Logo AND Algorithmique Numérique Distribuée

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