Logo AND Algorithmique Numérique Distribuée

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