Logo AND Algorithmique Numérique Distribuée

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