Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Change way for cleaning generated files.
[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                 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 )
214
215 set(dirs_in_tarball "")
216 foreach(file ${source_to_pack})
217   # This damn prefix is still set somewhere (seems to be in subdirs)
218   string(REPLACE "${PROJECT_DIRECTORY}/" "" file "${file}")
219   
220   # Create the directory on need
221   get_filename_component(file_location ${file} PATH)
222   string(REGEX MATCH ";${file_location};" OPERATION "${dirs_in_tarball}")
223   if(NOT OPERATION)
224        set(dirs_in_tarball "${dirs_in_tarball};${file_location};")
225        add_custom_command(
226          TARGET dist-dir
227          COMMAND ${CMAKE_COMMAND} -E make_directory simgrid-${release_version}/${file_location}/
228        )       
229    endif(NOT OPERATION)
230    
231    # Actually copy the file
232    add_custom_command(
233      TARGET dist-dir
234      COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_DIRECTORY}/${file} simgrid-${release_version}/${file_location}/
235    )
236 endforeach(file ${source_to_pack})
237
238 ######################################
239 ### Fill in the "make dist" target ###
240 ######################################
241
242 add_custom_target(dist
243   COMMAND ${CMAKE_COMMAND} -E tar cf simgrid-${release_version}.tar simgrid-${release_version}/
244   COMMAND gzip -9v simgrid-${release_version}.tar
245   COMMAND ${CMAKE_COMMAND} -E remove_directory simgrid-${release_version}
246 )
247 add_dependencies(dist dist-dir)
248
249 ###########################################
250 ### Fill in the "make distcheck" target ###
251 ###########################################
252
253 # Allow to test the "make dist"
254 add_custom_target(distcheck
255   COMMAND ${CMAKE_COMMAND} -E remove_directory simgrid-${release_version}.cpy 
256   COMMAND ${CMAKE_COMMAND} -E copy_directory simgrid-${release_version}/ simgrid-${release_version}.cpy 
257   COMMAND ${CMAKE_COMMAND} -E make_directory simgrid-${release_version}/_build
258   COMMAND ${CMAKE_COMMAND} -E make_directory simgrid-${release_version}/_inst
259  
260   # This stupid cmake creates a directory in source, killing the purpose of the chmod
261   # (tricking around)
262   COMMAND ${CMAKE_COMMAND} -E make_directory simgrid-${release_version}/CMakeFiles 
263 #  COMMAND chmod -R a-w simgrid-${release_version}/ # FIXME: we should pass without commenting that line
264   COMMAND chmod -R a+w simgrid-${release_version}/_build
265   COMMAND chmod -R a+w simgrid-${release_version}/_inst
266   COMMAND chmod -R a+w simgrid-${release_version}/CMakeFiles
267   
268   COMMAND ${CMAKE_COMMAND} -E chdir simgrid-${release_version}/_build ${CMAKE_COMMAND} build ..  -Dprefix=../_inst
269 #  COMMAND ${CMAKE_COMMAND} -E chdir simgrid-${release_version}/_build make dist-dir
270   COMMAND ${CMAKE_COMMAND} -E chdir simgrid-${release_version}/_build make
271   
272   # This fails, unfortunately, because GRAS is broken for now
273 #  COMMAND ${CMAKE_COMMAND} -E chdir simgrid-${release_version}/_build ctest -j5 --output-on-failure
274
275   COMMAND ${CMAKE_COMMAND} -E echo "XXX Check that cleaning works"
276   COMMAND ${CMAKE_COMMAND} -E chdir simgrid-${release_version}/_build make clean
277   COMMAND ${CMAKE_COMMAND} -E remove_directory simgrid-${release_version}/_build
278   COMMAND ${CMAKE_COMMAND} -E remove_directory simgrid-${release_version}/_inst
279   COMMAND diff -ruN simgrid-${release_version}.cpy simgrid-${release_version}
280   COMMAND ${CMAKE_COMMAND} -E remove_directory simgrid-${release_version}.cpy 
281   COMMAND ${CMAKE_COMMAND} -E remove_directory simgrid-${release_version}/
282 )
283 add_dependencies(distcheck dist-dir)
284
285 #######################################
286 ### Fill in the "make check" target ###
287 #######################################
288
289 if(enable_memcheck)
290         add_custom_target(check
291         COMMAND ctest -D ExperimentalMemCheck
292         )
293 else(enable_memcheck)
294         add_custom_target(check
295         COMMAND make test
296         )
297 endif(enable_memcheck)
298
299 #######################################
300 ### Fill in the "make xxx-clean" target ###
301 #######################################
302
303 add_custom_target(maintainer-clean
304 COMMAND ${CMAKE_COMMAND} -E remove -f src/config_unit.c
305 COMMAND ${CMAKE_COMMAND} -E remove -f src/cunit_unit.c
306 COMMAND ${CMAKE_COMMAND} -E remove -f src/dict_unit.c
307 COMMAND ${CMAKE_COMMAND} -E remove -f src/dynar_unit.c
308 COMMAND ${CMAKE_COMMAND} -E remove -f src/ex_unit.c
309 COMMAND ${CMAKE_COMMAND} -E remove -f src/set_unit.c
310 COMMAND ${CMAKE_COMMAND} -E remove -f src/simgrid_units_main.c
311 COMMAND ${CMAKE_COMMAND} -E remove -f src/swag_unit.c
312 COMMAND ${CMAKE_COMMAND} -E remove -f src/xbt_sha_unit.c
313 COMMAND ${CMAKE_COMMAND} -E remove -f src/xbt_str_unit.c
314 COMMAND ${CMAKE_COMMAND} -E remove -f src/xbt_strbuff_unit.c
315 COMMAND ${CMAKE_COMMAND} -E remove -f src/xbt_synchro_unit.c
316 WORKING_DIRECTORY "${PROJECT_DIRECTORY}"
317 )
318
319 add_custom_target(supernovae-clean
320 COMMAND ${CMAKE_COMMAND} -E remove -f src/supernovae_gras.c
321 COMMAND ${CMAKE_COMMAND} -E remove -f src/supernovae_sg.c
322 COMMAND ${CMAKE_COMMAND} -E remove -f src/supernovae_smpi.c
323 WORKING_DIRECTORY "${PROJECT_DIRECTORY}"
324 )
325
326 #############################################
327 ### Fill in the "make sync-gforge" target ###
328 #############################################
329
330 add_custom_target(sync-gforge
331 COMMAND chmod g+rw -R doc/
332 COMMAND chmod a+rX -R doc/
333 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
334 COMMAND scp doc/index.php doc/webcruft/robots.txt scm.gforge.inria.fr:/home/groups/simgrid/htdocs/
335 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/
336 WORKING_DIRECTORY "${PROJECT_DIRECTORY}"
337 )
338
339 include(CPack)