Logo AND Algorithmique Numérique Distribuée

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