Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Definitively remove old variable PROJECT_DIRECTORY for CMAKE_HOME_DIRECTORY.
[simgrid.git] / buildtools / Cmake / Distrib.cmake
1 #########################################
2 ### Fill in the "make install" target ###
3 #########################################
4           
5 # doc
6 if(NOT EXISTS ${CMAKE_HOME_DIRECTORY}/doc/html/)
7         file(MAKE_DIRECTORY ${CMAKE_HOME_DIRECTORY}/doc/html/)
8 endif(NOT EXISTS ${CMAKE_HOME_DIRECTORY}/doc/html/)
9 install(DIRECTORY "${CMAKE_HOME_DIRECTORY}/doc/html/"
10   DESTINATION "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/doc/simgrid/html/"
11   PATTERN ".svn" EXCLUDE 
12   PATTERN ".git" EXCLUDE 
13   PATTERN "*.o" EXCLUDE
14   PATTERN "*~" EXCLUDE
15 )
16
17 # binaries
18 install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/smpicc
19                  ${CMAKE_BINARY_DIR}/bin/smpif2c
20                  ${CMAKE_BINARY_DIR}/bin/smpiff
21                  ${CMAKE_BINARY_DIR}/bin/smpirun
22                 DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/)
23 if(WIN32)
24         install(PROGRAMS ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/tesh.pl
25         DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/
26         RENAME tesh)
27         add_custom_target(tesh
28         COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/tesh.pl ${CMAKE_BINARY_DIR}/bin/tesh
29         )
30 else(WIN32)
31         install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/tesh
32         DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/)
33 endif(WIN32)  
34         
35 install(PROGRAMS ${CMAKE_HOME_DIRECTORY}/tools/MSG_visualization/colorize.pl
36         DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/
37                 RENAME simgrid-colorizer)
38                 
39 add_custom_target(simgrid-colorizer ALL
40 COMMENT "Install ${CMAKE_BINARY_DIR}/bin/colorize"
41 COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_HOME_DIRECTORY}/tools/MSG_visualization/colorize.pl ${CMAKE_BINARY_DIR}/bin/colorize
42 )
43                                 
44 install(PROGRAMS ${CMAKE_HOME_DIRECTORY}/tools/simgrid_update_xml.pl
45                 DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/
46                 RENAME simgrid_update_xml)
47                 
48 add_custom_target(simgrid_update_xml ALL
49 COMMENT "Install ${CMAKE_BINARY_DIR}/bin/simgrid_update_xml"
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 "${CMAKE_HOME_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 "${CMAKE_HOME_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 ${CMAKE_HOME_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 "uninstall 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 "${CMAKE_HOME_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 "${CMAKE_HOME_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 "${CMAKE_HOME_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 ${CMAKE_HOME_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 "${CMAKE_HOME_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 ${CMAKE_HOME_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 "${CMAKE_HOME_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 "${CMAKE_HOME_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 "${CMAKE_HOME_DIRECTORY}"
367 )
368
369 include(CPack)