Logo AND Algorithmique Numérique Distribuée

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