Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Generate tests for memcheck.
[simgrid.git] / buildtools / Cmake / Distrib.cmake
1 set(CMAKE_INSTALL_PREFIX ${prefix} CACHE TYPE INTERNAL FORCE)
2
3 #########################################
4 ### Fill in the "make install" target ###
5 #########################################
6           
7 # doc
8 if(NOT EXISTS ${PROJECT_DIRECTORY}/doc/html/)
9         file(MAKE_DIRECTORY ${PROJECT_DIRECTORY}/doc/html/)
10 endif(NOT EXISTS ${PROJECT_DIRECTORY}/doc/html/)
11         install(DIRECTORY "${PROJECT_DIRECTORY}/doc/html/"
12           DESTINATION "$ENV{DESTDIR}${prefix}/doc/simgrid/html/"
13           PATTERN ".svn" EXCLUDE 
14           PATTERN ".git" EXCLUDE 
15           PATTERN "*.o" EXCLUDE
16           PATTERN "*~" EXCLUDE
17         )
18 # binaries
19 install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/smpicc
20                  ${CMAKE_BINARY_DIR}/bin/smpirun
21                  ${CMAKE_BINARY_DIR}/bin/tesh
22                 DESTINATION $ENV{DESTDIR}${prefix}/bin/)
23         
24 install(PROGRAMS tools/MSG_visualization/colorize.pl
25         DESTINATION $ENV{DESTDIR}${prefix}/bin/
26                 RENAME simgrid-colorizer)
27
28 # libraries
29 install(TARGETS simgrid gras 
30         DESTINATION $ENV{DESTDIR}${prefix}/lib/)
31         
32 install(FILES ${CMAKE_BINARY_DIR}/lib/libsimgrid_static.a 
33         RENAME libsimgrid.a
34         DESTINATION $ENV{DESTDIR}${prefix}/lib/)
35         
36 if(enable_smpi) 
37   install(TARGETS smpi
38           DESTINATION $ENV{DESTDIR}${prefix}/lib/)
39 endif(enable_smpi)      
40
41 # include files
42 foreach(file ${install_HEADERS})
43   get_filename_component(location ${file} PATH)
44   install(FILES ${file}
45           DESTINATION $ENV{DESTDIR}${prefix}/${location})
46 endforeach(file ${install_HEADERS})
47
48 # example files
49 foreach(file ${examples_to_install_in_doc})
50   string(REPLACE "${PROJECT_DIRECTORY}/examples/" "" file ${file})
51   get_filename_component(location ${file} PATH)
52   install(FILES "examples/${file}"
53           DESTINATION $ENV{DESTDIR}${prefix}/doc/simgrid/examples/${location})
54 endforeach(file ${examples_to_install_in_doc})
55
56 # bindings cruft
57 if(HAVE_JAVA)
58   install(FILES ${CMAKE_BINARY_DIR}/simgrid.jar
59           DESTINATION $ENV{DESTDIR}${prefix}/share/)
60 endif(HAVE_JAVA)
61
62 if(HAVE_LUA)
63         file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/lib/lua/5.1")
64         add_custom_target(lua_simgrid ALL
65                 COMMAND ${CMAKE_COMMAND} -E create_symlink ../../libsimgrid.so ${CMAKE_BINARY_DIR}/lib/lua/5.1/simgrid.so
66                 DEPENDS simgrid
67                 )
68         install(FILES ${CMAKE_BINARY_DIR}/lib/lua/5.1/simgrid.so
69                 DESTINATION $ENV{DESTDIR}${prefix}/lib/lua/5.1
70                 )
71 endif(HAVE_LUA)
72
73 if(HAVE_RUBY)
74         string(REGEX REPLACE "^.*ruby/" "" install_link_ruby "${RUBY_ARCH_DIR}")
75         file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/lib/ruby/${install_link_ruby}")
76         add_custom_target(ruby_simgrid ALL
77         COMMAND ${CMAKE_COMMAND} -E create_symlink ../../../libsimgrid.so ${CMAKE_BINARY_DIR}/lib/ruby/${install_link_ruby}/libsimgrid.so
78         DEPENDS simgrid
79         )
80         install(FILES ${CMAKE_BINARY_DIR}/lib/ruby/${install_link_ruby}/libsimgrid.so
81                 DESTINATION $ENV{DESTDIR}${prefix}/lib/ruby/${install_link_ruby}/
82         )
83         install(FILES ${PROJECT_DIRECTORY}/src/bindings/ruby/simgrid.rb
84                 DESTINATION $ENV{DESTDIR}${prefix}/lib/ruby/${install_link_ruby}/)
85
86 endif(HAVE_RUBY)
87
88 ###########################################
89 ### Fill in the "make uninstall" target ###
90 ###########################################
91
92 add_custom_target(uninstall
93 COMMAND ${CMAKE_COMMAND} -E     remove_directory ${prefix}/doc/simgrid
94 COMMAND ${CMAKE_COMMAND} -E     echo "uninstall doc ok"
95 COMMAND ${CMAKE_COMMAND} -E     remove -f ${prefix}/lib/libgras*
96 COMMAND ${CMAKE_COMMAND} -E     remove -f ${prefix}/lib/libsimgrid*
97 COMMAND ${CMAKE_COMMAND} -E     remove -f ${prefix}/lib/libsmpi*
98 COMMAND ${CMAKE_COMMAND} -E     echo "uninstall lib ok"
99 COMMAND ${CMAKE_COMMAND} -E     remove -f ${prefix}/bin/smpicc
100 COMMAND ${CMAKE_COMMAND} -E     remove -f ${prefix}/bin/smpirun
101 COMMAND ${CMAKE_COMMAND} -E     remove -f ${prefix}/bin/tesh
102 COMMAND ${CMAKE_COMMAND} -E     remove -f ${prefix}/bin/simgrid-colorizer
103 COMMAND ${CMAKE_COMMAND} -E     echo "uninstall bin ok"
104 COMMAND ${CMAKE_COMMAND} -E     remove_directory ${prefix}/include/amok
105 COMMAND ${CMAKE_COMMAND} -E     remove_directory ${prefix}/include/gras
106 COMMAND ${CMAKE_COMMAND} -E     remove_directory ${prefix}/include/instr
107 COMMAND ${CMAKE_COMMAND} -E     remove_directory ${prefix}/include/msg 
108 COMMAND ${CMAKE_COMMAND} -E     remove_directory ${prefix}/include/simdag
109 COMMAND ${CMAKE_COMMAND} -E     remove_directory ${prefix}/include/smpi
110 COMMAND ${CMAKE_COMMAND} -E     remove_directory ${prefix}/include/surf
111 COMMAND ${CMAKE_COMMAND} -E     remove_directory ${prefix}/include/xbt
112 COMMAND ${CMAKE_COMMAND} -E     remove_directory ${prefix}/include/mc
113 COMMAND ${CMAKE_COMMAND} -E     remove -f ${prefix}/include/simgrid_config.h
114 COMMAND ${CMAKE_COMMAND} -E     remove -f ${prefix}/include/gras.h 
115 COMMAND ${CMAKE_COMMAND} -E     remove -f ${prefix}/include/xbt.h
116 COMMAND ${CMAKE_COMMAND} -E     echo "uninstal include ok"
117 WORKING_DIRECTORY "${prefix}"
118 )
119
120 if(HAVE_JAVA)
121         add_custom_command(TARGET uninstall
122         COMMAND ${CMAKE_COMMAND} -E     remove -f ${prefix}/share/simgrid.jar
123         COMMAND ${CMAKE_COMMAND} -E echo "uninstall binding java ok"
124         WORKING_DIRECTORY "${PROJECT_DIRECTORY}/"
125         )       
126 endif(HAVE_JAVA)
127
128 if(HAVE_LUA)
129         add_custom_command(TARGET uninstall
130         COMMAND ${CMAKE_COMMAND} -E echo "uninstall binding lua ok"
131         COMMAND ${CMAKE_COMMAND} -E remove -f ${prefix}/lib/lua/5.1/simgrid.so  
132         WORKING_DIRECTORY "${PROJECT_DIRECTORY}/"
133         )
134 endif(HAVE_LUA)
135
136 if(HAVE_RUBY)
137         string(REGEX REPLACE "^.*ruby/" "" install_link_ruby "${RUBY_ARCH_DIR}")
138         add_custom_command(TARGET uninstall
139         COMMAND ${CMAKE_COMMAND} -E echo "uninstall binding ruby ok"
140         COMMAND ${CMAKE_COMMAND} -E remove -f ${prefix}/lib/ruby/${install_link_ruby}/libsimgrid.so
141         COMMAND ${CMAKE_COMMAND} -E remove -f ${prefix}/lib/ruby/${install_link_ruby}/simgrid.rb
142         WORKING_DIRECTORY "${PROJECT_DIRECTORY}/"
143         )
144 endif(HAVE_RUBY)
145
146 ######################################
147 ### Fill in the "make html" target ###
148 ######################################
149
150 add_custom_target(html
151 COMMAND ${CMAKE_COMMAND} -E echo "Make the html doc"
152 COMMAND ${CMAKE_COMMAND} -E echo "cmake -DBIBTEX2HTML=${BIBTEX2HTML} ./"
153 COMMAND ${CMAKE_COMMAND} -DBIBTEX2HTML=${BIBTEX2HTML} ./
154 COMMAND ${CMAKE_COMMAND} -E remove_directory ${PROJECT_DIRECTORY}/buildtools/Cmake/doc/CMakeFiles
155 COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_DIRECTORY}/buildtools/Cmake/doc/CMakeCache.txt
156 COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_DIRECTORY}/buildtools/Cmake/doc/cmake_install.cmake
157 COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_DIRECTORY}/buildtools/Cmake/doc/Makefile
158 WORKING_DIRECTORY "${PROJECT_DIRECTORY}/buildtools/Cmake/doc"
159 )
160
161 ################################################################
162 ## Build a sain "make dist" target to build a source package ###
163 ##   containing only the files that I explicitely state      ###
164 ##   (instead of any cruft laying on my disk as CPack does)  ###
165 ################################################################
166
167 ##########################################
168 ### Fill in the "make dist-dir" target ###
169 ##########################################
170
171 add_custom_target(dist-dir
172   COMMAND test -e simgrid-${release_version}/ && chmod -R a+w simgrid-${release_version}/ || true
173   COMMAND ${CMAKE_COMMAND} -E remove_directory simgrid-${release_version}
174   COMMAND ${CMAKE_COMMAND} -E make_directory simgrid-${release_version}
175 )
176
177 set(dirs_in_tarball "")
178 foreach(file ${source_to_pack} ${txt_files})
179   # This damn prefix is still set somewhere (seems to be in subdirs)
180   string(REPLACE "${PROJECT_DIRECTORY}/" "" file ${file})
181   
182   # Create the directory on need
183   get_filename_component(file_location ${file} PATH)
184   string(REGEX MATCH ";${file_location};" OPERATION "${dirs_in_tarball}")
185   if(NOT OPERATION)
186        set(dirs_in_tarball "${dirs_in_tarball};${file_location};")
187        add_custom_command(
188          TARGET dist-dir
189          COMMAND ${CMAKE_COMMAND} -E make_directory simgrid-${release_version}/${file_location}/
190        )       
191    endif(NOT OPERATION)
192    
193    # Actually copy the file
194    add_custom_command(
195      TARGET dist-dir
196      COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_DIRECTORY}/${file} simgrid-${release_version}/${file_location}/
197    )
198 endforeach(file ${source_to_pack})
199
200 ######################################
201 ### Fill in the "make dist" target ###
202 ######################################
203
204 add_custom_target(dist
205   COMMAND ${CMAKE_COMMAND} -E tar cf simgrid-${release_version}.tar simgrid-${release_version}/
206   COMMAND gzip -9v simgrid-${release_version}.tar
207   COMMAND ${CMAKE_COMMAND} -E remove_directory simgrid-${release_version}
208 )
209 add_dependencies(dist dist-dir)
210
211 ###########################################
212 ### Fill in the "make distcheck" target ###
213 ###########################################
214
215 # Allow to test the "make dist"
216 add_custom_target(distcheck
217   COMMAND ${CMAKE_COMMAND} -E make_directory simgrid-${release_version}/_build
218   COMMAND ${CMAKE_COMMAND} -E make_directory simgrid-${release_version}/_inst
219   
220   # This stupid cmake creates a directory in source, killing the purpose of the chmod
221   # (tricking around)
222   COMMAND ${CMAKE_COMMAND} -E make_directory simgrid-${release_version}/CMakeFiles 
223 #  COMMAND chmod -R a-w simgrid-${release_version}/ # FIXME: we should pass without commenting that line
224   COMMAND chmod -R a+w simgrid-${release_version}/_build
225   COMMAND chmod -R a+w simgrid-${release_version}/_inst
226   COMMAND chmod -R a+w simgrid-${release_version}/CMakeFiles
227   
228   COMMAND ${CMAKE_COMMAND} -E chdir simgrid-${release_version}/_build ${CMAKE_COMMAND} build ..  -Dprefix=../_inst
229 #  COMMAND ${CMAKE_COMMAND} -E chdir simgrid-${release_version}/_build make dist-dir
230   COMMAND ${CMAKE_COMMAND} -E chdir simgrid-${release_version}/_build make 
231   COMMAND ${CMAKE_COMMAND} -E chdir simgrid-${release_version}/_build ctest -j5 --output-on-failure
232   COMMAND ${CMAKE_COMMAND} -E chdir simgrid-${release_version}/_build make clean
233 #  COMMAND ${CMAKE_COMMAND} -E remove_directory simgrid-${release_version}/
234 )
235 add_dependencies(distcheck dist-dir)
236
237 #######################################
238 ### Fill in the "make check" target ###
239 #######################################
240
241 if(enable_memcheck)
242         add_custom_target(check
243         COMMAND ctest -D ExperimentalMemCheck
244         )
245 else(enable_memcheck)
246         add_custom_target(check
247         COMMAND make test
248         )
249 endif(enable_memcheck)
250
251 #######################################
252 ### Fill in the "make all-clean" target ###
253 #######################################
254
255 add_custom_target(maintainer-clean
256 COMMAND ${CMAKE_COMMAND} -E remove -f src/config_unit.c
257 COMMAND ${CMAKE_COMMAND} -E remove -f src/cunit_unit.c
258 COMMAND ${CMAKE_COMMAND} -E remove -f src/dict_unit.c
259 COMMAND ${CMAKE_COMMAND} -E remove -f src/dynar_unit.c
260 COMMAND ${CMAKE_COMMAND} -E remove -f src/ex_unit.c
261 COMMAND ${CMAKE_COMMAND} -E remove -f src/set_unit.c
262 COMMAND ${CMAKE_COMMAND} -E remove -f src/simgrid_units_main.c
263 COMMAND ${CMAKE_COMMAND} -E remove -f src/swag_unit.c
264 COMMAND ${CMAKE_COMMAND} -E remove -f src/xbt_sha_unit.c
265 COMMAND ${CMAKE_COMMAND} -E remove -f src/xbt_str_unit.c
266 COMMAND ${CMAKE_COMMAND} -E remove -f src/xbt_strbuff_unit.c
267 COMMAND ${CMAKE_COMMAND} -E remove -f src/xbt_synchro_unit.c
268 WORKING_DIRECTORY "${PROJECT_DIRECTORY}"
269 )
270
271 add_custom_target(supernovae-clean
272 COMMAND ${CMAKE_COMMAND} -E remove -f src/supernovae_gras.c
273 COMMAND ${CMAKE_COMMAND} -E remove -f src/supernovae_sg.c
274 COMMAND ${CMAKE_COMMAND} -E remove -f src/supernovae_smpi.c
275 WORKING_DIRECTORY "${PROJECT_DIRECTORY}"
276 )
277
278 add_custom_target(doc-clean
279 COMMAND ${CMAKE_COMMAND} -E remove -f doc/all_bib.html
280 COMMAND ${CMAKE_COMMAND} -E remove -f doc/all_bib.latin1.html
281 COMMAND ${CMAKE_COMMAND} -E remove -f doc/all_bib.latin1.html.tmp
282 COMMAND ${CMAKE_COMMAND} -E remove -f doc/logcategories.sh
283 COMMAND ${CMAKE_COMMAND} -E remove -f doc/publis_core.bib
284 COMMAND ${CMAKE_COMMAND} -E remove -f doc/publis_core_bib.html
285 COMMAND ${CMAKE_COMMAND} -E remove -f doc/publis_core_bib.latin1.html
286 COMMAND ${CMAKE_COMMAND} -E remove -f doc/publis_core_bib.latin1.html.tmp
287 COMMAND ${CMAKE_COMMAND} -E remove -f doc/publis_count.html
288 COMMAND ${CMAKE_COMMAND} -E remove -f doc/publis_extern.bib
289 COMMAND ${CMAKE_COMMAND} -E remove -f doc/publis_extern_bib.html
290 COMMAND ${CMAKE_COMMAND} -E remove -f doc/publis_extern_bib.latin1.html
291 COMMAND ${CMAKE_COMMAND} -E remove -f doc/publis_extern_bib.latin1.html.tmp
292 COMMAND ${CMAKE_COMMAND} -E remove -f doc/publis_intra.bib
293 COMMAND ${CMAKE_COMMAND} -E remove -f doc/publis_intra_bib.html
294 COMMAND ${CMAKE_COMMAND} -E remove -f doc/publis_intra_bib.latin1.html
295 COMMAND ${CMAKE_COMMAND} -E remove -f doc/publis_intra_bib.latin1.html.tmp
296 COMMAND ${CMAKE_COMMAND} -E remove -f doc/tmp.realtoc
297 COMMAND ${CMAKE_COMMAND} -E remove -f doc/using_bib.html
298 COMMAND ${CMAKE_COMMAND} -E remove -f doc/using_bib.latin1.html
299 COMMAND ${CMAKE_COMMAND} -E remove -f doc/using_bib.latin1.html.tmp
300 COMMAND ${CMAKE_COMMAND} -E remove -f doc/realtoc.sh
301 WORKING_DIRECTORY "${PROJECT_DIRECTORY}"
302 )
303
304 add_custom_target(java-clean
305 COMMAND ${CMAKE_COMMAND} -E remove -f src/simgrid.jar
306 COMMAND ${CMAKE_COMMAND} -E remove_directory src/.classes
307 COMMAND ${CMAKE_COMMAND} -E remove -f examples/java/basic/BasicTest.class
308 COMMAND ${CMAKE_COMMAND} -E remove -f examples/java/basic/FinalizeTask.class
309 COMMAND ${CMAKE_COMMAND} -E remove -f examples/java/basic/Forwarder.class
310 COMMAND ${CMAKE_COMMAND} -E remove -f examples/java/basic/Master.class
311 COMMAND ${CMAKE_COMMAND} -E remove -f examples/java/basic/Slave.class
312 COMMAND ${CMAKE_COMMAND} -E remove -f examples/java/comm_time/CommTimeTest.class
313 COMMAND ${CMAKE_COMMAND} -E remove -f examples/java/comm_time/FinalizeTask.class
314 COMMAND ${CMAKE_COMMAND} -E remove -f examples/java/comm_time/Master.class
315 COMMAND ${CMAKE_COMMAND} -E remove -f examples/java/comm_time/Slave.class
316 COMMAND ${CMAKE_COMMAND} -E remove -f examples/java/ping_pong/PingPongTask.class
317 COMMAND ${CMAKE_COMMAND} -E remove -f examples/java/ping_pong/PingPongTest.class
318 COMMAND ${CMAKE_COMMAND} -E remove -f examples/java/ping_pong/Receiver.class
319 COMMAND ${CMAKE_COMMAND} -E remove -f examples/java/ping_pong/Sender.class
320 COMMAND ${CMAKE_COMMAND} -E remove -f examples/java/suspend/DreamMaster.class
321 COMMAND ${CMAKE_COMMAND} -E remove -f examples/java/suspend/LazyGuy.class
322 COMMAND ${CMAKE_COMMAND} -E remove -f examples/java/suspend/SuspendTest.class
323 WORKING_DIRECTORY "${PROJECT_DIRECTORY}"
324 )
325
326 add_custom_target(all-clean
327 COMMAND make clean
328 COMMAND make java-clean
329 COMMAND make doc-clean
330 COMMAND make supernovae-clean
331 )
332 if(enable_maintainer_mode)
333         add_custom_command(TARGET all-clean
334         COMMAND make maintainer-clean
335         )
336 endif(enable_maintainer_mode)
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)