Logo AND Algorithmique Numérique Distribuée

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