Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid
[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
26   DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/)
27
28 install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/graphicator
29   DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/)
30
31 install(PROGRAMS ${CMAKE_HOME_DIRECTORY}/tools/MSG_visualization/colorize.pl
32   DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/
33   RENAME simgrid-colorizer)
34
35 add_custom_target(simgrid-colorizer ALL
36   COMMENT "Install ${CMAKE_BINARY_DIR}/bin/colorize"
37   COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_HOME_DIRECTORY}/tools/MSG_visualization/colorize.pl ${CMAKE_BINARY_DIR}/bin/colorize
38   )
39
40 install(PROGRAMS ${CMAKE_HOME_DIRECTORY}/tools/simgrid_update_xml.pl
41   DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/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
49 # libraries
50 install(TARGETS simgrid
51   DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/)
52
53 if(enable_java)
54   set(SIMGRID_JAR_TO_INSTALL "${SIMGRID_JAR}")
55   install(TARGETS simgrid-java
56       DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/)
57   install(FILES ${SIMGRID_JAR_TO_INSTALL}
58       DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/java/
59       RENAME simgrid.jar)
60 endif()
61
62 # include files
63 set(HEADERS
64   ${headers_to_install}
65   ${generated_headers_to_install}
66   )
67 foreach(file ${HEADERS})
68   get_filename_component(location ${file} PATH)
69   string(REPLACE "${CMAKE_CURRENT_BINARY_DIR}/" "" location "${location}")
70   install(FILES ${file}
71     DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${location})
72 endforeach(file ${HEADERS})
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 $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/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/graphicator
101   COMMAND ${CMAKE_COMMAND} -E   echo "uninstall bin ok"
102   COMMAND ${CMAKE_COMMAND} -E   remove_directory ${CMAKE_INSTALL_PREFIX}/include/instr
103   COMMAND ${CMAKE_COMMAND} -E   remove_directory ${CMAKE_INSTALL_PREFIX}/include/msg
104   COMMAND ${CMAKE_COMMAND} -E   remove_directory ${CMAKE_INSTALL_PREFIX}/include/simdag
105   COMMAND ${CMAKE_COMMAND} -E   remove_directory ${CMAKE_INSTALL_PREFIX}/include/smpi
106   COMMAND ${CMAKE_COMMAND} -E   remove_directory ${CMAKE_INSTALL_PREFIX}/include/simix
107   COMMAND ${CMAKE_COMMAND} -E   remove_directory ${CMAKE_INSTALL_PREFIX}/include/surf
108   COMMAND ${CMAKE_COMMAND} -E   remove_directory ${CMAKE_INSTALL_PREFIX}/include/xbt
109   COMMAND ${CMAKE_COMMAND} -E   remove_directory ${CMAKE_INSTALL_PREFIX}/include/mc
110   COMMAND ${CMAKE_COMMAND} -E   remove_directory ${CMAKE_INSTALL_PREFIX}/include/simgrid
111   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/include/simgrid.h
112   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/include/simgrid_config.h
113   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/include/xbt.h
114   COMMAND ${CMAKE_COMMAND} -E   echo "uninstall include ok"
115   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/share/man/man1/simgrid_update_xml.1
116   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/share/man/man1/tesh.1
117   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/share/man/man1/smpicc.1
118   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/share/man/man1/smpicxx.1
119   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/share/man/man1/smpirun.1
120   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/share/man/man1/smpiff.1
121   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/share/man/man1/smpif90.1
122   
123     
124   COMMAND ${CMAKE_COMMAND} -E   echo "uninstall man ok"
125   WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}"
126   )
127
128 if(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     )
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   ${JSURF_SWIG_SRC}
151   ${JSURF_SWIG_SRC_EXTRA}
152   ${JSURF_C_SRC}
153   ${LUA_SRC}
154   ${MC_SRC_BASE}
155   ${MC_SRC}
156   ${MC_SIMGRID_MC_SRC}
157   ${MSG_SRC}
158   ${S4U_SRC}
159   ${NS3_SRC}
160   ${RNGSTREAM_SRC}
161   ${SIMDAG_SRC}
162   ${SIMGRID_SRC}
163   ${SIMIX_SRC}
164   ${SMPI_SRC}
165   ${SURF_SRC}
166   ${TRACING_SRC}
167   ${XBT_RL_SRC}
168   ${XBT_SRC}
169   ${EXTRA_DIST}
170   ${CMAKE_SOURCE_FILES}
171   ${CMAKEFILES_TXT}
172   ${DOC_FIGS}
173   ${DOC_IMG}
174   ${DOC_SOURCES}
175   ${DOC_TOOLS}
176   ${PLATFORMS_EXAMPLES}
177   ${README_files}
178   ${bin_files}
179   ${examples_src}
180   ${tesh_files}
181   ${teshsuite_src}
182   ${testsuite_src}
183   ${tools_src}
184   ${txt_files}
185   ${xml_files}
186   )
187
188 ##########################################
189 ### Fill in the "make dist-dir" target ###
190 ##########################################
191
192 add_custom_target(dist-dir
193   COMMENT "Generating the distribution directory"
194   COMMAND ${CMAKE_COMMAND} -E remove_directory ${PROJECT_NAME}-${release_version}/
195   COMMAND ${CMAKE_COMMAND} -E remove ${PROJECT_NAME}-${release_version}.tar.gz
196   COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_NAME}-${release_version}
197   COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_NAME}-${release_version}/doc/html/
198   COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_HOME_DIRECTORY}/doc/html/ ${PROJECT_NAME}-${release_version}/doc/html/
199   )
200 add_dependencies(dist-dir maintainer_files)
201
202 set(dirs_in_tarball "")
203 foreach(file ${source_to_pack})
204   #message(${file})
205   # This damn prefix is still set somewhere (seems to be in subdirs)
206   string(REPLACE "${CMAKE_HOME_DIRECTORY}/" "" file "${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       )
217   endif()
218
219   # Actually copy the file
220   add_custom_command(
221     TARGET dist-dir
222     COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_HOME_DIRECTORY}/${file} ${PROJECT_NAME}-${release_version}/${file_location}
223     )
224 endforeach(file ${source_to_pack})
225
226 add_custom_command(
227   TARGET dist-dir
228   COMMAND ${CMAKE_COMMAND} -E echo "${GIT_VERSION}" > ${PROJECT_NAME}-${release_version}/.gitversion
229   )
230
231 ######################################
232 ### Fill in the "make dist" target ###
233 ######################################
234
235 add_custom_target(dist
236   COMMENT "Removing the distribution directory"
237   DEPENDS ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-${release_version}.tar.gz
238   COMMAND ${CMAKE_COMMAND} -E echo ${PROJECT_NAME}-${release_version} > ${CMAKE_BINARY_DIR}/VERSION
239   COMMAND ${CMAKE_COMMAND} -E remove_directory ${PROJECT_NAME}-${release_version}/
240   )
241
242 add_custom_command(
243   OUTPUT ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-${release_version}.tar.gz
244   COMMENT "Compressing the archive from the distribution directory"
245   COMMAND ${CMAKE_COMMAND} -E tar cf ${PROJECT_NAME}-${release_version}.tar ${PROJECT_NAME}-${release_version}/
246   COMMAND gzip -9v ${PROJECT_NAME}-${release_version}.tar
247   COMMAND ${CMAKE_COMMAND} -E remove_directory ${PROJECT_NAME}-${release_version}/
248   )
249 add_dependencies(dist dist-dir)
250
251 if(NOT enable_maintainer_mode)
252   add_custom_target(echo-dist
253     COMMAND ${CMAKE_COMMAND} -E echo "WARNING: ----------------------------------------------------"
254     COMMAND ${CMAKE_COMMAND} -E echo "WARNING: Distrib is generated without option maintainer mode "
255     COMMAND ${CMAKE_COMMAND} -E echo "WARNING: ----------------------------------------------------"
256     )
257   add_dependencies(dist echo-dist)
258 endif()
259
260 ###########################################
261 ### Fill in the "make distcheck" target ###
262 ###########################################
263
264 set(CMAKE_BINARY_TEST_DIR ${CMAKE_BINARY_DIR})
265
266 # Allow to test the "make dist"
267 add_custom_target(distcheck
268   COMMAND ${CMAKE_COMMAND} -E echo "XXX compare archive with git repository"
269   COMMAND ${CMAKE_HOME_DIRECTORY}/tools/internal/check_dist_archive -batch ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}.tar.gz
270
271   COMMAND ${CMAKE_COMMAND} -E echo "XXX remove old copy"
272   COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}
273
274   COMMAND ${CMAKE_COMMAND} -E echo "XXX Untar distrib"
275   COMMAND ${CMAKE_COMMAND} -E tar xf ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}.tar.gz ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}
276
277   COMMAND ${CMAKE_COMMAND} -E echo "XXX create build and install subtrees"
278   COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}/_build
279   COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}/_inst
280
281   COMMAND ${CMAKE_COMMAND} -E echo "XXX Configure"
282   COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}/_build
283   ${CMAKE_COMMAND}
284   -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}/_inst
285   ..
286   COMMAND ${CMAKE_COMMAND} -E echo "XXX Build"
287   COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}/_build ${CMAKE_MAKE_PROGRAM}
288
289   COMMAND ${CMAKE_COMMAND} -E echo "XXX Test"
290   COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}/_build ctest --output-on-failure
291
292   COMMAND ${CMAKE_COMMAND} -E echo "XXX Install"
293   COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}/_build ${CMAKE_MAKE_PROGRAM} install
294   COMMAND ${CMAKE_COMMAND} -E create_symlink
295   ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}/_inst/lib/libsimgrid.so
296   ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}/_inst/lib/libsimgridtest.so
297
298   COMMAND ${CMAKE_COMMAND} -E echo "XXX Install with documentation"
299   COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}/_build ${CMAKE_MAKE_PROGRAM} install
300
301   COMMAND ${CMAKE_COMMAND} -E echo "XXX Remove temp directories"
302   COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}
303   )
304 add_dependencies(distcheck dist)
305
306 #######################################
307 ### Fill in the "make check" target ###
308 #######################################
309
310 if(enable_memcheck)
311   add_custom_target(check
312     COMMAND ctest -D ExperimentalMemCheck
313     )
314 else()
315   add_custom_target(check
316     COMMAND make test
317     )
318 endif()
319
320 #######################################
321 ### Fill in the "make xxx-clean" target ###
322 #######################################
323
324 add_custom_target(maintainer-clean
325   COMMAND ${CMAKE_COMMAND} -E remove -f src/config_unit.c
326   COMMAND ${CMAKE_COMMAND} -E remove -f src/cunit_unit.c
327   COMMAND ${CMAKE_COMMAND} -E remove -f src/dict_unit.c
328   COMMAND ${CMAKE_COMMAND} -E remove -f src/dynar_unit.c
329   COMMAND ${CMAKE_COMMAND} -E remove -f src/ex_unit.c
330   COMMAND ${CMAKE_COMMAND} -E remove -f src/set_unit.c
331   COMMAND ${CMAKE_COMMAND} -E remove -f src/simgrid_units_main.c
332   COMMAND ${CMAKE_COMMAND} -E remove -f src/swag_unit.c
333   COMMAND ${CMAKE_COMMAND} -E remove -f src/xbt_str_unit.c
334   COMMAND ${CMAKE_COMMAND} -E remove -f src/xbt_strbuff_unit.c
335   COMMAND ${CMAKE_COMMAND} -E remove -f src/xbt_synchro_unit.c
336   WORKING_DIRECTORY "${CMAKE_HOME_DIRECTORY}"
337   )
338
339 include(CPack)