Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of 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   ${EXAMPLES_CMAKEFILES_TXT}
172   ${TESHSUITE_CMAKEFILES_TXT}
173   ${TOOLS_CMAKEFILES_TXT}
174   ${DOC_FIGS}
175   ${DOC_IMG}
176   ${DOC_SOURCES}
177   ${DOC_TOOLS}
178   ${PLATFORMS_EXAMPLES}
179   ${README_files}
180   ${bin_files}
181   ${examples_src}
182   ${tesh_files}
183   ${teshsuite_src}
184   ${testsuite_src}
185   ${tools_src}
186   ${txt_files}
187   ${xml_files}
188   )
189
190 ##########################################
191 ### Fill in the "make dist-dir" target ###
192 ##########################################
193
194 add_custom_target(dist-dir
195   COMMENT "Generating the distribution directory"
196   COMMAND ${CMAKE_COMMAND} -E remove_directory ${PROJECT_NAME}-${release_version}/
197   COMMAND ${CMAKE_COMMAND} -E remove ${PROJECT_NAME}-${release_version}.tar.gz
198   COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_NAME}-${release_version}
199   COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_NAME}-${release_version}/doc/html/
200   COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_HOME_DIRECTORY}/doc/html/ ${PROJECT_NAME}-${release_version}/doc/html/
201   )
202 add_dependencies(dist-dir maintainer_files)
203
204 set(dirs_in_tarball "")
205 foreach(file ${source_to_pack})
206   #message(${file})
207   # This damn prefix is still set somewhere (seems to be in subdirs)
208   string(REPLACE "${CMAKE_HOME_DIRECTORY}/" "" file "${file}")
209
210   # Create the directory on need
211   get_filename_component(file_location ${file} PATH)
212   string(REGEX MATCH ";${file_location};" OPERATION "${dirs_in_tarball}")
213   if(NOT OPERATION)
214     set(dirs_in_tarball "${dirs_in_tarball};${file_location};")
215     add_custom_command(
216       TARGET dist-dir
217       COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_NAME}-${release_version}/${file_location}/
218       )
219   endif()
220
221   # Actually copy the file
222   add_custom_command(
223     TARGET dist-dir
224     COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_HOME_DIRECTORY}/${file} ${PROJECT_NAME}-${release_version}/${file_location}
225     )
226 endforeach(file ${source_to_pack})
227
228 add_custom_command(
229   TARGET dist-dir
230   COMMAND ${CMAKE_COMMAND} -E echo "${GIT_VERSION}" > ${PROJECT_NAME}-${release_version}/.gitversion
231   )
232
233 ######################################
234 ### Fill in the "make dist" target ###
235 ######################################
236
237 add_custom_target(dist
238   COMMENT "Removing the distribution directory"
239   DEPENDS ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-${release_version}.tar.gz
240   COMMAND ${CMAKE_COMMAND} -E echo ${PROJECT_NAME}-${release_version} > ${CMAKE_BINARY_DIR}/VERSION
241   COMMAND ${CMAKE_COMMAND} -E remove_directory ${PROJECT_NAME}-${release_version}/
242   )
243
244 add_custom_command(
245   OUTPUT ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-${release_version}.tar.gz
246   COMMENT "Compressing the archive from the distribution directory"
247   COMMAND ${CMAKE_COMMAND} -E tar cf ${PROJECT_NAME}-${release_version}.tar ${PROJECT_NAME}-${release_version}/
248   COMMAND gzip -9v ${PROJECT_NAME}-${release_version}.tar
249   COMMAND ${CMAKE_COMMAND} -E remove_directory ${PROJECT_NAME}-${release_version}/
250   )
251 add_dependencies(dist dist-dir)
252
253 if(NOT enable_maintainer_mode)
254   add_custom_target(echo-dist
255     COMMAND ${CMAKE_COMMAND} -E echo "WARNING: ----------------------------------------------------"
256     COMMAND ${CMAKE_COMMAND} -E echo "WARNING: Distrib is generated without option maintainer mode "
257     COMMAND ${CMAKE_COMMAND} -E echo "WARNING: ----------------------------------------------------"
258     )
259   add_dependencies(dist echo-dist)
260 endif()
261
262 ###########################################
263 ### Fill in the "make distcheck" target ###
264 ###########################################
265
266 set(CMAKE_BINARY_TEST_DIR ${CMAKE_BINARY_DIR})
267
268 # Allow to test the "make dist"
269 add_custom_target(distcheck
270   COMMAND ${CMAKE_COMMAND} -E echo "XXX compare archive with git repository"
271   COMMAND ${CMAKE_HOME_DIRECTORY}/tools/internal/check_dist_archive -batch ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}.tar.gz
272
273   COMMAND ${CMAKE_COMMAND} -E echo "XXX remove old copy"
274   COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}
275
276   COMMAND ${CMAKE_COMMAND} -E echo "XXX Untar distrib"
277   COMMAND ${CMAKE_COMMAND} -E tar xf ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}.tar.gz ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}
278
279   COMMAND ${CMAKE_COMMAND} -E echo "XXX create build and install subtrees"
280   COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}/_build
281   COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}/_inst
282
283   COMMAND ${CMAKE_COMMAND} -E echo "XXX Configure"
284   COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}/_build
285   ${CMAKE_COMMAND}
286   -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}/_inst
287   ..
288   COMMAND ${CMAKE_COMMAND} -E echo "XXX Build"
289   COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}/_build ${CMAKE_MAKE_PROGRAM}
290
291   COMMAND ${CMAKE_COMMAND} -E echo "XXX Test"
292   COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}/_build ctest --output-on-failure
293
294   COMMAND ${CMAKE_COMMAND} -E echo "XXX Install"
295   COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}/_build ${CMAKE_MAKE_PROGRAM} install
296   COMMAND ${CMAKE_COMMAND} -E create_symlink
297   ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}/_inst/lib/libsimgrid.so
298   ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}/_inst/lib/libsimgridtest.so
299
300   COMMAND ${CMAKE_COMMAND} -E echo "XXX Install with documentation"
301   COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}/_build ${CMAKE_MAKE_PROGRAM} install
302
303   COMMAND ${CMAKE_COMMAND} -E echo "XXX Remove temp directories"
304   COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}
305   )
306 add_dependencies(distcheck dist)
307
308 #######################################
309 ### Fill in the "make check" target ###
310 #######################################
311
312 if(enable_memcheck)
313   add_custom_target(check
314     COMMAND ctest -D ExperimentalMemCheck
315     )
316 else()
317   add_custom_target(check
318     COMMAND make test
319     )
320 endif()
321
322 #######################################
323 ### Fill in the "make xxx-clean" target ###
324 #######################################
325
326 add_custom_target(maintainer-clean
327   COMMAND ${CMAKE_COMMAND} -E remove -f src/config_unit.c
328   COMMAND ${CMAKE_COMMAND} -E remove -f src/cunit_unit.c
329   COMMAND ${CMAKE_COMMAND} -E remove -f src/dict_unit.c
330   COMMAND ${CMAKE_COMMAND} -E remove -f src/dynar_unit.c
331   COMMAND ${CMAKE_COMMAND} -E remove -f src/ex_unit.c
332   COMMAND ${CMAKE_COMMAND} -E remove -f src/set_unit.c
333   COMMAND ${CMAKE_COMMAND} -E remove -f src/simgrid_units_main.c
334   COMMAND ${CMAKE_COMMAND} -E remove -f src/swag_unit.c
335   COMMAND ${CMAKE_COMMAND} -E remove -f src/xbt_sha_unit.c
336   COMMAND ${CMAKE_COMMAND} -E remove -f src/xbt_str_unit.c
337   COMMAND ${CMAKE_COMMAND} -E remove -f src/xbt_strbuff_unit.c
338   COMMAND ${CMAKE_COMMAND} -E remove -f src/xbt_synchro_unit.c
339   WORKING_DIRECTORY "${CMAKE_HOME_DIRECTORY}"
340   )
341
342 include(CPack)