Logo AND Algorithmique Numérique Distribuée

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