Logo AND Algorithmique Numérique Distribuée

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