Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
7c442cee167ec4f903beb3e47ba4f37fbbd038ab
[simgrid.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.8)
2 project(SimGrid-Java C)
3 set(UPDATE_TYPE svn)
4 set(CMAKE_C_FLAGS "" CACHE TYPE INTERNAL FORCE)
5 set(CMAKE_EXE_LINKER_FLAGS "" CACHE TYPE INTERNAL FORCE)
6 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_HOME_DIRECTORY}/lib")
7 set(soversion 1)
8
9 set(SIMGRID_JAVA_VERSION_MAJOR "1")
10 set(SIMGRID_JAVA_VERSION_MINOR "2")
11 set(SIMGRID_JAVA_VERSION_PATCH "0")
12 set(DIST_NAME ${PROJECT_NAME}-${SIMGRID_JAVA_VERSION_MAJOR}.${SIMGRID_JAVA_VERSION_MINOR})
13
14 ########
15 ## GCC #
16 ########
17 exec_program("${CMAKE_C_COMPILER} --version" OUTPUT_VARIABLE "COMPILER_C_VERSION")
18 string(REGEX MATCH "[0-9].[0-9].[0-9]" COMPILER_C_VERSION "${COMPILER_C_VERSION}")
19 string(REGEX MATCH "^[0-9].[0-9]" COMPILER_C_VERSION_MAJOR_MINOR "${COMPILER_C_VERSION}")
20 string(REPLACE "${COMPILER_C_VERSION_MAJOR_MINOR}." "" COMPILER_C_VERSION_PATCH "${COMPILER_C_VERSION}")
21
22 ########
23 ## GIT #
24 ########
25 if(EXISTS ${CMAKE_HOME_DIRECTORY}/.git/ AND NOT WIN32)
26 exec_program("git remote | head -n 1" OUTPUT_VARIABLE remote RETURN_VALUE ret)
27 exec_program("git config --get remote.${remote}.url" OUTPUT_VARIABLE url RETURN_VALUE ret)
28
29 if(url)
30         exec_program("git --git-dir=${CMAKE_HOME_DIRECTORY}/.git log --oneline -1" OUTPUT_VARIABLE "GIT_VERSION")
31         message(STATUS "Git version: ${GIT_VERSION}")
32         exec_program("git --git-dir=${CMAKE_HOME_DIRECTORY}/.git log -n 1 --format=%ai ." OUTPUT_VARIABLE "GIT_DATE")
33         message(STATUS "Git date: ${GIT_DATE}")
34         string(REGEX REPLACE " .*" "" GIT_VERSION "${GIT_VERSION}")
35         STRING(REPLACE " +0000" "" GIT_DATE ${GIT_DATE})
36         STRING(REPLACE " " "~" GIT_DATE ${GIT_DATE})
37         STRING(REPLACE ":" "-" GIT_DATE ${GIT_DATE})
38 endif(url)
39 endif(EXISTS ${CMAKE_HOME_DIRECTORY}/.git/ AND NOT WIN32)
40
41 #########
42 # CDASH #
43 #########
44 SET(DROP_METHOD "http")
45 SET(DROP_SITE "cdash.inria.fr/CDash")
46 SET(DROP_LOCATION "/submit.php?project=simgrid")
47 SET(DROP_SITE_CDASH TRUE)
48 SET(TRIGGER_SITE "http://cdash.inria.fr/CDash/cgi-bin/Submit-Random-TestingResults.cgi")
49 SET(BUILDNAME "SimGrid-Java" CACHE TYPE INTERNAL FORCE)
50 set(osname ${CMAKE_SYSTEM_NAME})
51 set(cpu ${CMAKE_SYSTEM_PROCESSOR})
52 set(DISTRIB2 ${CMAKE_SYSTEM_VERSION})
53 SET(SITE "${osname}_${DISTRIB2}_${cpu}")
54 SET(CTEST_SITE "${osname}_${DISTRIB2}_${cpu}")
55 SET(CTEST_PROJECT_NAME "${PROJECT_NAME}")
56 SET(CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE "3000000")
57 SET(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE "3000000")
58 set(PIPOL_IMAGE $ENV{PIPOL_IMAGE})
59 if(NOT ${PIPOL_IMAGE} MATCHES "\n")
60 set(SITE ${PIPOL_IMAGE})
61 endif(NOT ${PIPOL_IMAGE} MATCHES "\n")
62 message(STATUS "SITE        : ${SITE}")
63 message(STATUS "BUILDNAME   : ${BUILDNAME}")
64
65 ###############################
66 # Test the build dependencies #
67 ###############################
68 include(FindSimGrid.cmake)
69 include(FindJavaSG.cmake)
70
71 ###############################
72 # Declare our package content #
73 ###############################
74 set(JMSG_C_SRC
75         src/smx_context_java.h
76         src/smx_context_java.c
77         src/jxbt_utilities.c
78         src/jxbt_utilities.h
79         src/jmsg.c 
80         src/jmsg.h
81         src/jmsg_comm.c
82         src/jmsg_comm.h
83         src/jmsg_host.c
84         src/jmsg_host.h
85         src/jmsg_process.c
86         src/jmsg_process.h
87         src/jmsg_task.c
88         src/jmsg_task.h
89         src/jmsg_synchro.c
90         src/jmsg_synchro.h
91         src/jtrace.c
92         src/jtrace.h
93         src/jmsg_rngstream.c
94         src/jmsg_rngstream.h
95 )
96
97 set(JMSG_JAVA_SRC
98         org/simgrid/msg/Host.java
99         org/simgrid/msg/HostFailureException.java       
100         org/simgrid/msg/HostNotFoundException.java      
101         org/simgrid/msg/JniException.java
102         org/simgrid/msg/Msg.java
103         org/simgrid/msg/MsgException.java
104         org/simgrid/msg/NativeException.java
105         org/simgrid/msg/Process.java
106         org/simgrid/msg/ProcessKilledError.java
107         org/simgrid/msg/ProcessNotFoundException.java
108         org/simgrid/msg/Task.java
109         org/simgrid/msg/TaskCancelledException.java
110         org/simgrid/msg/TimeoutException.java
111         org/simgrid/msg/TransferFailureException.java   
112         org/simgrid/msg/Mutex.java
113         org/simgrid/msg/Comm.java
114         org/simgrid/trace/Trace.java
115         org/simgrid/msg/RngStream.java
116 )
117
118 set(JAVA_EXAMPLES
119   examples/bittorrent/Bittorrent.java
120   examples/bittorrent/Common.java
121   examples/bittorrent/Connection.java
122   examples/bittorrent/MessageTask.java
123   examples/bittorrent/Peer.java
124   examples/bittorrent/Tracker.java
125   examples/bittorrent/TrackerTask.java
126   examples/chord/Chord.java
127   examples/chord/Common.java
128   examples/chord/Node.java
129   examples/chord/ChordTask.java
130         examples/chord/FindSuccessorAnswerTask.java
131         examples/chord/FindSuccessorTask.java
132         examples/chord/GetPredecessorAnswerTask.java
133         examples/chord/NotifyTask.java
134         examples/mutualExclusion/centralized/MutexCentral.java
135         examples/mutualExclusion/centralized/GrantTask.java
136         examples/mutualExclusion/centralized/Coordinator.java
137         examples/mutualExclusion/centralized/ReleaseTask.java
138         examples/mutualExclusion/centralized/Node.java
139         examples/mutualExclusion/centralized/RequestTask.java
140         examples/basic/FinalizeTask.java
141         examples/basic/Forwarder.java
142         examples/basic/Master.java
143         examples/basic/BasicTest.java
144         examples/basic/Slave.java
145         examples/commTime/FinalizeTask.java
146         examples/commTime/Master.java
147         examples/commTime/Slave.java
148         examples/commTime/CommTimeTest.java
149         examples/pingPong/PingPongTask.java
150         examples/pingPong/Sender.java
151         examples/pingPong/Receiver.java
152         examples/pingPong/PingPongTest.java
153         examples/master_slave_bypass/Master.java
154         examples/master_slave_bypass/MsBypass.java
155         examples/master_slave_bypass/Slave.java
156         examples/master_slave_bypass/FinalizeTask.java
157         examples/master_slave_kill/Master.java
158         examples/master_slave_kill/MsKill.java
159         examples/master_slave_kill/Slave.java
160         examples/master_slave_kill/FinalizeTask.java
161         examples/async/AsyncTest.java
162         examples/async/FinalizeTask.java  
163         examples/async/Forwarder.java
164         examples/async/Master.java  
165         examples/async/Slave.java
166         examples/startKillTime/Slave.java
167         examples/startKillTime/Master.java
168         examples/startKillTime/StartKillTime.java
169         examples/tracing/PingPongTask.java
170         examples/tracing/Sender.java
171         examples/tracing/Receiver.java
172         examples/tracing/TracingTest.java
173 )
174
175 set(CMAKE_SRC
176 ${CMAKE_HOME_DIRECTORY}/ChangeLog
177 ${CMAKE_HOME_DIRECTORY}/CMakeLists.txt
178 ${CMAKE_HOME_DIRECTORY}/FindJavaSG.cmake
179 ${CMAKE_HOME_DIRECTORY}/FindSimGrid.cmake
180 )
181
182 set(XML_FILES
183     examples/commTime/commTimeDeployment.xml
184     examples/mutualExclusion/ring3.xml
185     examples/mutualExclusion/centralized/mutex_centralized_deployment.xml
186     examples/platform.xml
187     examples/pingPong/pingPongDeployment.xml
188     examples/basic/basicDeployment.xml
189     examples/basic/deploy.xml
190     examples/master_slave_bypass/platform.xml
191     examples/master_slave_kill/platform.xml
192     examples/async/asyncDeployment.xml
193     examples/tracing/tracingPingPongDeployment.xml
194     examples/bittorrent/bittorrent.xml
195 )
196
197 set(source_to_pack
198 ${CMAKE_SRC}
199 ${JMSG_C_SRC}
200 ${JMSG_JAVA_SRC}
201 ${JAVA_EXAMPLES}
202 ${XML_FILES}
203 )
204
205 string(REPLACE "org/" "${CMAKE_HOME_DIRECTORY}/org/" JAVA_FILES "${JMSG_JAVA_SRC}") 
206 string(REPLACE "org/" "${CMAKE_HOME_DIRECTORY}/classes/org/" JMSG_JAVA_SRC_CLASS "${JMSG_JAVA_SRC}")
207 string(REPLACE ".java" ".class" JMSG_JAVA_SRC_CLASS "${JMSG_JAVA_SRC_CLASS}")
208 string(REPLACE "examples/" "${CMAKE_HOME_DIRECTORY}/examples/" JAVA_EXAMPLES_CLASS "${JAVA_EXAMPLES}") 
209 string(REPLACE ".java" ".class" JAVA_EXAMPLES_CLASS "${JAVA_EXAMPLES_CLASS}")
210
211 #########
212 # FLAGS #
213 #########
214 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g -Wall -Wunused -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wchar-subscripts -Wcomment -Wformat -Wwrite-strings -Wno-unused-function -Wno-unused-parameter -Wno-strict-aliasing -Wno-format-nonliteral -Werror ")
215 set(INCLUDE_PATH "-I${CMAKE_HOME_DIRECTORY}/src -I${SIMGRID_INCLUDES} ")
216 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${INCLUDE_PATH}")
217
218 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=int-to-pointer-cast -Wno-error=pointer-to-int-cast")
219 if(COMPILER_C_VERSION_MAJOR_MINOR MATCHES "4.6")
220     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=unused-but-set-variable")
221 endif(COMPILER_C_VERSION_MAJOR_MINOR MATCHES "4.6")
222
223 ###########
224 # TARGETS #
225 ###########
226 # SG_java
227 add_library(SG_java SHARED ${JMSG_C_SRC})
228 if(WIN32)
229     set_target_properties(SG_java PROPERTIES LINK_FLAGS "-Wl,--subsystem,windows,--kill-at ${SIMGRID_LIB}" PREFIX "")
230     find_path(PEXPORTS_PATH NAMES pexports.exe PATHS NO_DEFAULT_PATHS)
231     message(STATUS "pexports: ${PEXPORTS_PATH}")
232     if(PEXPORTS_PATH)
233     add_custom_command(TARGET SG_java POST_BUILD
234     COMMAND ${PEXPORTS_PATH}/pexports.exe ${CMAKE_BINARY_DIR}/SG_java.dll > ${CMAKE_BINARY_DIR}/SG_java.def)
235     endif(PEXPORTS_PATH)
236 else(WIN32)
237     target_link_libraries(SG_java pcre pthread simgrid)
238     set_target_properties(SG_java PROPERTIES LINK_FLAGS "-L${SIMGRID_LIB_PATH}")
239 endif(WIN32)
240
241 # SG_java_tracing
242 add_library(SG_java_tracing SHARED ${JMSG_C_SRC})
243 if(WIN32)
244     set_target_properties(SG_java_tracing PROPERTIES LINK_FLAGS "-Wl,--subsystem,windows,--kill-at ${SIMGRID_LIB}" PREFIX "")
245     find_path(PEXPORTS_PATH NAMES pexports.exe PATHS NO_DEFAULT_PATHS)
246     message(STATUS "pexports: ${PEXPORTS_PATH}")
247     if(PEXPORTS_PATH)
248     add_custom_command(TARGET SG_java_tracing POST_BUILD
249     COMMAND ${PEXPORTS_PATH}/pexports.exe ${CMAKE_BINARY_DIR}/SG_java_tracing.dll > ${CMAKE_BINARY_DIR}/SG_java_tracing.def)
250     endif(PEXPORTS_PATH)
251 else(WIN32)
252     target_link_libraries(SG_java_tracing pcre pthread simgrid)
253     set_target_properties(SG_java_tracing PROPERTIES LINK_FLAGS "-L${SIMGRID_LIB_PATH}")
254 endif(WIN32)
255
256
257 # java_classes
258 add_custom_command(
259         OUTPUT  ${JMSG_JAVA_SRC_CLASS}
260         DEPENDS ${JMSG_JAVA_SRC}
261         COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_HOME_DIRECTORY}/classes/"
262         COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/classes/
263                                         -cp ${CMAKE_HOME_DIRECTORY}/classes/ ${JAVA_FILES}
264         COMMENT "Compiling java sources of core library..."                                     
265 )
266 add_custom_target(java_classes ALL
267   DEPENDS ${JMSG_JAVA_SRC_CLASS}
268 )
269
270 # simgrid_jar
271 add_custom_target(simgrid_jar ALL
272   COMMAND ${JAVA_ARCHIVE} -cvf ${CMAKE_HOME_DIRECTORY}/simgrid.jar .
273   COMMENT "Building simgrid.jar..."
274   WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/classes 
275 )
276
277 # simgrid_java_examples
278 add_custom_command(
279         COMMENT "Build examples for java"
280         OUTPUT  ${JAVA_EXAMPLES_CLASS}
281         DEPENDS ${JAVA_EXAMPLES}
282         COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/basic/*.java  
283         COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/async/*.java
284         COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/chord/*.java
285         COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/commTime/*.java
286           COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/master_slave_bypass/*.java
287           COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/master_slave_kill/*.java
288         COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/centralized/*.java                                 
289         COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/pingPong/*.java
290         COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/startKillTime/*.java
291         COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/tracing/*.java
292         COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/bittorrent/*.java
293 )
294
295 add_custom_target(simgrid_java_examples ALL
296         DEPENDS ${JAVA_EXAMPLES_CLASS}
297 )
298
299 ########################
300 # Declare dependencies #
301 ########################
302 add_dependencies(simgrid_jar java_classes)
303 add_dependencies(simgrid_java_examples simgrid_jar SG_java_tracing SG_java)
304
305 SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES
306 ${CMAKE_HOME_DIRECTORY}/simgrid.jar
307 )
308
309 #####################
310 # Declare our tests #
311 #####################
312 INCLUDE(CTest)
313 ENABLE_TESTING()
314
315 ADD_TEST(async           ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/async/async.tesh)
316 ADD_TEST(basic           ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/basic/basic.tesh)
317 ADD_TEST(bittorrent           ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/bittorrent/bittorrent.tesh)
318 ADD_TEST(chord           ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/chord/chord.tesh)
319 ADD_TEST(pingPong        ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/pingPong/pingpong.tesh)
320 ADD_TEST(CommTime        ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/commTime/commtime.tesh)
321 ADD_TEST(mutualExclusion ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/mutualexclusion.tesh)
322 ADD_TEST(bypass          ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/master_slave_bypass/bypass.tesh)
323 ADD_TEST(kill            ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/master_slave_kill/kill.tesh)
324 ADD_TEST(startKillTime   ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/startKillTime/startKillTime.tesh)
325 ADD_TEST(tracing         ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/tracing/tracingPingPong.tesh)
326 #Don't forget to put new test in this list!!!
327 set(test_list basic bittorrent chord async pingPong CommTime mutualExclusion bypass kill startKillTime tracing)
328
329 ##########################################
330 # Set the  DYLD_LIBRARY_PATH for mac     #
331 ##########################################
332 if(APPLE)
333     if($ENV{DYLD_LIBRARY_PATH})
334         set_tests_properties(${test_list}
335         PROPERTIES ENVIRONMENT "DYLD_LIBRARY_PATH=${CMAKE_HOME_DIRECTORY}/lib:${SIMGRID_LIB_PATH}")
336     else($ENV{DYLD_LIBRARY_PATH})
337         set_tests_properties(${test_list}
338         PROPERTIES ENVIRONMENT "DYLD_LIBRARY_PATH=$ENV{DYLD_LIBRARY_PATH}:${CMAKE_HOME_DIRECTORY}/lib:${SIMGRID_LIB_PATH}")
339     endif($ENV{DYLD_LIBRARY_PATH})
340 else(APPLE)
341     ##########################################
342     # Set the  LD_LIBRARY_PATH for our tests #
343     ##########################################
344     if(NOT WIN32)
345         if($ENV{LD_LIBRARY_PATH})
346             set_tests_properties(${test_list}
347             PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_HOME_DIRECTORY}/lib:${SIMGRID_LIB_PATH}")
348         else($ENV{LD_LIBRARY_PATH})
349             set_tests_properties(${test_list}
350             PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}:${CMAKE_HOME_DIRECTORY}/lib:${SIMGRID_LIB_PATH}")
351         endif($ENV{LD_LIBRARY_PATH})
352     endif(NOT WIN32)
353 endif(APPLE)
354
355 ###########
356 # Install #
357 ###########
358 install(TARGETS SG_java SG_java_tracing
359         DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/java/)
360 install(FILES ${CMAKE_HOME_DIRECTORY}/simgrid.jar
361         DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/java/)
362
363
364 #########
365 # Dist  #
366 #########
367
368 add_custom_target(dist-dir
369   COMMENT "Generating the distribution directory"
370   COMMAND test -e ${DIST_NAME}/ && chmod -R a+w ${DIST_NAME}/ || true
371   COMMAND ${CMAKE_COMMAND} -E remove_directory ${DIST_NAME}/
372   COMMAND ${CMAKE_COMMAND} -E make_directory ${DIST_NAME}
373 )
374
375 set(dirs_in_tarball "")
376 foreach(file ${source_to_pack})
377
378   # This damn prefix is still set somewhere (seems to be in subdirs)
379   string(REPLACE "${CMAKE_HOME_DIRECTORY}/" "" file "${file}")
380   
381   # Create the directory on need
382   get_filename_component(file_location ${file} PATH)
383   string(REGEX MATCH ";${file_location};" OPERATION "${dirs_in_tarball}")
384   if(NOT OPERATION)
385        set(dirs_in_tarball "${dirs_in_tarball};${file_location};")
386        add_custom_command(
387          TARGET dist-dir
388          COMMAND ${CMAKE_COMMAND} -E make_directory ${DIST_NAME}/${file_location}/
389        )       
390    endif(NOT OPERATION)
391    
392    # Actually copy the file
393    add_custom_command(
394      TARGET dist-dir
395      COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_HOME_DIRECTORY}/${file} ${DIST_NAME}/${file_location}/
396    )
397 endforeach(file ${source_to_pack})
398
399 add_custom_target(dist
400   DEPENDS ${CMAKE_BINARY_DIR}/${DIST_NAME}.tar.gz
401   COMMENT "Generated ${DIST_NAME}"
402 )
403 add_custom_command(
404         OUTPUT ${CMAKE_BINARY_DIR}/${DIST_NAME}.tar.gz  
405         COMMENT "Compressing the archive from the distribution directory"
406         COMMAND ${CMAKE_COMMAND} -E tar cf ${DIST_NAME}.tar ${DIST_NAME}/
407         COMMAND gzip -9v ${DIST_NAME}.tar
408         COMMAND ${CMAKE_COMMAND} -E remove_directory ${DIST_NAME}/
409 )
410 add_dependencies(dist dist-dir)
411
412 ########
413 # NOTE #
414 ########
415 file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/Testing/Notes/)
416 file(WRITE ${CMAKE_BINARY_DIR}/Testing/Notes/Build  "GIT version : ${GIT_VERSION}\n")
417 file(APPEND ${CMAKE_BINARY_DIR}/Testing/Notes/Build "Release     : ${DIST_NAME}\n")
418 file(APPEND ${CMAKE_BINARY_DIR}/Testing/Notes/Build "Pipol user  : $ENV{PIPOL_USER}\n")
419 file(APPEND ${CMAKE_BINARY_DIR}/Testing/Notes/Build "Pipol image : $ENV{PIPOL_IMAGE}\n")
420
421 #######
422 # DOC #
423 #######
424 set(WARNING "This file is generated, don't edit it!")
425 set(srcdir ${CMAKE_HOME_DIRECTORY})
426 include(GenerateDoc.cmake)