Logo AND Algorithmique Numérique Distribuée

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