Logo AND Algorithmique Numérique Distribuée

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