Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove lua from cmake files.
[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 ###########################################
86 ### Fill in the "make uninstall" target ###
87 ###########################################
88
89 add_custom_target(uninstall
90 COMMAND ${CMAKE_COMMAND} -E     remove_directory ${CMAKE_INSTALL_PREFIX}/doc/simgrid
91 COMMAND ${CMAKE_COMMAND} -E     echo "uninstall doc ok"
92 COMMAND ${CMAKE_COMMAND} -E     remove -f ${CMAKE_INSTALL_PREFIX}/lib/libgras*
93 COMMAND ${CMAKE_COMMAND} -E     remove -f ${CMAKE_INSTALL_PREFIX}/lib/libsimgrid*
94 COMMAND ${CMAKE_COMMAND} -E     remove -f ${CMAKE_INSTALL_PREFIX}/lib/libsmpi*
95 COMMAND ${CMAKE_COMMAND} -E     echo "uninstall lib ok"
96 COMMAND ${CMAKE_COMMAND} -E     remove -f ${CMAKE_INSTALL_PREFIX}/bin/smpicc
97 COMMAND ${CMAKE_COMMAND} -E     remove -f ${CMAKE_INSTALL_PREFIX}/bin/smpif2c
98 COMMAND ${CMAKE_COMMAND} -E     remove -f ${CMAKE_INSTALL_PREFIX}/bin/smpiff
99 COMMAND ${CMAKE_COMMAND} -E     remove -f ${CMAKE_INSTALL_PREFIX}/bin/smpirun
100 COMMAND ${CMAKE_COMMAND} -E     remove -f ${CMAKE_INSTALL_PREFIX}/bin/tesh
101 COMMAND ${CMAKE_COMMAND} -E     remove -f ${CMAKE_INSTALL_PREFIX}/bin/simgrid-colorizer
102 COMMAND ${CMAKE_COMMAND} -E     remove -f ${CMAKE_INSTALL_PREFIX}/bin/simgrid_update_xml
103 COMMAND ${CMAKE_COMMAND} -E     remove -f ${CMAKE_INSTALL_PREFIX}/bin/gras_stub_generator
104 COMMAND ${CMAKE_COMMAND} -E     echo "uninstall bin ok"
105 COMMAND ${CMAKE_COMMAND} -E     remove_directory ${CMAKE_INSTALL_PREFIX}/include/amok
106 COMMAND ${CMAKE_COMMAND} -E     remove_directory ${CMAKE_INSTALL_PREFIX}/include/gras
107 COMMAND ${CMAKE_COMMAND} -E     remove_directory ${CMAKE_INSTALL_PREFIX}/include/instr
108 COMMAND ${CMAKE_COMMAND} -E     remove_directory ${CMAKE_INSTALL_PREFIX}/include/msg 
109 COMMAND ${CMAKE_COMMAND} -E     remove_directory ${CMAKE_INSTALL_PREFIX}/include/simdag
110 COMMAND ${CMAKE_COMMAND} -E     remove_directory ${CMAKE_INSTALL_PREFIX}/include/smpi
111 COMMAND ${CMAKE_COMMAND} -E     remove_directory ${CMAKE_INSTALL_PREFIX}/include/surf
112 COMMAND ${CMAKE_COMMAND} -E     remove_directory ${CMAKE_INSTALL_PREFIX}/include/xbt
113 COMMAND ${CMAKE_COMMAND} -E     remove_directory ${CMAKE_INSTALL_PREFIX}/include/mc
114 COMMAND ${CMAKE_COMMAND} -E     remove -f ${CMAKE_INSTALL_PREFIX}/include/simgrid_config.h
115 COMMAND ${CMAKE_COMMAND} -E     remove -f ${CMAKE_INSTALL_PREFIX}/include/gras.h 
116 COMMAND ${CMAKE_COMMAND} -E     remove -f ${CMAKE_INSTALL_PREFIX}/include/xbt.h
117 COMMAND ${CMAKE_COMMAND} -E     echo "uninstall include ok"
118 WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}"
119 )
120
121 ################################################################
122 ## Build a sain "make dist" target to build a source package ###
123 ##   containing only the files that I explicitely state      ###
124 ##   (instead of any cruft laying on my disk as CPack does)  ###
125 ################################################################
126
127 ##########################################
128 ### Fill in the "make dist-dir" target ###
129 ##########################################
130
131 add_custom_target(dist-dir
132   COMMENT "Generating the distribution directory"
133   COMMAND test -e simgrid-${release_version}/ && chmod -R a+w simgrid-${release_version}/ || true
134   COMMAND ${CMAKE_COMMAND} -E remove_directory simgrid-${release_version}/
135   COMMAND ${CMAKE_COMMAND} -E make_directory simgrid-${release_version}
136   COMMAND ${CMAKE_COMMAND} -E make_directory simgrid-${release_version}/doc/html/
137   COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_HOME_DIRECTORY}/doc/html/ simgrid-${release_version}/doc/html/
138 )
139 add_dependencies(dist-dir simgrid_documentation)
140
141 set(dirs_in_tarball "")
142 foreach(file ${source_to_pack})
143   #message(${file})
144   # This damn prefix is still set somewhere (seems to be in subdirs)
145   string(REPLACE "${CMAKE_HOME_DIRECTORY}/" "" file "${file}")
146   
147   # Create the directory on need
148   get_filename_component(file_location ${file} PATH)
149   string(REGEX MATCH ";${file_location};" OPERATION "${dirs_in_tarball}")
150   if(NOT OPERATION)
151        set(dirs_in_tarball "${dirs_in_tarball};${file_location};")
152        add_custom_command(
153          TARGET dist-dir
154          COMMAND ${CMAKE_COMMAND} -E make_directory simgrid-${release_version}/${file_location}/
155        )       
156    endif(NOT OPERATION)
157    
158    # Actually copy the file
159    add_custom_command(
160      TARGET dist-dir
161      COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_HOME_DIRECTORY}/${file} simgrid-${release_version}/${file_location}/
162    )
163    
164    add_custom_command(
165      TARGET dist-dir
166      COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/Makefile.default simgrid-${release_version}/Makefile
167    )
168 endforeach(file ${source_to_pack})
169
170 ######################################
171 ### Fill in the "make dist" target ###
172 ######################################
173
174 add_custom_target(dist
175   DEPENDS ${CMAKE_BINARY_DIR}/simgrid-${release_version}.tar.gz
176 )
177 add_custom_command(
178         OUTPUT ${CMAKE_BINARY_DIR}/simgrid-${release_version}.tar.gz    
179         COMMENT "Compressing the archive from the distribution directory"
180         COMMAND ${CMAKE_COMMAND} -E tar cf simgrid-${release_version}.tar simgrid-${release_version}/
181         COMMAND gzip -9v simgrid-${release_version}.tar
182         COMMAND ${CMAKE_COMMAND} -E remove_directory simgrid-${release_version}/
183 )
184 add_dependencies(dist dist-dir)
185
186 ###########################################
187 ### Fill in the "make distcheck" target ###
188 ###########################################
189
190 # Allow to test the "make dist"
191 add_custom_target(distcheck
192   COMMAND ${CMAKE_COMMAND} -E echo "XXX remove old copy"
193   COMMAND ${CMAKE_COMMAND} -E remove_directory simgrid-${release_version}.cpy 
194   COMMAND ${CMAKE_COMMAND} -E echo "XXX copy again the source tree"
195   COMMAND ${CMAKE_COMMAND} -E copy_directory simgrid-${release_version}/ simgrid-${release_version}.cpy 
196   COMMAND ${CMAKE_COMMAND} -E echo "XXX create build and install subtrees"
197   COMMAND ${CMAKE_COMMAND} -E make_directory simgrid-${release_version}/_build
198   COMMAND ${CMAKE_COMMAND} -E make_directory simgrid-${release_version}/_inst
199  
200   # This stupid cmake creates a directory in source, killing the purpose of the chmod
201   # (tricking around)
202   COMMAND ${CMAKE_COMMAND} -E echo "XXX change the modes of directories"
203   COMMAND ${CMAKE_COMMAND} -E make_directory simgrid-${release_version}/CMakeFiles 
204   COMMAND chmod -R a-w simgrid-${release_version}/ # FIXME: we should pass without commenting that line
205   COMMAND chmod -R a+w simgrid-${release_version}/_build
206   COMMAND chmod -R a+w simgrid-${release_version}/_inst
207   COMMAND chmod -R a+w simgrid-${release_version}/CMakeFiles
208   
209   COMMAND ${CMAKE_COMMAND} -E echo "XXX Configure"
210   COMMAND ${CMAKE_COMMAND} -E chdir simgrid-${release_version}/_build ${CMAKE_COMMAND} build ..  -DCMAKE_INSTALL_PREFIX=../_inst -Wno-dev -Denable_doc=OFF
211 #  COMMAND ${CMAKE_COMMAND} -E chdir simgrid-${release_version}/_build make dist-dir
212   COMMAND ${CMAKE_COMMAND} -E echo "XXX Build"
213   COMMAND ${CMAKE_COMMAND} -E chdir simgrid-${release_version}/_build make VERBOSE=1
214   
215   # This fails, unfortunately, because GRAS is broken for now
216   COMMAND ${CMAKE_COMMAND} -E chdir simgrid-${release_version}/_build ctest -j5 --output-on-failure
217
218   COMMAND ${CMAKE_COMMAND} -E echo "XXX Check that cleaning works"
219   COMMAND ${CMAKE_COMMAND} -E chdir simgrid-${release_version}/_build make clean
220   COMMAND ${CMAKE_COMMAND} -E echo "XXX Display what is remaining after make clean"
221   COMMAND ${CMAKE_COMMAND} -E chdir simgrid-${release_version}/_build ls -lR
222   COMMAND ${CMAKE_COMMAND} -E echo "XXX Remove _build and _inst directories"
223   COMMAND chmod a+w simgrid-${release_version}/
224   COMMAND ${CMAKE_COMMAND} -E remove_directory simgrid-${release_version}/_build
225   COMMAND ${CMAKE_COMMAND} -E remove_directory simgrid-${release_version}/_inst
226   COMMAND ${CMAKE_COMMAND} -E echo "XXX The output of the diff follows"
227   COMMAND diff -ruN simgrid-${release_version}.cpy simgrid-${release_version}
228   COMMAND ${CMAKE_COMMAND} -E echo "XXX end of the diff, random cleanups now"
229   COMMAND ${CMAKE_COMMAND} -E remove_directory simgrid-${release_version}.cpy 
230   COMMAND ${CMAKE_COMMAND} -E remove_directory simgrid-${release_version}
231 )
232 add_dependencies(distcheck dist-dir)
233
234 #######################################
235 ### Fill in the "make check" target ###
236 #######################################
237
238 if(enable_memcheck)
239         add_custom_target(check
240         COMMAND ctest -D ExperimentalMemCheck
241         )
242 else(enable_memcheck)
243         add_custom_target(check
244         COMMAND make test
245         )
246 endif(enable_memcheck)
247
248 #######################################
249 ### Fill in the "make xxx-clean" target ###
250 #######################################
251
252 add_custom_target(maintainer-clean
253 COMMAND ${CMAKE_COMMAND} -E remove -f src/config_unit.c
254 COMMAND ${CMAKE_COMMAND} -E remove -f src/cunit_unit.c
255 COMMAND ${CMAKE_COMMAND} -E remove -f src/dict_unit.c
256 COMMAND ${CMAKE_COMMAND} -E remove -f src/dynar_unit.c
257 COMMAND ${CMAKE_COMMAND} -E remove -f src/ex_unit.c
258 COMMAND ${CMAKE_COMMAND} -E remove -f src/set_unit.c
259 COMMAND ${CMAKE_COMMAND} -E remove -f src/simgrid_units_main.c
260 COMMAND ${CMAKE_COMMAND} -E remove -f src/swag_unit.c
261 COMMAND ${CMAKE_COMMAND} -E remove -f src/xbt_sha_unit.c
262 COMMAND ${CMAKE_COMMAND} -E remove -f src/xbt_str_unit.c
263 COMMAND ${CMAKE_COMMAND} -E remove -f src/xbt_strbuff_unit.c
264 COMMAND ${CMAKE_COMMAND} -E remove -f src/xbt_synchro_unit.c
265 WORKING_DIRECTORY "${CMAKE_HOME_DIRECTORY}"
266 )
267
268 add_custom_target(supernovae-clean
269 COMMAND ${CMAKE_COMMAND} -E remove -f src/supernovae_gras.c
270 COMMAND ${CMAKE_COMMAND} -E remove -f src/supernovae_sg.c
271 COMMAND ${CMAKE_COMMAND} -E remove -f src/supernovae_smpi.c
272 WORKING_DIRECTORY "${CMAKE_HOME_DIRECTORY}"
273 )
274
275 #############################################
276 ### Fill in the "make sync-gforge" target ###
277 #############################################
278
279 add_custom_target(sync-gforge-doc
280 COMMAND chmod g+rw -R doc/
281 COMMAND chmod a+rX -R doc/
282 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
283 COMMAND scp doc/index.php doc/webcruft/robots.txt scm.gforge.inria.fr:/home/groups/simgrid/htdocs/
284 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/
285 WORKING_DIRECTORY "${CMAKE_HOME_DIRECTORY}"
286 )
287 add_custom_target(sync-gforge-dtd
288 COMMAND scp src/surf/simgrid.dtd scm.gforge.inria.fr:/home/groups/simgrid/htdocs/
289 WORKING_DIRECTORY "${CMAKE_HOME_DIRECTORY}"
290 )
291
292
293 include(CPack)