Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
91b516c33cdb070934b3a26f4eb4e27c3a0f8aec
[simgrid.git] / tools / cmake / Distrib.cmake
1 #########################################
2 ### Fill in the "make install" target ###
3 #########################################
4
5 # doc
6 file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/doc/html/)
7 install(DIRECTORY "${CMAKE_BINARY_DIR}/doc/html/"
8   DESTINATION doc/simgrid/html/)
9
10 # binaries
11 if(enable_smpi)
12   install(PROGRAMS
13     ${CMAKE_BINARY_DIR}/bin/smpicc
14     ${CMAKE_BINARY_DIR}/bin/smpicxx
15     ${CMAKE_BINARY_DIR}/bin/smpirun
16     DESTINATION bin/)
17   if(SMPI_FORTRAN)
18     install(PROGRAMS
19       ${CMAKE_BINARY_DIR}/bin/smpif90
20       ${CMAKE_BINARY_DIR}/bin/smpiff
21       DESTINATION bin/)
22     install(PROGRAMS
23       ${CMAKE_BINARY_DIR}/include/smpi/mpi.mod
24       DESTINATION include/smpi/)
25   endif()
26 endif()
27
28 install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/tesh  DESTINATION bin/)
29
30 install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/graphicator  DESTINATION bin/)
31
32 install(PROGRAMS ${CMAKE_HOME_DIRECTORY}/tools/MSG_visualization/colorize.pl
33   DESTINATION bin/
34   RENAME simgrid-colorizer)
35
36 add_custom_target(simgrid-colorizer ALL
37   COMMENT "Install ${CMAKE_BINARY_DIR}/bin/colorize"
38   COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_HOME_DIRECTORY}/tools/MSG_visualization/colorize.pl ${CMAKE_BINARY_DIR}/bin/colorize)
39
40 install(PROGRAMS ${CMAKE_HOME_DIRECTORY}/tools/simgrid_update_xml.pl
41   DESTINATION bin/
42   RENAME simgrid_update_xml)
43
44 add_custom_target(simgrid_update_xml ALL
45   COMMENT "Install ${CMAKE_BINARY_DIR}/bin/simgrid_update_xml"
46   COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_HOME_DIRECTORY}/tools/simgrid_update_xml.pl ${CMAKE_BINARY_DIR}/bin/simgrid_update_xml)
47
48 install(PROGRAMS ${CMAKE_HOME_DIRECTORY}/tools/simgrid_convert_TI_traces.py
49   DESTINATION bin/
50   RENAME simgrid_convert_TI_traces)
51
52 add_custom_target(simgrid_convert_TI_traces ALL
53     COMMENT "Install ${CMAKE_BINARY_DIR}/bin/simgrid_convert_TI_traces"
54     COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_HOME_DIRECTORY}/tools/simgrid_convert_TI_traces.py ${CMAKE_BINARY_DIR}/bin/simgrid_convert_TI_traces)
55
56 # libraries
57 install(TARGETS simgrid DESTINATION lib/)
58
59 if(enable_java)
60   set(SIMGRID_JAR_TO_INSTALL "${SIMGRID_JAR}")
61   install(TARGETS simgrid-java   DESTINATION lib/)
62   install(FILES ${SIMGRID_JAR_TO_INSTALL}
63       DESTINATION java/
64       RENAME simgrid.jar)
65 endif()
66
67 # pkg-config files
68 configure_file("${CMAKE_HOME_DIRECTORY}/tools/pkg-config/simgrid.pc.in"
69   "${PROJECT_BINARY_DIR}/simgrid.pc" @ONLY)
70 install(FILES "${PROJECT_BINARY_DIR}/simgrid.pc" DESTINATION lib/pkgconfig/)
71
72 # include files
73 foreach(file ${headers_to_install}  ${generated_headers_to_install})
74   get_filename_component(location ${file} PATH)
75   string(REPLACE "${CMAKE_CURRENT_BINARY_DIR}/" "" location "${location}")
76   install(FILES ${file} DESTINATION ${location})
77 endforeach()
78
79 # example files
80 foreach(file ${examples_to_install})
81   string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/examples/" "" file ${file})
82   get_filename_component(location ${file} PATH)
83   install(FILES "examples/${file}"
84     DESTINATION doc/simgrid/examples/${location})
85 endforeach(file ${examples_to_install})
86
87 ###########################################
88 ### Fill in the "make uninstall" target ###
89 ###########################################
90
91 add_custom_target(uninstall
92   COMMAND ${CMAKE_COMMAND} -E   remove_directory ${CMAKE_INSTALL_PREFIX}/doc/simgrid
93   COMMAND ${CMAKE_COMMAND} -E   echo "uninstall doc ok"
94   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/lib/libsimgrid*
95   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/lib/lua/5.1/simgrid*
96   COMMAND ${CMAKE_COMMAND} -E   echo "uninstall lib ok"
97   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/bin/smpicc
98   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/bin/smpicxx
99   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/bin/smpiff
100   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/bin/smpif90
101   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/bin/smpirun
102   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/bin/tesh
103   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/bin/simgrid-colorizer
104   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/bin/simgrid_update_xml
105   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/bin/simgrid_convert_TI_traces
106   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/bin/graphicator
107   COMMAND ${CMAKE_COMMAND} -E   echo "uninstall bin ok"
108   COMMAND ${CMAKE_COMMAND} -E   remove_directory ${CMAKE_INSTALL_PREFIX}/include/instr
109   COMMAND ${CMAKE_COMMAND} -E   remove_directory ${CMAKE_INSTALL_PREFIX}/include/msg
110   COMMAND ${CMAKE_COMMAND} -E   remove_directory ${CMAKE_INSTALL_PREFIX}/include/simdag
111   COMMAND ${CMAKE_COMMAND} -E   remove_directory ${CMAKE_INSTALL_PREFIX}/include/smpi
112   COMMAND ${CMAKE_COMMAND} -E   remove_directory ${CMAKE_INSTALL_PREFIX}/include/simix
113   COMMAND ${CMAKE_COMMAND} -E   remove_directory ${CMAKE_INSTALL_PREFIX}/include/surf
114   COMMAND ${CMAKE_COMMAND} -E   remove_directory ${CMAKE_INSTALL_PREFIX}/include/xbt
115   COMMAND ${CMAKE_COMMAND} -E   remove_directory ${CMAKE_INSTALL_PREFIX}/include/mc
116   COMMAND ${CMAKE_COMMAND} -E   remove_directory ${CMAKE_INSTALL_PREFIX}/include/simgrid
117   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/include/simgrid.h
118   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/include/simgrid/config.h
119   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/include/xbt.h
120   COMMAND ${CMAKE_COMMAND} -E   echo "uninstall include ok"
121   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/share/man/man1/simgrid_update_xml.1
122   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/share/man/man1/tesh.1
123   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/share/man/man1/smpicc.1
124   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/share/man/man1/smpicxx.1
125   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/share/man/man1/smpirun.1
126   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/share/man/man1/smpiff.1
127   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/share/man/man1/smpif90.1
128
129
130   COMMAND ${CMAKE_COMMAND} -E   echo "uninstall man ok"
131   WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}")
132
133 if(SIMGRID_HAVE_LUA)
134   add_custom_command(TARGET uninstall
135     COMMAND ${CMAKE_COMMAND} -E echo "uninstall binding lua ok"
136     COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_INSTALL_PREFIX}/lib/lua/5.1/simgrid.${LIB_EXE}
137     WORKING_DIRECTORY "${CMAKE_HOME_DIRECTORY}/")
138 endif()
139
140 ################################################################
141 ## Build a sain "make dist" target to build a source package ###
142 ##   containing only the files that I explicitely state      ###
143 ##   (instead of any cruft laying on my disk as CPack does)  ###
144 ################################################################
145
146 # This is the complete list of what will be added to the source archive
147 set(source_to_pack
148   ${headers_to_install}
149   ${source_of_generated_headers}
150   ${BINDINGS_SRC}
151   ${JEDULE_SRC}
152   ${JMSG_C_SRC}
153   ${JMSG_JAVA_SRC}
154   ${LUA_SRC}
155   ${MC_SRC_BASE}
156   ${MC_SRC}
157   ${MC_SIMGRID_MC_SRC}
158   ${MSG_SRC}
159   ${S4U_SRC}
160   ${NS3_SRC}
161   ${PLUGINS_SRC}
162   ${RNGSTREAM_SRC}
163   ${SIMDAG_SRC}
164   ${SIMGRID_SRC}
165   ${SIMIX_SRC}
166   ${SMPI_SRC}
167   ${SURF_SRC}
168   ${TRACING_SRC}
169   ${XBT_RL_SRC}
170   ${XBT_SRC}
171   ${EXTRA_DIST}
172   ${CMAKE_SOURCE_FILES}
173   ${CMAKEFILES_TXT}
174   ${DOC_FIGS}
175   ${DOC_IMG}
176   ${DOC_SOURCES}
177   ${DOC_TOOLS}
178   ${PLATFORMS_EXAMPLES}
179   ${README_files}
180   ${bin_files}
181   ${examples_src}
182   ${tesh_files}
183   ${teshsuite_src}
184   ${testsuite_src}
185   ${tools_src}
186   ${txt_files}
187   ${xml_files}
188   )
189
190 ##########################################
191 ### Fill in the "make dist-dir" target ###
192 ##########################################
193
194 add_custom_target(dist-dir
195   COMMENT "Generating the distribution directory"
196   COMMAND ${CMAKE_COMMAND} -E remove_directory ${PROJECT_NAME}-${release_version}/
197   COMMAND ${CMAKE_COMMAND} -E remove ${PROJECT_NAME}-${release_version}.tar.gz
198   COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_NAME}-${release_version}
199   COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_NAME}-${release_version}/doc/html/
200   COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_BINARY_DIR}/doc/html/ ${PROJECT_NAME}-${release_version}/doc/html/
201   COMMAND rm -f `grep -rl " Reference" ${PROJECT_NAME}-${release_version}/doc/html/` # Doxygen, go away
202   COMMAND rm -f `grep -rl "Member List" ${PROJECT_NAME}-${release_version}/doc/html/` # Doxygen, you're getting annoying
203   )
204 add_dependencies(dist-dir maintainer_files)
205
206 set(dirs_in_tarball "")
207 foreach(file ${source_to_pack})
208   #message(${file})
209   # This damn prefix is still set somewhere (seems to be in subdirs)
210   string(REPLACE "${CMAKE_HOME_DIRECTORY}/" "" file "${file}")
211
212   # Create the directory on need
213   get_filename_component(file_location ${file} PATH)
214   string(REGEX MATCH ";${file_location};" OPERATION "${dirs_in_tarball}")
215   if(NOT OPERATION)
216     set(dirs_in_tarball "${dirs_in_tarball};${file_location};")
217     add_custom_command(
218       TARGET dist-dir
219       COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_NAME}-${release_version}/${file_location}/)
220   endif()
221
222   # Actually copy the file
223   add_custom_command(
224     TARGET dist-dir
225     COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_HOME_DIRECTORY}/${file} ${PROJECT_NAME}-${release_version}/${file_location})
226 endforeach(file ${source_to_pack})
227
228 add_custom_command(
229   TARGET dist-dir
230   COMMAND ${CMAKE_COMMAND} -E echo "${GIT_VERSION}" > ${PROJECT_NAME}-${release_version}/.gitversion)
231
232 ##########################################################
233 ### Link all sources to the bindir if srcdir != bindir ###
234 ##########################################################
235 add_custom_target(hardlinks
236    COMMENT "Making the source files available from the bindir"
237 )
238 if (NOT ${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
239   foreach(file ${source_to_pack})
240     #message(${file})
241     # This damn prefix is still set somewhere (seems to be in subdirs)
242     string(REPLACE "${CMAKE_HOME_DIRECTORY}/" "" file "${file}")
243
244     # Create the directory on need
245     get_filename_component(file_location ${file} PATH)
246     string(REGEX MATCH ";${file_location};" OPERATION "${dirs_in_bindir}")
247     if(NOT OPERATION)
248       set(dirs_in_tarball "${dirs_in_bindir};${file_location};")
249       add_custom_command(
250         TARGET hardlinks
251         COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/${file_location}/)
252     endif()
253
254     # Actually copy the file
255     add_custom_command(
256       TARGET hardlinks
257       COMMAND if test -f ${CMAKE_HOME_DIRECTORY}/${file} \; then rm -f ${CMAKE_BINARY_DIR}/${file}\; ln ${CMAKE_HOME_DIRECTORY}/${file} ${CMAKE_BINARY_DIR}/${file_location}\; fi
258     )
259   endforeach(file ${source_to_pack})
260 endif()
261
262
263 ######################################
264 ### Fill in the "make dist" target ###
265 ######################################
266
267 add_custom_target(dist
268   COMMENT "Removing the distribution directory"
269   DEPENDS ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-${release_version}.tar.gz
270   COMMAND ${CMAKE_COMMAND} -E echo ${PROJECT_NAME}-${release_version} > ${CMAKE_BINARY_DIR}/VERSION
271   COMMAND ${CMAKE_COMMAND} -E remove_directory ${PROJECT_NAME}-${release_version}/)
272
273 add_custom_command(
274   OUTPUT ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-${release_version}.tar.gz
275   COMMENT "Compressing the archive from the distribution directory"
276   COMMAND ${CMAKE_COMMAND} -E tar cf ${PROJECT_NAME}-${release_version}.tar ${PROJECT_NAME}-${release_version}/
277   COMMAND gzip -9v ${PROJECT_NAME}-${release_version}.tar
278   COMMAND ${CMAKE_COMMAND} -E remove_directory ${PROJECT_NAME}-${release_version}/)
279 add_dependencies(dist dist-dir)
280
281 if(NOT enable_maintainer_mode)
282   add_custom_target(echo-dist
283     COMMAND ${CMAKE_COMMAND} -E echo "WARNING: ----------------------------------------------------"
284     COMMAND ${CMAKE_COMMAND} -E echo "WARNING: Distrib is generated without option maintainer mode "
285     COMMAND ${CMAKE_COMMAND} -E echo "WARNING: ----------------------------------------------------")
286   add_dependencies(dist echo-dist)
287 endif()
288
289 ###########################################
290 ### Fill in the "make distcheck" target ###
291 ###########################################
292
293 set(CMAKE_BINARY_TEST_DIR ${CMAKE_BINARY_DIR})
294
295 # Allow to test the "make dist"
296 add_custom_target(distcheck
297   COMMAND ${CMAKE_COMMAND} -E echo "XXX compare archive with git repository"
298   COMMAND ${CMAKE_HOME_DIRECTORY}/tools/internal/check_dist_archive -batch ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}.tar.gz
299
300   COMMAND ${CMAKE_COMMAND} -E echo "XXX remove old copy"
301   COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}
302
303   COMMAND ${CMAKE_COMMAND} -E echo "XXX Untar distrib"
304   COMMAND ${CMAKE_COMMAND} -E tar xf ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}.tar.gz ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}
305
306   COMMAND ${CMAKE_COMMAND} -E echo "XXX create build and install subtrees"
307   COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}/_build
308   COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}/_inst
309
310   COMMAND ${CMAKE_COMMAND} -E echo "XXX Configure"
311   COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}/_build
312           ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}/_inst -Denable_lto=OFF ..
313         
314   COMMAND ${CMAKE_COMMAND} -E echo "XXX Build"
315   COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}/_build ${CMAKE_MAKE_PROGRAM} -j 4
316
317   COMMAND ${CMAKE_COMMAND} -E echo "XXX Install"
318   COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}/_build ${CMAKE_MAKE_PROGRAM} install
319
320   COMMAND ${CMAKE_COMMAND} -E echo "XXX Build tests"
321   COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}/_build ${CMAKE_MAKE_PROGRAM} -j 4 tests
322
323   COMMAND ${CMAKE_COMMAND} -E echo "XXX Run tests"
324   COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}/_build ctest --output-on-failure -j 4
325
326   COMMAND ${CMAKE_COMMAND} -E echo "XXX Remove temp directories"
327   COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}
328   )
329 add_dependencies(distcheck dist)
330
331 #######################################
332 ### Fill in the "make check" target ###
333 #######################################
334
335 if(enable_memcheck)
336   add_custom_target(check COMMAND ctest -D ExperimentalMemCheck)
337 else()
338   add_custom_target(check COMMAND make test)
339 endif()
340 add_dependencies(check tests)
341
342 #######################################
343 ### Fill in the "make xxx-clean" target ###
344 #######################################
345
346 add_custom_target(maintainer-clean
347   COMMAND ${CMAKE_COMMAND} -E remove -f src/mpif.f90
348   WORKING_DIRECTORY "${CMAKE_HOME_DIRECTORY}")
349
350 include(CPack)