Logo AND Algorithmique Numérique Distribuée

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