Logo AND Algorithmique Numérique Distribuée

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