Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
reindent
[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 install(PROGRAMS ${CMAKE_HOME_DIRECTORY}/tools/simgrid_update_xml.pl
40   DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/
41   RENAME simgrid_update_xml)
42
43 add_custom_target(simgrid_update_xml ALL
44   COMMENT "Install ${CMAKE_BINARY_DIR}/bin/simgrid_update_xml"
45   COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_HOME_DIRECTORY}/tools/simgrid_update_xml.pl ${CMAKE_BINARY_DIR}/bin/simgrid_update_xml)
46
47 # libraries
48 install(TARGETS simgrid
49   DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/)
50
51 if(enable_java)
52   set(SIMGRID_JAR_TO_INSTALL "${SIMGRID_JAR}")
53   install(TARGETS simgrid-java
54       DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/)
55   install(FILES ${SIMGRID_JAR_TO_INSTALL}
56       DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/java/
57       RENAME simgrid.jar)
58 endif()
59
60 # include files
61 set(HEADERS
62   ${headers_to_install}
63   ${generated_headers_to_install}
64   )
65 foreach(file ${HEADERS})
66   get_filename_component(location ${file} PATH)
67   string(REPLACE "${CMAKE_CURRENT_BINARY_DIR}/" "" location "${location}")
68   install(FILES ${file}
69     DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${location})
70 endforeach(file ${HEADERS})
71
72 # example files
73 foreach(file ${examples_to_install})
74   string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/examples/" "" file ${file})
75   get_filename_component(location ${file} PATH)
76   install(FILES "examples/${file}"
77     DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/doc/simgrid/examples/${location})
78 endforeach(file ${examples_to_install})
79
80 ###########################################
81 ### Fill in the "make uninstall" target ###
82 ###########################################
83
84 add_custom_target(uninstall
85   COMMAND ${CMAKE_COMMAND} -E   remove_directory ${CMAKE_INSTALL_PREFIX}/doc/simgrid
86   COMMAND ${CMAKE_COMMAND} -E   echo "uninstall doc ok"
87   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/lib/libsimgrid*
88   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/lib/lua/5.1/simgrid*
89   COMMAND ${CMAKE_COMMAND} -E   echo "uninstall lib ok"
90   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/bin/smpicc
91   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/bin/smpicxx
92   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/bin/smpiff
93   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/bin/smpif90
94   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/bin/smpirun
95   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/bin/tesh
96   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/bin/simgrid-colorizer
97   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/bin/simgrid_update_xml
98   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/bin/graphicator
99   COMMAND ${CMAKE_COMMAND} -E   echo "uninstall bin ok"
100   COMMAND ${CMAKE_COMMAND} -E   remove_directory ${CMAKE_INSTALL_PREFIX}/include/instr
101   COMMAND ${CMAKE_COMMAND} -E   remove_directory ${CMAKE_INSTALL_PREFIX}/include/msg
102   COMMAND ${CMAKE_COMMAND} -E   remove_directory ${CMAKE_INSTALL_PREFIX}/include/simdag
103   COMMAND ${CMAKE_COMMAND} -E   remove_directory ${CMAKE_INSTALL_PREFIX}/include/smpi
104   COMMAND ${CMAKE_COMMAND} -E   remove_directory ${CMAKE_INSTALL_PREFIX}/include/simix
105   COMMAND ${CMAKE_COMMAND} -E   remove_directory ${CMAKE_INSTALL_PREFIX}/include/surf
106   COMMAND ${CMAKE_COMMAND} -E   remove_directory ${CMAKE_INSTALL_PREFIX}/include/xbt
107   COMMAND ${CMAKE_COMMAND} -E   remove_directory ${CMAKE_INSTALL_PREFIX}/include/mc
108   COMMAND ${CMAKE_COMMAND} -E   remove_directory ${CMAKE_INSTALL_PREFIX}/include/simgrid
109   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/include/simgrid.h
110   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/include/simgrid_config.h
111   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/include/xbt.h
112   COMMAND ${CMAKE_COMMAND} -E   echo "uninstall include ok"
113   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/share/man/man1/simgrid_update_xml.1
114   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/share/man/man1/tesh.1
115   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/share/man/man1/smpicc.1
116   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/share/man/man1/smpicxx.1
117   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/share/man/man1/smpirun.1
118   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/share/man/man1/smpiff.1
119   COMMAND ${CMAKE_COMMAND} -E   remove -f ${CMAKE_INSTALL_PREFIX}/share/man/man1/smpif90.1
120   
121     
122   COMMAND ${CMAKE_COMMAND} -E   echo "uninstall man ok"
123   WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}")
124
125 if(HAVE_LUA)
126   add_custom_command(TARGET uninstall
127     COMMAND ${CMAKE_COMMAND} -E echo "uninstall binding lua ok"
128     COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_INSTALL_PREFIX}/lib/lua/5.1/simgrid.${LIB_EXE}
129     WORKING_DIRECTORY "${CMAKE_HOME_DIRECTORY}/")
130 endif()
131
132 ################################################################
133 ## Build a sain "make dist" target to build a source package ###
134 ##   containing only the files that I explicitely state      ###
135 ##   (instead of any cruft laying on my disk as CPack does)  ###
136 ################################################################
137
138 # This is the complete list of what will be added to the source archive
139 set(source_to_pack
140   ${headers_to_install}
141   ${source_of_generated_headers}
142   ${BINDINGS_SRC}
143   ${JEDULE_SRC}
144   ${JMSG_C_SRC}
145   ${JMSG_JAVA_SRC}
146   ${JSURF_SWIG_SRC}
147   ${JSURF_SWIG_SRC_EXTRA}
148   ${JSURF_C_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   ${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 add_dependencies(dist-dir maintainer_files)
196
197 set(dirs_in_tarball "")
198 foreach(file ${source_to_pack})
199   #message(${file})
200   # This damn prefix is still set somewhere (seems to be in subdirs)
201   string(REPLACE "${CMAKE_HOME_DIRECTORY}/" "" file "${file}")
202
203   # Create the directory on need
204   get_filename_component(file_location ${file} PATH)
205   string(REGEX MATCH ";${file_location};" OPERATION "${dirs_in_tarball}")
206   if(NOT OPERATION)
207     set(dirs_in_tarball "${dirs_in_tarball};${file_location};")
208     add_custom_command(
209       TARGET dist-dir
210       COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_NAME}-${release_version}/${file_location}/)
211   endif()
212
213   # Actually copy the file
214   add_custom_command(
215     TARGET dist-dir
216     COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_HOME_DIRECTORY}/${file} ${PROJECT_NAME}-${release_version}/${file_location})
217 endforeach(file ${source_to_pack})
218
219 add_custom_command(
220   TARGET dist-dir
221   COMMAND ${CMAKE_COMMAND} -E echo "${GIT_VERSION}" > ${PROJECT_NAME}-${release_version}/.gitversion)
222
223 ######################################
224 ### Fill in the "make dist" target ###
225 ######################################
226
227 add_custom_target(dist
228   COMMENT "Removing the distribution directory"
229   DEPENDS ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-${release_version}.tar.gz
230   COMMAND ${CMAKE_COMMAND} -E echo ${PROJECT_NAME}-${release_version} > ${CMAKE_BINARY_DIR}/VERSION
231   COMMAND ${CMAKE_COMMAND} -E remove_directory ${PROJECT_NAME}-${release_version}/)
232
233 add_custom_command(
234   OUTPUT ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-${release_version}.tar.gz
235   COMMENT "Compressing the archive from the distribution directory"
236   COMMAND ${CMAKE_COMMAND} -E tar cf ${PROJECT_NAME}-${release_version}.tar ${PROJECT_NAME}-${release_version}/
237   COMMAND gzip -9v ${PROJECT_NAME}-${release_version}.tar
238   COMMAND ${CMAKE_COMMAND} -E remove_directory ${PROJECT_NAME}-${release_version}/)
239 add_dependencies(dist dist-dir)
240
241 if(NOT enable_maintainer_mode)
242   add_custom_target(echo-dist
243     COMMAND ${CMAKE_COMMAND} -E echo "WARNING: ----------------------------------------------------"
244     COMMAND ${CMAKE_COMMAND} -E echo "WARNING: Distrib is generated without option maintainer mode "
245     COMMAND ${CMAKE_COMMAND} -E echo "WARNING: ----------------------------------------------------")
246   add_dependencies(dist echo-dist)
247 endif()
248
249 ###########################################
250 ### Fill in the "make distcheck" target ###
251 ###########################################
252
253 set(CMAKE_BINARY_TEST_DIR ${CMAKE_BINARY_DIR})
254
255 # Allow to test the "make dist"
256 add_custom_target(distcheck
257   COMMAND ${CMAKE_COMMAND} -E echo "XXX compare archive with git repository"
258   COMMAND ${CMAKE_HOME_DIRECTORY}/tools/internal/check_dist_archive -batch ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}.tar.gz
259
260   COMMAND ${CMAKE_COMMAND} -E echo "XXX remove old copy"
261   COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}
262
263   COMMAND ${CMAKE_COMMAND} -E echo "XXX Untar distrib"
264   COMMAND ${CMAKE_COMMAND} -E tar xf ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}.tar.gz ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}
265
266   COMMAND ${CMAKE_COMMAND} -E echo "XXX create build and install subtrees"
267   COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}/_build
268   COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}/_inst
269
270   COMMAND ${CMAKE_COMMAND} -E echo "XXX Configure"
271   COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}/_build
272           ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}/_inst -Denable_lto=OFF ..
273           
274   COMMAND ${CMAKE_COMMAND} -E echo "XXX Build"
275   COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}/_build ${CMAKE_MAKE_PROGRAM} -j 4
276   
277   COMMAND ${CMAKE_COMMAND} -E echo "XXX Test"
278   COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}/_build ctest --output-on-failure -j 4
279
280   COMMAND ${CMAKE_COMMAND} -E echo "XXX Install"
281   COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}/_build ${CMAKE_MAKE_PROGRAM} install
282   COMMAND ${CMAKE_COMMAND} -E create_symlink
283   ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}/_inst/lib/libsimgrid.so
284   ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}/_inst/lib/libsimgridtest.so
285
286   COMMAND ${CMAKE_COMMAND} -E echo "XXX Install with documentation"
287   COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}/_build ${CMAKE_MAKE_PROGRAM} install
288
289   COMMAND ${CMAKE_COMMAND} -E echo "XXX Remove temp directories"
290   COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_TEST_DIR}/${PROJECT_NAME}-${release_version}
291   )
292 add_dependencies(distcheck dist)
293
294 #######################################
295 ### Fill in the "make check" target ###
296 #######################################
297
298 if(enable_memcheck)
299   add_custom_target(check COMMAND ctest -D ExperimentalMemCheck)
300 else()
301   add_custom_target(check COMMAND make test)
302 endif()
303
304 #######################################
305 ### Fill in the "make xxx-clean" target ###
306 #######################################
307
308 add_custom_target(maintainer-clean
309   COMMAND ${CMAKE_COMMAND} -E remove -f src/config_unit.c
310   COMMAND ${CMAKE_COMMAND} -E remove -f src/cunit_unit.c
311   COMMAND ${CMAKE_COMMAND} -E remove -f src/dict_unit.c
312   COMMAND ${CMAKE_COMMAND} -E remove -f src/dynar_unit.c
313   COMMAND ${CMAKE_COMMAND} -E remove -f src/ex_unit.c
314   COMMAND ${CMAKE_COMMAND} -E remove -f src/set_unit.c
315   COMMAND ${CMAKE_COMMAND} -E remove -f src/simgrid_units_main.c
316   COMMAND ${CMAKE_COMMAND} -E remove -f src/swag_unit.c
317   COMMAND ${CMAKE_COMMAND} -E remove -f src/xbt_str_unit.c
318   COMMAND ${CMAKE_COMMAND} -E remove -f src/xbt_strbuff_unit.c
319   COMMAND ${CMAKE_COMMAND} -E remove -f src/xbt_synchro_unit.c
320   WORKING_DIRECTORY "${CMAKE_HOME_DIRECTORY}")
321
322 include(CPack)