Logo AND Algorithmique Numérique Distribuée

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