Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
2faa006ecb4f6ab3efc4c1e8528836c104cf5955
[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 "3")
10 set(SIMGRID_JAVA_VERSION_MINOR "7")
11 set(SIMGRID_JAVA_VERSION_PATCH "1")
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   ${CMAKE_HOME_DIRECTORY}/src/smx_context_java.h
76   ${CMAKE_HOME_DIRECTORY}/src/smx_context_java.c
77   ${CMAKE_HOME_DIRECTORY}/src/jxbt_utilities.c
78   ${CMAKE_HOME_DIRECTORY}/src/jxbt_utilities.h
79   ${CMAKE_HOME_DIRECTORY}/src/jmsg.c 
80   ${CMAKE_HOME_DIRECTORY}/src/jmsg.h
81   ${CMAKE_HOME_DIRECTORY}/src/jmsg_comm.c
82   ${CMAKE_HOME_DIRECTORY}/src/jmsg_comm.h
83   ${CMAKE_HOME_DIRECTORY}/src/jmsg_host.c
84   ${CMAKE_HOME_DIRECTORY}/src/jmsg_host.h
85   ${CMAKE_HOME_DIRECTORY}/src/jmsg_process.c
86   ${CMAKE_HOME_DIRECTORY}/src/jmsg_process.h
87   ${CMAKE_HOME_DIRECTORY}/src/jmsg_task.c
88   ${CMAKE_HOME_DIRECTORY}/src/jmsg_task.h
89   ${CMAKE_HOME_DIRECTORY}/src/jmsg_synchro.c
90   ${CMAKE_HOME_DIRECTORY}/src/jmsg_synchro.h
91   ${CMAKE_HOME_DIRECTORY}/src/jmsg_rngstream.c
92   ${CMAKE_HOME_DIRECTORY}/src/jmsg_rngstream.h
93 )
94
95 set(JMSG_JAVA_SRC
96   ${CMAKE_HOME_DIRECTORY}/org/simgrid/msg/Host.java
97   ${CMAKE_HOME_DIRECTORY}/org/simgrid/msg/HostFailureException.java     
98   ${CMAKE_HOME_DIRECTORY}/org/simgrid/msg/HostNotFoundException.java    
99   ${CMAKE_HOME_DIRECTORY}/org/simgrid/msg/JniException.java
100   ${CMAKE_HOME_DIRECTORY}/org/simgrid/msg/Msg.java
101   ${CMAKE_HOME_DIRECTORY}/org/simgrid/msg/MsgException.java
102   ${CMAKE_HOME_DIRECTORY}/org/simgrid/msg/NativeException.java
103   ${CMAKE_HOME_DIRECTORY}/org/simgrid/msg/Process.java
104   ${CMAKE_HOME_DIRECTORY}/org/simgrid/msg/ProcessKilledError.java
105   ${CMAKE_HOME_DIRECTORY}/org/simgrid/msg/ProcessNotFoundException.java
106   ${CMAKE_HOME_DIRECTORY}/org/simgrid/msg/Task.java
107   ${CMAKE_HOME_DIRECTORY}/org/simgrid/msg/TaskCancelledException.java
108   ${CMAKE_HOME_DIRECTORY}/org/simgrid/msg/TimeoutException.java
109   ${CMAKE_HOME_DIRECTORY}/org/simgrid/msg/TransferFailureException.java 
110   ${CMAKE_HOME_DIRECTORY}/org/simgrid/msg/Mutex.java
111   ${CMAKE_HOME_DIRECTORY}/org/simgrid/msg/Comm.java
112   ${CMAKE_HOME_DIRECTORY}/org/simgrid/msg/RngStream.java
113 )
114
115 set(JAVA_EXAMPLES
116   ${CMAKE_HOME_DIRECTORY}/examples/async/AsyncTest.java
117   ${CMAKE_HOME_DIRECTORY}/examples/async/FinalizeTask.java  
118   ${CMAKE_HOME_DIRECTORY}/examples/async/Forwarder.java
119   ${CMAKE_HOME_DIRECTORY}/examples/async/Master.java  
120   ${CMAKE_HOME_DIRECTORY}/examples/async/Slave.java
121   ${CMAKE_HOME_DIRECTORY}/examples/bittorrent/Bittorrent.java
122   ${CMAKE_HOME_DIRECTORY}/examples/bittorrent/Common.java
123   ${CMAKE_HOME_DIRECTORY}/examples/bittorrent/Connection.java
124   ${CMAKE_HOME_DIRECTORY}/examples/bittorrent/MessageTask.java
125   ${CMAKE_HOME_DIRECTORY}/examples/bittorrent/Peer.java
126   ${CMAKE_HOME_DIRECTORY}/examples/bittorrent/Tracker.java
127   ${CMAKE_HOME_DIRECTORY}/examples/bittorrent/TrackerTask.java
128   ${CMAKE_HOME_DIRECTORY}/examples/chord/Chord.java
129   ${CMAKE_HOME_DIRECTORY}/examples/chord/Common.java
130   ${CMAKE_HOME_DIRECTORY}/examples/chord/Node.java
131   ${CMAKE_HOME_DIRECTORY}/examples/chord/ChordTask.java
132   ${CMAKE_HOME_DIRECTORY}/examples/chord/FindSuccessorAnswerTask.java
133   ${CMAKE_HOME_DIRECTORY}/examples/chord/FindSuccessorTask.java
134   ${CMAKE_HOME_DIRECTORY}/examples/chord/GetPredecessorAnswerTask.java
135   ${CMAKE_HOME_DIRECTORY}/examples/chord/NotifyTask.java
136   ${CMAKE_HOME_DIRECTORY}/examples/commTime/FinalizeTask.java
137   ${CMAKE_HOME_DIRECTORY}/examples/commTime/Master.java
138   ${CMAKE_HOME_DIRECTORY}/examples/commTime/Slave.java
139   ${CMAKE_HOME_DIRECTORY}/examples/commTime/CommTimeTest.java
140   ${CMAKE_HOME_DIRECTORY}/examples/masterslave/FinalizeTask.java
141   ${CMAKE_HOME_DIRECTORY}/examples/masterslave/Forwarder.java
142   ${CMAKE_HOME_DIRECTORY}/examples/masterslave/Master.java
143   ${CMAKE_HOME_DIRECTORY}/examples/masterslave/Masterslave.java
144   ${CMAKE_HOME_DIRECTORY}/examples/masterslave/Slave.java       
145   ${CMAKE_HOME_DIRECTORY}/examples/master_slave_bypass/Master.java
146   ${CMAKE_HOME_DIRECTORY}/examples/master_slave_bypass/MsBypass.java
147   ${CMAKE_HOME_DIRECTORY}/examples/master_slave_bypass/Slave.java
148   ${CMAKE_HOME_DIRECTORY}/examples/master_slave_bypass/FinalizeTask.java
149   ${CMAKE_HOME_DIRECTORY}/examples/master_slave_kill/Master.java
150   ${CMAKE_HOME_DIRECTORY}/examples/master_slave_kill/MsKill.java
151   ${CMAKE_HOME_DIRECTORY}/examples/master_slave_kill/Slave.java
152   ${CMAKE_HOME_DIRECTORY}/examples/master_slave_kill/FinalizeTask.java
153   ${CMAKE_HOME_DIRECTORY}/examples/migration/Emigrant.java
154   ${CMAKE_HOME_DIRECTORY}/examples/migration/Migration.java
155   ${CMAKE_HOME_DIRECTORY}/examples/migration/Policeman.java
156   ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/centralized/MutexCentral.java
157   ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/centralized/GrantTask.java
158   ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/centralized/Coordinator.java
159   ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/centralized/ReleaseTask.java
160   ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/centralized/Node.java
161   ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/centralized/RequestTask.java
162   ${CMAKE_HOME_DIRECTORY}/examples/pingPong/PingPongTask.java
163   ${CMAKE_HOME_DIRECTORY}/examples/pingPong/Sender.java
164   ${CMAKE_HOME_DIRECTORY}/examples/pingPong/Receiver.java
165   ${CMAKE_HOME_DIRECTORY}/examples/pingPong/PingPongTest.java
166   ${CMAKE_HOME_DIRECTORY}/examples/startKillTime/Master.java
167   ${CMAKE_HOME_DIRECTORY}/examples/startKillTime/Slave.java
168   ${CMAKE_HOME_DIRECTORY}/examples/startKillTime/StartKillTime.java
169   ${CMAKE_HOME_DIRECTORY}/examples/suspend/DreamMaster.java
170   ${CMAKE_HOME_DIRECTORY}/examples/suspend/LazyGuy.java
171   ${CMAKE_HOME_DIRECTORY}/examples/suspend/Suspend.java
172 )
173
174 set(CMAKE_SRC
175   ${CMAKE_HOME_DIRECTORY}/ChangeLog
176   ${CMAKE_HOME_DIRECTORY}/CMakeLists.txt
177   ${CMAKE_HOME_DIRECTORY}/FindJavaSG.cmake
178   ${CMAKE_HOME_DIRECTORY}/FindSimGrid.cmake
179 )
180
181 set(XML_FILES
182   ${CMAKE_HOME_DIRECTORY}/examples/master_slave_bypass/platform.xml
183   ${CMAKE_HOME_DIRECTORY}/examples/bittorrent/bittorrent.xml
184   ${CMAKE_HOME_DIRECTORY}/examples/platform.xml
185   ${CMAKE_HOME_DIRECTORY}/examples/commTime/commTimeDeployment.xml
186   ${CMAKE_HOME_DIRECTORY}/examples/async/asyncDeployment.xml
187   ${CMAKE_HOME_DIRECTORY}/examples/migration/migrationDeployment.xml
188   ${CMAKE_HOME_DIRECTORY}/examples/masterslave/deploy.xml
189   ${CMAKE_HOME_DIRECTORY}/examples/masterslave/masterslaveDeployment.xml
190   ${CMAKE_HOME_DIRECTORY}/examples/chord/chord100.xml
191   ${CMAKE_HOME_DIRECTORY}/examples/chord/chord.xml
192   ${CMAKE_HOME_DIRECTORY}/examples/chord/chord10.xml
193   ${CMAKE_HOME_DIRECTORY}/examples/chord/chord10000.xml
194   ${CMAKE_HOME_DIRECTORY}/examples/chord/chord1000.xml
195   ${CMAKE_HOME_DIRECTORY}/examples/chord/chord90.xml
196   ${CMAKE_HOME_DIRECTORY}/examples/suspend/suspendDeployment.xml
197   ${CMAKE_HOME_DIRECTORY}/examples/master_slave_kill/platform.xml
198   ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/centralized/mutex_centralized_deployment.xml
199   ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/ring3.xml
200   ${CMAKE_HOME_DIRECTORY}/examples/priority/priorityDeployment.xml
201   ${CMAKE_HOME_DIRECTORY}/examples/pingPong/pingPongDeployment.xml
202   ${CMAKE_HOME_DIRECTORY}/examples/startKillTime/deployment_kill.xml
203   ${CMAKE_HOME_DIRECTORY}/examples/startKillTime/deployment_start.xml
204   ${CMAKE_HOME_DIRECTORY}/examples/startKillTime/deployment_start_kill.xml
205   ${CMAKE_HOME_DIRECTORY}/examples/startKillTime/deployment.xml
206 )
207
208 set(source_to_pack
209   ${CMAKE_SRC}
210   ${JMSG_C_SRC}
211   ${JMSG_JAVA_SRC}
212   ${JAVA_EXAMPLES}
213   ${XML_FILES}
214 )
215
216 string(REPLACE "org/" "classes/org/" JMSG_JAVA_SRC_CLASS "${JMSG_JAVA_SRC}")
217 string(REPLACE ".java" ".class" JMSG_JAVA_SRC_CLASS "${JMSG_JAVA_SRC_CLASS}")
218 string(REPLACE ".java" ".class" JAVA_EXAMPLES_CLASS "${JAVA_EXAMPLES_CLASS}")
219
220 #########
221 # FLAGS #
222 #########
223 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 ")
224 set(INCLUDE_PATH "-I${CMAKE_HOME_DIRECTORY}/src -I${SIMGRID_INCLUDES} ")
225 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${INCLUDE_PATH}")
226
227 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=int-to-pointer-cast -Wno-error=pointer-to-int-cast")
228 if(COMPILER_C_VERSION_MAJOR_MINOR MATCHES "4.6")
229   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=unused-but-set-variable")
230 endif(COMPILER_C_VERSION_MAJOR_MINOR MATCHES "4.6")
231
232 ###########
233 # TARGETS #
234 ###########
235 # SG_java
236 add_library(SG_java SHARED ${JMSG_C_SRC})
237 if(WIN32)
238   set_target_properties(SG_java PROPERTIES LINK_FLAGS "-Wl,--subsystem,windows,--kill-at ${SIMGRID_LIB}" PREFIX "")
239   find_path(PEXPORTS_PATH NAMES pexports.exe PATHS NO_DEFAULT_PATHS)
240   message(STATUS "pexports: ${PEXPORTS_PATH}")
241   if(PEXPORTS_PATH)
242     add_custom_command(TARGET SG_java POST_BUILD
243     COMMAND ${PEXPORTS_PATH}/pexports.exe ${CMAKE_BINARY_DIR}/SG_java.dll > ${CMAKE_BINARY_DIR}/SG_java.def)
244   endif(PEXPORTS_PATH)
245 else(WIN32)
246   target_link_libraries(SG_java pcre pthread simgrid)
247   set_target_properties(SG_java PROPERTIES LINK_FLAGS "-L${SIMGRID_LIB_PATH}")
248 endif(WIN32)
249
250 # java_classes
251 add_custom_command(
252   OUTPUT        ${JMSG_JAVA_SRC_CLASS}
253   DEPENDS ${JMSG_JAVA_SRC}
254   COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_HOME_DIRECTORY}/classes/"
255   COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/classes/
256                                 -cp ${CMAKE_HOME_DIRECTORY}/classes/ ${JMSG_JAVA_SRC}
257   COMMENT "Compiling java sources of core library..."                                   
258 )
259 add_custom_target(java_classes ALL
260   DEPENDS ${JMSG_JAVA_SRC_CLASS}
261 )
262 SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES
263   ${JMSG_JAVA_SRC_CLASS}
264 )
265
266
267 # simgrid_jar
268 add_custom_target(simgrid_jar ALL
269   COMMAND ${JAVA_ARCHIVE} -cvf ${CMAKE_HOME_DIRECTORY}/simgrid.jar .
270   COMMENT "Building simgrid.jar..."
271   WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/classes 
272 )
273
274 # simgrid_java_examples
275 add_custom_command(
276   COMMENT "Build examples for java"
277   OUTPUT        ${JAVA_EXAMPLES_CLASS}
278   DEPENDS ${JAVA_EXAMPLES}
279   COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/async/*.java
280   COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/bittorrent/*.java
281   COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/chord/*.java
282   COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/commTime/*.java
283   COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/masterslave/*.java
284   COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/master_slave_bypass/*.java
285   COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/master_slave_kill/*.java
286   COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/migration/*.java
287   COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/centralized/*.java                               
288   COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/pingPong/*.java
289   COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/priority/*.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/suspend/*.java
292 )
293
294 add_custom_target(simgrid_java_examples ALL
295   DEPENDS ${JAVA_EXAMPLES}
296 )
297
298 ########################
299 # Declare dependencies #
300 ########################
301 add_dependencies(simgrid_jar java_classes)
302 add_dependencies(simgrid_java_examples simgrid_jar SG_java)
303
304 SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES
305   ${CMAKE_HOME_DIRECTORY}/simgrid.jar
306 )
307
308 #####################
309 # Declare our tests #
310 #####################
311 INCLUDE(CTest)
312 ENABLE_TESTING()
313
314 ADD_TEST(async           ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/async/async.tesh)
315 ADD_TEST(bittorrent      ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/bittorrent/bittorrent.tesh)
316 ADD_TEST(bypass          ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/master_slave_bypass/bypass.tesh)
317 ADD_TEST(commTime        ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/commTime/commtime.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(kill            ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/master_slave_kill/kill.tesh)
320 ADD_TEST(masterslave     ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/masterslave/masterslave.tesh)
321 ADD_TEST(migration       ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/migration/migration.tesh)
322 ADD_TEST(mutualExclusion ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/mutualexclusion.tesh)
323 ADD_TEST(pingPong        ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/pingPong/pingpong.tesh)
324 ADD_TEST(priority        ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/priority/priority.tesh)
325 ADD_TEST(startKillTime   ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/startKillTime/startKillTime.tesh)
326 ADD_TEST(suspend         ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/suspend/suspend.tesh)
327 #Don't forget to put new test in this list!!!
328 set(test_list async bittorrent bypass chord commTime kill masterslave migration mutualExclusion pingPong priority startKillTime)
329
330 ##########################################
331 # Set the  DYLD_LIBRARY_PATH for mac     #
332 ##########################################
333 if(APPLE)
334   if($ENV{DYLD_LIBRARY_PATH})
335     set_tests_properties(${test_list}
336     PROPERTIES ENVIRONMENT "DYLD_LIBRARY_PATH=${CMAKE_HOME_DIRECTORY}/lib:${SIMGRID_LIB_PATH}")
337   else($ENV{DYLD_LIBRARY_PATH})
338     set_tests_properties(${test_list}
339     PROPERTIES ENVIRONMENT "DYLD_LIBRARY_PATH=$ENV{DYLD_LIBRARY_PATH}:${CMAKE_HOME_DIRECTORY}/lib:${SIMGRID_LIB_PATH}")
340   endif($ENV{DYLD_LIBRARY_PATH})
341 else(APPLE)
342 ##########################################
343 # Set the  LD_LIBRARY_PATH for our tests #
344 ##########################################
345   if(NOT WIN32)
346     if($ENV{LD_LIBRARY_PATH})
347       set_tests_properties(${test_list}
348       PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_HOME_DIRECTORY}/lib:${SIMGRID_LIB_PATH}")
349     else($ENV{LD_LIBRARY_PATH})
350       set_tests_properties(${test_list}
351       PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}:${CMAKE_HOME_DIRECTORY}/lib:${SIMGRID_LIB_PATH}")
352     endif($ENV{LD_LIBRARY_PATH})
353   endif(NOT WIN32)
354 endif(APPLE)
355
356 ###########
357 # Install #
358 ###########
359 install(TARGETS SG_java
360   DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/java/)
361 install(FILES ${CMAKE_HOME_DIRECTORY}/simgrid.jar
362   DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/java/)
363
364
365 #########
366 # Dist  #
367 #########
368
369 add_custom_target(dist-dir
370   COMMENT "Generating the distribution directory"
371   COMMAND test -e ${DIST_NAME}/ && chmod -R a+w ${DIST_NAME}/ || true
372   COMMAND ${CMAKE_COMMAND} -E remove_directory ${DIST_NAME}/
373   COMMAND ${CMAKE_COMMAND} -E make_directory ${DIST_NAME}
374 )
375
376 set(dirs_in_tarball "")
377 foreach(file ${source_to_pack})
378
379   # This damn prefix is still set somewhere (seems to be in subdirs)
380   string(REPLACE "${CMAKE_HOME_DIRECTORY}/" "" file "${file}")
381   
382   # Create the directory on need
383   get_filename_component(file_location ${file} PATH)
384   string(REGEX MATCH ";${file_location};" OPERATION "${dirs_in_tarball}")
385   if(NOT OPERATION)
386     set(dirs_in_tarball "${dirs_in_tarball};${file_location};")
387     add_custom_command(
388       TARGET dist-dir
389       COMMAND ${CMAKE_COMMAND} -E make_directory ${DIST_NAME}/${file_location}/
390     )       
391   endif(NOT OPERATION)
392    
393    # Actually copy the file
394   add_custom_command(
395     TARGET dist-dir
396     COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_HOME_DIRECTORY}/${file} ${DIST_NAME}/${file_location}/
397   )
398 endforeach(file ${source_to_pack})
399
400 add_custom_target(dist
401   DEPENDS ${CMAKE_BINARY_DIR}/${DIST_NAME}.tar.gz
402   COMMENT "Generated ${DIST_NAME}"
403 )
404 add_custom_command(
405   OUTPUT ${CMAKE_BINARY_DIR}/${DIST_NAME}.tar.gz        
406   COMMENT "Compressing the archive from the distribution directory"
407   COMMAND ${CMAKE_COMMAND} -E tar cf ${DIST_NAME}.tar ${DIST_NAME}/
408   COMMAND gzip -9v ${DIST_NAME}.tar
409   COMMAND ${CMAKE_COMMAND} -E remove_directory ${DIST_NAME}/
410 )
411 add_dependencies(dist dist-dir)
412
413 ########
414 # NOTE #
415 ########
416 file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/Testing/Notes/)
417 file(WRITE ${CMAKE_BINARY_DIR}/Testing/Notes/Build  "GIT version : ${GIT_VERSION}\n")
418 file(APPEND ${CMAKE_BINARY_DIR}/Testing/Notes/Build "Release     : ${DIST_NAME}\n")
419 file(APPEND ${CMAKE_BINARY_DIR}/Testing/Notes/Build "Pipol user  : $ENV{PIPOL_USER}\n")
420 file(APPEND ${CMAKE_BINARY_DIR}/Testing/Notes/Build "Pipol image : $ENV{PIPOL_IMAGE}\n")
421
422 #######
423 # DOC #
424 #######
425 set(WARNING "This file is generated, don't edit it!")
426 set(srcdir ${CMAKE_HOME_DIRECTORY})
427 include(GenerateDoc.cmake)