Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
3b2e74a05f5896fc8cd7942f2196d9d9a1814f2a
[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 add_custom_target(check
242 COMMAND make test
243 #WORKING_DIRECTORY "${PROJECT_DIRECTORY}"
244 )
245
246 #######################################
247 ### Fill in the "make all-clean" target ###
248 #######################################
249
250 add_custom_target(maintainer-clean
251 COMMAND ${CMAKE_COMMAND} -E remove -f src/config_unit.c
252 COMMAND ${CMAKE_COMMAND} -E remove -f src/cunit_unit.c
253 COMMAND ${CMAKE_COMMAND} -E remove -f src/dict_unit.c
254 COMMAND ${CMAKE_COMMAND} -E remove -f src/dynar_unit.c
255 COMMAND ${CMAKE_COMMAND} -E remove -f src/ex_unit.c
256 COMMAND ${CMAKE_COMMAND} -E remove -f src/set_unit.c
257 COMMAND ${CMAKE_COMMAND} -E remove -f src/simgrid_units_main.c
258 COMMAND ${CMAKE_COMMAND} -E remove -f src/swag_unit.c
259 COMMAND ${CMAKE_COMMAND} -E remove -f src/xbt_sha_unit.c
260 COMMAND ${CMAKE_COMMAND} -E remove -f src/xbt_str_unit.c
261 COMMAND ${CMAKE_COMMAND} -E remove -f src/xbt_strbuff_unit.c
262 COMMAND ${CMAKE_COMMAND} -E remove -f src/xbt_synchro_unit.c
263 WORKING_DIRECTORY "${PROJECT_DIRECTORY}"
264 )
265
266 add_custom_target(supernovae-clean
267 COMMAND ${CMAKE_COMMAND} -E remove -f src/supernovae_gras.c
268 COMMAND ${CMAKE_COMMAND} -E remove -f src/supernovae_sg.c
269 COMMAND ${CMAKE_COMMAND} -E remove -f src/supernovae_smpi.c
270 WORKING_DIRECTORY "${PROJECT_DIRECTORY}"
271 )
272
273 add_custom_target(doc-clean
274 COMMAND ${CMAKE_COMMAND} -E remove -f doc/all_bib.html
275 COMMAND ${CMAKE_COMMAND} -E remove -f doc/all_bib.latin1.html
276 COMMAND ${CMAKE_COMMAND} -E remove -f doc/all_bib.latin1.html.tmp
277 COMMAND ${CMAKE_COMMAND} -E remove -f doc/logcategories.sh
278 COMMAND ${CMAKE_COMMAND} -E remove -f doc/publis_core.bib
279 COMMAND ${CMAKE_COMMAND} -E remove -f doc/publis_core_bib.html
280 COMMAND ${CMAKE_COMMAND} -E remove -f doc/publis_core_bib.latin1.html
281 COMMAND ${CMAKE_COMMAND} -E remove -f doc/publis_core_bib.latin1.html.tmp
282 COMMAND ${CMAKE_COMMAND} -E remove -f doc/publis_count.html
283 COMMAND ${CMAKE_COMMAND} -E remove -f doc/publis_extern.bib
284 COMMAND ${CMAKE_COMMAND} -E remove -f doc/publis_extern_bib.html
285 COMMAND ${CMAKE_COMMAND} -E remove -f doc/publis_extern_bib.latin1.html
286 COMMAND ${CMAKE_COMMAND} -E remove -f doc/publis_extern_bib.latin1.html.tmp
287 COMMAND ${CMAKE_COMMAND} -E remove -f doc/publis_intra.bib
288 COMMAND ${CMAKE_COMMAND} -E remove -f doc/publis_intra_bib.html
289 COMMAND ${CMAKE_COMMAND} -E remove -f doc/publis_intra_bib.latin1.html
290 COMMAND ${CMAKE_COMMAND} -E remove -f doc/publis_intra_bib.latin1.html.tmp
291 COMMAND ${CMAKE_COMMAND} -E remove -f doc/tmp.realtoc
292 COMMAND ${CMAKE_COMMAND} -E remove -f doc/using_bib.html
293 COMMAND ${CMAKE_COMMAND} -E remove -f doc/using_bib.latin1.html
294 COMMAND ${CMAKE_COMMAND} -E remove -f doc/using_bib.latin1.html.tmp
295 COMMAND ${CMAKE_COMMAND} -E remove -f doc/realtoc.sh
296 WORKING_DIRECTORY "${PROJECT_DIRECTORY}"
297 )
298
299 add_custom_target(java-clean
300 COMMAND ${CMAKE_COMMAND} -E remove -f src/simgrid.jar
301 COMMAND ${CMAKE_COMMAND} -E remove_directory src/.classes
302 COMMAND ${CMAKE_COMMAND} -E remove -f examples/java/basic/BasicTest.class
303 COMMAND ${CMAKE_COMMAND} -E remove -f examples/java/basic/FinalizeTask.class
304 COMMAND ${CMAKE_COMMAND} -E remove -f examples/java/basic/Forwarder.class
305 COMMAND ${CMAKE_COMMAND} -E remove -f examples/java/basic/Master.class
306 COMMAND ${CMAKE_COMMAND} -E remove -f examples/java/basic/Slave.class
307 COMMAND ${CMAKE_COMMAND} -E remove -f examples/java/comm_time/CommTimeTest.class
308 COMMAND ${CMAKE_COMMAND} -E remove -f examples/java/comm_time/FinalizeTask.class
309 COMMAND ${CMAKE_COMMAND} -E remove -f examples/java/comm_time/Master.class
310 COMMAND ${CMAKE_COMMAND} -E remove -f examples/java/comm_time/Slave.class
311 COMMAND ${CMAKE_COMMAND} -E remove -f examples/java/ping_pong/PingPongTask.class
312 COMMAND ${CMAKE_COMMAND} -E remove -f examples/java/ping_pong/PingPongTest.class
313 COMMAND ${CMAKE_COMMAND} -E remove -f examples/java/ping_pong/Receiver.class
314 COMMAND ${CMAKE_COMMAND} -E remove -f examples/java/ping_pong/Sender.class
315 COMMAND ${CMAKE_COMMAND} -E remove -f examples/java/suspend/DreamMaster.class
316 COMMAND ${CMAKE_COMMAND} -E remove -f examples/java/suspend/LazyGuy.class
317 COMMAND ${CMAKE_COMMAND} -E remove -f examples/java/suspend/SuspendTest.class
318 WORKING_DIRECTORY "${PROJECT_DIRECTORY}"
319 )
320
321 add_custom_target(all-clean
322 COMMAND make clean
323 COMMAND make java-clean
324 COMMAND make doc-clean
325 COMMAND make supernovae-clean
326 )
327 if(enable_maintainer_mode)
328         add_custom_command(TARGET all-clean
329         COMMAND make maintainer-clean
330         )
331 endif(enable_maintainer_mode)
332
333 #############################################
334 ### Fill in the "make sync-gforge" target ###
335 #############################################
336
337 add_custom_target(sync-gforge
338 COMMAND chmod g+rw -R doc/
339 COMMAND chmod a+rX -R doc/
340 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
341 COMMAND scp doc/index.php doc/webcruft/robots.txt scm.gforge.inria.fr:/home/groups/simgrid/htdocs/
342 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/
343 WORKING_DIRECTORY "${PROJECT_DIRECTORY}"
344 )
345
346 include(CPack)