Logo AND Algorithmique Numérique Distribuée

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