Logo AND Algorithmique Numérique Distribuée

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