Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
definitely fix doc generation, and inclusion of documentation in dist archives
[simgrid.git] / buildtools / Cmake / Distrib.cmake
1 #########################################
2 ### Fill in the "make install" target ###
3 #########################################
4           
5 # doc
6 if(enable_doc)
7         if(NOT EXISTS ${PROJECT_DIRECTORY}/doc/html/)
8                 file(MAKE_DIRECTORY ${PROJECT_DIRECTORY}/doc/html/)
9         endif(NOT EXISTS ${PROJECT_DIRECTORY}/doc/html/)
10                 install(DIRECTORY "${PROJECT_DIRECTORY}/doc/html/"
11                   DESTINATION "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/doc/simgrid/html/"
12                   PATTERN ".svn" EXCLUDE 
13                   PATTERN ".git" EXCLUDE 
14                   PATTERN "*.o" EXCLUDE
15                   PATTERN "*~" EXCLUDE
16                 )
17 endif(enable_doc)
18
19 # binaries
20 install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/smpicc
21                  ${CMAKE_BINARY_DIR}/bin/smpif2c
22                  ${CMAKE_BINARY_DIR}/bin/smpiff
23                  ${CMAKE_BINARY_DIR}/bin/smpirun
24                 DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/)
25 if(WIN32)
26         install(PROGRAMS ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/tesh.pl
27         DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/
28         RENAME tesh)
29         add_custom_target(tesh
30         COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/tesh.pl ${CMAKE_BINARY_DIR}/bin/tesh
31         )
32 else(WIN32)
33         install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/tesh
34         DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/)
35 endif(WIN32)  
36         
37 install(PROGRAMS ${CMAKE_HOME_DIRECTORY}/tools/MSG_visualization/colorize.pl
38         DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/
39                 RENAME simgrid-colorizer)
40                 
41 add_custom_target(simgrid-colorizer ALL
42 COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_HOME_DIRECTORY}/tools/MSG_visualization/colorize.pl ${CMAKE_BINARY_DIR}/bin/colorize
43 )
44                                 
45 install(PROGRAMS ${CMAKE_HOME_DIRECTORY}/tools/simgrid_update_xml.pl
46                 DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/
47                 RENAME simgrid_update_xml)
48                 
49 add_custom_target(simgrid_update_xml ALL
50 COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_HOME_DIRECTORY}/tools/simgrid_update_xml.pl ${CMAKE_BINARY_DIR}/bin/simgrid_update_xml
51 )
52                 
53 install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/gras_stub_generator
54                 DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/)
55
56 # libraries
57 install(TARGETS simgrid gras 
58         DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/)
59         
60 if(enable_smpi) 
61   install(TARGETS smpi
62           DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/)
63 endif(enable_smpi)
64
65 if(enable_lib_static AND NOT WIN32)
66         install(TARGETS simgrid_static 
67                 DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/)
68         if(enable_smpi) 
69                 install(TARGETS smpi_static
70                         DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/)
71         endif(enable_smpi)
72 endif(enable_lib_static AND NOT WIN32)
73
74 # include files
75 foreach(file ${install_HEADERS})
76   get_filename_component(location ${file} PATH)
77   string(REPLACE "${CMAKE_CURRENT_BINARY_DIR}/" "" location "${location}")
78   install(FILES ${file}
79           DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${location})
80 endforeach(file ${install_HEADERS})
81
82 # example files
83 foreach(file ${examples_to_install_in_doc})
84   string(REPLACE "${PROJECT_DIRECTORY}/examples/" "" file ${file})
85   get_filename_component(location ${file} PATH)
86   install(FILES "examples/${file}"
87           DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/doc/simgrid/examples/${location})
88 endforeach(file ${examples_to_install_in_doc})
89
90 # example README
91 foreach(file ${README_examples_files})
92   string(REPLACE "${PROJECT_DIRECTORY}/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 ${README_examples_files})
97
98 # bindings cruft
99 if(HAVE_JAVA)
100   install(FILES ${CMAKE_BINARY_DIR}/simgrid.jar
101           DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/share/)
102 endif(HAVE_JAVA)
103
104 if(HAVE_LUA)
105         file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/lib/lua/5.1")
106         add_custom_target(simgrid_lua ALL
107                 DEPENDS simgrid 
108                                 ${CMAKE_BINARY_DIR}/lib/lua/5.1/simgrid.${LIB_EXE}
109                 )
110         add_custom_command(
111                 OUTPUT ${CMAKE_BINARY_DIR}/lib/lua/5.1/simgrid.${LIB_EXE}
112                 COMMAND ${CMAKE_COMMAND} -E create_symlink ../../libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/lib/lua/5.1/simgrid.${LIB_EXE}
113         )
114         install(FILES ${CMAKE_BINARY_DIR}/lib/lua/5.1/simgrid.${LIB_EXE}
115                 DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/lua/5.1
116                 )
117 endif(HAVE_LUA)
118
119 if(HAVE_RUBY)
120         string(REGEX REPLACE "^.*ruby/" "" install_link_ruby "${RUBY_ARCH_DIR}")
121         file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/lib/ruby/${install_link_ruby}")
122         add_custom_target(ruby_simgrid ALL
123                 DEPENDS simgrid
124                                 ${CMAKE_BINARY_DIR}/lib/ruby/${install_link_ruby}/libsimgrid.${LIB_EXE}
125         )
126         add_custom_command(
127                 OUTPUT ${CMAKE_BINARY_DIR}/lib/ruby/${install_link_ruby}/libsimgrid.${LIB_EXE}
128                 COMMAND ${CMAKE_COMMAND} -E create_symlink ../../../libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/lib/ruby/${install_link_ruby}/libsimgrid.${LIB_EXE}
129         )
130         install(FILES ${CMAKE_BINARY_DIR}/lib/ruby/${install_link_ruby}/libsimgrid.${LIB_EXE}
131                 DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/ruby/${install_link_ruby}/
132         )
133         install(FILES ${PROJECT_DIRECTORY}/src/bindings/ruby/simgrid.rb
134                 DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/ruby/${install_link_ruby}/)
135
136 endif(HAVE_RUBY)
137
138 ###########################################
139 ### Fill in the "make uninstall" target ###
140 ###########################################
141
142 add_custom_target(uninstall
143 COMMAND ${CMAKE_COMMAND} -E     remove_directory ${CMAKE_INSTALL_PREFIX}/doc/simgrid
144 COMMAND ${CMAKE_COMMAND} -E     echo "uninstall doc ok"
145 COMMAND ${CMAKE_COMMAND} -E     remove -f ${CMAKE_INSTALL_PREFIX}/lib/libgras*
146 COMMAND ${CMAKE_COMMAND} -E     remove -f ${CMAKE_INSTALL_PREFIX}/lib/libsimgrid*
147 COMMAND ${CMAKE_COMMAND} -E     remove -f ${CMAKE_INSTALL_PREFIX}/lib/libsmpi*
148 COMMAND ${CMAKE_COMMAND} -E     echo "uninstall lib ok"
149 COMMAND ${CMAKE_COMMAND} -E     remove -f ${CMAKE_INSTALL_PREFIX}/bin/smpicc
150 COMMAND ${CMAKE_COMMAND} -E     remove -f ${CMAKE_INSTALL_PREFIX}/bin/smpif2c
151 COMMAND ${CMAKE_COMMAND} -E     remove -f ${CMAKE_INSTALL_PREFIX}/bin/smpiff
152 COMMAND ${CMAKE_COMMAND} -E     remove -f ${CMAKE_INSTALL_PREFIX}/bin/smpirun
153 COMMAND ${CMAKE_COMMAND} -E     remove -f ${CMAKE_INSTALL_PREFIX}/bin/tesh
154 COMMAND ${CMAKE_COMMAND} -E     remove -f ${CMAKE_INSTALL_PREFIX}/bin/simgrid-colorizer
155 COMMAND ${CMAKE_COMMAND} -E     remove -f ${CMAKE_INSTALL_PREFIX}/bin/simgrid_update_xml
156 COMMAND ${CMAKE_COMMAND} -E     remove -f ${CMAKE_INSTALL_PREFIX}/bin/gras_stub_generator
157 COMMAND ${CMAKE_COMMAND} -E     echo "uninstall bin ok"
158 COMMAND ${CMAKE_COMMAND} -E     remove_directory ${CMAKE_INSTALL_PREFIX}/include/amok
159 COMMAND ${CMAKE_COMMAND} -E     remove_directory ${CMAKE_INSTALL_PREFIX}/include/gras
160 COMMAND ${CMAKE_COMMAND} -E     remove_directory ${CMAKE_INSTALL_PREFIX}/include/instr
161 COMMAND ${CMAKE_COMMAND} -E     remove_directory ${CMAKE_INSTALL_PREFIX}/include/msg 
162 COMMAND ${CMAKE_COMMAND} -E     remove_directory ${CMAKE_INSTALL_PREFIX}/include/simdag
163 COMMAND ${CMAKE_COMMAND} -E     remove_directory ${CMAKE_INSTALL_PREFIX}/include/smpi
164 COMMAND ${CMAKE_COMMAND} -E     remove_directory ${CMAKE_INSTALL_PREFIX}/include/surf
165 COMMAND ${CMAKE_COMMAND} -E     remove_directory ${CMAKE_INSTALL_PREFIX}/include/xbt
166 COMMAND ${CMAKE_COMMAND} -E     remove_directory ${CMAKE_INSTALL_PREFIX}/include/mc
167 COMMAND ${CMAKE_COMMAND} -E     remove -f ${CMAKE_INSTALL_PREFIX}/include/simgrid_config.h
168 COMMAND ${CMAKE_COMMAND} -E     remove -f ${CMAKE_INSTALL_PREFIX}/include/gras.h 
169 COMMAND ${CMAKE_COMMAND} -E     remove -f ${CMAKE_INSTALL_PREFIX}/include/xbt.h
170 COMMAND ${CMAKE_COMMAND} -E     echo "uninstal include ok"
171 WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}"
172 )
173
174 if(HAVE_JAVA)
175         add_custom_command(TARGET uninstall
176         COMMAND ${CMAKE_COMMAND} -E     remove -f ${CMAKE_INSTALL_PREFIX}/share/simgrid.jar
177         COMMAND ${CMAKE_COMMAND} -E echo "uninstall binding java ok"
178         WORKING_DIRECTORY "${PROJECT_DIRECTORY}/"
179         )       
180 endif(HAVE_JAVA)
181
182 if(HAVE_LUA)
183         add_custom_command(TARGET uninstall
184         COMMAND ${CMAKE_COMMAND} -E echo "uninstall binding lua ok"
185         COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_INSTALL_PREFIX}/lib/lua/5.1/simgrid.${LIB_EXE}
186         WORKING_DIRECTORY "${PROJECT_DIRECTORY}/"
187         )
188 endif(HAVE_LUA)
189
190 if(HAVE_RUBY)
191         string(REGEX REPLACE "^.*ruby/" "" install_link_ruby "${RUBY_ARCH_DIR}")
192         add_custom_command(TARGET uninstall
193         COMMAND ${CMAKE_COMMAND} -E echo "uninstall binding ruby ok"
194         COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_INSTALL_PREFIX}/lib/ruby/${install_link_ruby}/libsimgrid.${LIB_EXE}
195         COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_INSTALL_PREFIX}/lib/ruby/${install_link_ruby}/simgrid.rb
196         WORKING_DIRECTORY "${PROJECT_DIRECTORY}/"
197         )
198 endif(HAVE_RUBY)
199
200 ################################################################
201 ## Build a sain "make dist" target to build a source package ###
202 ##   containing only the files that I explicitely state      ###
203 ##   (instead of any cruft laying on my disk as CPack does)  ###
204 ################################################################
205
206 ##########################################
207 ### Fill in the "make dist-dir" target ###
208 ##########################################
209
210 if(enable_doc)
211 add_custom_target(dist-dir
212   COMMENT "Generating the distribution directory"
213   COMMAND test -e simgrid-${release_version}/ && chmod -R a+w simgrid-${release_version}/ || true
214   COMMAND ${CMAKE_COMMAND} -E remove_directory simgrid-${release_version}/
215   COMMAND ${CMAKE_COMMAND} -E make_directory simgrid-${release_version}
216   COMMAND ${CMAKE_COMMAND} -E make_directory simgrid-${release_version}/doc/html/
217   COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_DIRECTORY}/doc/html/ simgrid-${release_version}/doc/html/
218 )
219 add_dependencies(dist-dir simgrid_documentation)
220 else(enable_doc)
221 add_custom_target(dist-dir
222         COMMAND ${CMAKE_COMMAND} -E echo "Please enable the doc to generate the doc"
223         COMMAND I_said_PLEASE_ENABLE_THE_DOC_GENERATION_BEFORE_BUILDING_AN_ARCHIVE
224 )
225 endif(enable_doc)
226
227 set(dirs_in_tarball "")
228 foreach(file ${source_to_pack})
229   #message(${file})
230   # This damn prefix is still set somewhere (seems to be in subdirs)
231   string(REPLACE "${PROJECT_DIRECTORY}/" "" file "${file}")
232   
233   # Create the directory on need
234   get_filename_component(file_location ${file} PATH)
235   string(REGEX MATCH ";${file_location};" OPERATION "${dirs_in_tarball}")
236   if(NOT OPERATION)
237        set(dirs_in_tarball "${dirs_in_tarball};${file_location};")
238        add_custom_command(
239          TARGET dist-dir
240          COMMAND ${CMAKE_COMMAND} -E make_directory simgrid-${release_version}/${file_location}/
241        )       
242    endif(NOT OPERATION)
243    
244    # Actually copy the file
245    add_custom_command(
246      TARGET dist-dir
247      COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_DIRECTORY}/${file} simgrid-${release_version}/${file_location}/
248    )
249 endforeach(file ${source_to_pack})
250
251 ######################################
252 ### Fill in the "make dist" target ###
253 ######################################
254
255 add_custom_target(dist
256   DEPENDS ${CMAKE_BINARY_DIR}/simgrid-${release_version}.tar.gz
257 )
258 add_custom_command(
259         OUTPUT ${CMAKE_BINARY_DIR}/simgrid-${release_version}.tar.gz    
260         COMMENT "Compressing the archive from the distribution directory"
261         COMMAND ${CMAKE_COMMAND} -E tar cf simgrid-${release_version}.tar simgrid-${release_version}/
262         COMMAND gzip -9v simgrid-${release_version}.tar
263         COMMAND ${CMAKE_COMMAND} -E remove_directory simgrid-${release_version}/
264 )
265 add_dependencies(dist dist-dir)
266
267 ###########################################
268 ### Fill in the "make distcheck" target ###
269 ###########################################
270
271 # Allow to test the "make dist"
272 add_custom_target(distcheck
273   COMMAND ${CMAKE_COMMAND} -E echo "XXX remove old copy"
274   COMMAND ${CMAKE_COMMAND} -E remove_directory simgrid-${release_version}.cpy 
275   COMMAND ${CMAKE_COMMAND} -E echo "XXX copy again the source tree"
276   COMMAND ${CMAKE_COMMAND} -E copy_directory simgrid-${release_version}/ simgrid-${release_version}.cpy 
277   COMMAND ${CMAKE_COMMAND} -E echo "XXX create build and install subtrees"
278   COMMAND ${CMAKE_COMMAND} -E make_directory simgrid-${release_version}/_build
279   COMMAND ${CMAKE_COMMAND} -E make_directory simgrid-${release_version}/_inst
280  
281   # This stupid cmake creates a directory in source, killing the purpose of the chmod
282   # (tricking around)
283   COMMAND ${CMAKE_COMMAND} -E echo "XXX change the modes of directories"
284   COMMAND ${CMAKE_COMMAND} -E make_directory simgrid-${release_version}/CMakeFiles 
285   COMMAND chmod -R a-w simgrid-${release_version}/ # FIXME: we should pass without commenting that line
286   COMMAND chmod -R a+w simgrid-${release_version}/_build
287   COMMAND chmod -R a+w simgrid-${release_version}/_inst
288   COMMAND chmod -R a+w simgrid-${release_version}/CMakeFiles
289   
290   COMMAND ${CMAKE_COMMAND} -E echo "XXX Configure"
291   COMMAND ${CMAKE_COMMAND} -E chdir simgrid-${release_version}/_build ${CMAKE_COMMAND} build ..  -DCMAKE_INSTALL_PREFIX=../_inst -Wno-dev -Denable_doc=OFF
292 #  COMMAND ${CMAKE_COMMAND} -E chdir simgrid-${release_version}/_build make dist-dir
293   COMMAND ${CMAKE_COMMAND} -E echo "XXX Build"
294   COMMAND ${CMAKE_COMMAND} -E chdir simgrid-${release_version}/_build make VERBOSE=1
295   
296   # This fails, unfortunately, because GRAS is broken for now
297   COMMAND ${CMAKE_COMMAND} -E chdir simgrid-${release_version}/_build ctest -j5 --output-on-failure
298
299   COMMAND ${CMAKE_COMMAND} -E echo "XXX Check that cleaning works"
300   COMMAND ${CMAKE_COMMAND} -E chdir simgrid-${release_version}/_build make clean
301   COMMAND ${CMAKE_COMMAND} -E echo "XXX Display what is remaining after make clean"
302   COMMAND ${CMAKE_COMMAND} -E chdir simgrid-${release_version}/_build ls -lR
303   COMMAND ${CMAKE_COMMAND} -E echo "XXX Remove _build and _inst directories"
304   COMMAND chmod a+w simgrid-${release_version}/
305   COMMAND ${CMAKE_COMMAND} -E remove_directory simgrid-${release_version}/_build
306   COMMAND ${CMAKE_COMMAND} -E remove_directory simgrid-${release_version}/_inst
307   COMMAND ${CMAKE_COMMAND} -E echo "XXX The output of the diff follows"
308   COMMAND diff -ruN simgrid-${release_version}.cpy simgrid-${release_version}
309   COMMAND ${CMAKE_COMMAND} -E echo "XXX end of the diff, random cleanups now"
310   COMMAND ${CMAKE_COMMAND} -E remove_directory simgrid-${release_version}.cpy 
311   COMMAND ${CMAKE_COMMAND} -E remove_directory simgrid-${release_version}
312 )
313 add_dependencies(distcheck dist-dir)
314
315 #######################################
316 ### Fill in the "make check" target ###
317 #######################################
318
319 if(enable_memcheck)
320         add_custom_target(check
321         COMMAND ctest -D ExperimentalMemCheck
322         )
323 else(enable_memcheck)
324         add_custom_target(check
325         COMMAND make test
326         )
327 endif(enable_memcheck)
328
329 #######################################
330 ### Fill in the "make xxx-clean" target ###
331 #######################################
332
333 add_custom_target(maintainer-clean
334 COMMAND ${CMAKE_COMMAND} -E remove -f src/config_unit.c
335 COMMAND ${CMAKE_COMMAND} -E remove -f src/cunit_unit.c
336 COMMAND ${CMAKE_COMMAND} -E remove -f src/dict_unit.c
337 COMMAND ${CMAKE_COMMAND} -E remove -f src/dynar_unit.c
338 COMMAND ${CMAKE_COMMAND} -E remove -f src/ex_unit.c
339 COMMAND ${CMAKE_COMMAND} -E remove -f src/set_unit.c
340 COMMAND ${CMAKE_COMMAND} -E remove -f src/simgrid_units_main.c
341 COMMAND ${CMAKE_COMMAND} -E remove -f src/swag_unit.c
342 COMMAND ${CMAKE_COMMAND} -E remove -f src/xbt_sha_unit.c
343 COMMAND ${CMAKE_COMMAND} -E remove -f src/xbt_str_unit.c
344 COMMAND ${CMAKE_COMMAND} -E remove -f src/xbt_strbuff_unit.c
345 COMMAND ${CMAKE_COMMAND} -E remove -f src/xbt_synchro_unit.c
346 WORKING_DIRECTORY "${PROJECT_DIRECTORY}"
347 )
348
349 add_custom_target(supernovae-clean
350 COMMAND ${CMAKE_COMMAND} -E remove -f src/supernovae_gras.c
351 COMMAND ${CMAKE_COMMAND} -E remove -f src/supernovae_sg.c
352 COMMAND ${CMAKE_COMMAND} -E remove -f src/supernovae_smpi.c
353 WORKING_DIRECTORY "${PROJECT_DIRECTORY}"
354 )
355
356 #############################################
357 ### Fill in the "make sync-gforge" target ###
358 #############################################
359
360 add_custom_target(sync-gforge
361 COMMAND chmod g+rw -R doc/
362 COMMAND chmod a+rX -R doc/
363 COMMAND rsync --verbose --cvs-exclude --compress --delete --delete-excluded --rsh=ssh --ignore-times --recursive --links --perms --times --omit-dir-times doc/html/ scm.gforge.inria.fr:/home/groups/simgrid/htdocs/doc/ || true
364 COMMAND scp doc/index.php doc/webcruft/robots.txt scm.gforge.inria.fr:/home/groups/simgrid/htdocs/
365 COMMAND scp doc/html/simgrid_modules2.png doc/html/simgrid_modules.png doc/webcruft/simgrid_logo.png doc/webcruft/simgrid_logo_small.png scm.gforge.inria.fr:/home/groups/simgrid/htdocs/
366 WORKING_DIRECTORY "${PROJECT_DIRECTORY}"
367 )
368
369 include(CPack)