Logo AND Algorithmique Numérique Distribuée

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