Logo AND Algorithmique Numérique Distribuée

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