Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make bind atributes private (we don't want users to mess with it)
[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}.${SIMGRID_JAVA_VERSION_PATCH})
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 # Check for option tracing in SimGrid
72 include(CheckLibraryExists)
73 CHECK_LIBRARY_EXISTS(${SIMGRID_LIB} TRACE_start "" HAVE_TRACING)
74 if(NOT HAVE_TRACING)
75   message(STATUS "Warning: SimGrid-java must be linked with library Simgrid included trace option to enable tracing.")
76   message(STATUS "Warning: See http://simgrid.gforge.inria.fr/simgrid/3.8/doc/tracing.html to see how compile SimGrid library with this option.")
77 endif(NOT HAVE_TRACING)
78
79 ###############################
80 # Declare our package content #
81 ###############################
82 set(JMSG_C_SRC
83   ${CMAKE_HOME_DIRECTORY}/src/smx_context_cojava.h
84   ${CMAKE_HOME_DIRECTORY}/src/smx_context_cojava.c
85   ${CMAKE_HOME_DIRECTORY}/src/jmsg_file.c
86   ${CMAKE_HOME_DIRECTORY}/src/jmsg_file.h
87   ${CMAKE_HOME_DIRECTORY}/src/smx_context_java.h
88   ${CMAKE_HOME_DIRECTORY}/src/smx_context_java.c
89   ${CMAKE_HOME_DIRECTORY}/src/jxbt_utilities.c
90   ${CMAKE_HOME_DIRECTORY}/src/jxbt_utilities.h
91   ${CMAKE_HOME_DIRECTORY}/src/jmsg.c 
92   ${CMAKE_HOME_DIRECTORY}/src/jmsg.h
93   ${CMAKE_HOME_DIRECTORY}/src/jmsg_comm.c
94   ${CMAKE_HOME_DIRECTORY}/src/jmsg_comm.h
95   ${CMAKE_HOME_DIRECTORY}/src/jmsg_host.c
96   ${CMAKE_HOME_DIRECTORY}/src/jmsg_host.h
97   ${CMAKE_HOME_DIRECTORY}/src/jmsg_process.c
98   ${CMAKE_HOME_DIRECTORY}/src/jmsg_process.h
99   ${CMAKE_HOME_DIRECTORY}/src/jmsg_task.c
100   ${CMAKE_HOME_DIRECTORY}/src/jmsg_task.h
101   ${CMAKE_HOME_DIRECTORY}/src/jmsg_synchro.c
102   ${CMAKE_HOME_DIRECTORY}/src/jmsg_synchro.h
103   ${CMAKE_HOME_DIRECTORY}/src/jmsg_rngstream.c
104   ${CMAKE_HOME_DIRECTORY}/src/jmsg_rngstream.h
105 )
106
107 set(JTRACE_C_SRC
108         src/jtrace.c
109         src/jtrace.h
110 )       
111
112 set(JMSG_JAVA_SRC
113   ${CMAKE_HOME_DIRECTORY}/org/simgrid/msg/Host.java
114   ${CMAKE_HOME_DIRECTORY}/org/simgrid/msg/HostFailureException.java     
115   ${CMAKE_HOME_DIRECTORY}/org/simgrid/msg/HostNotFoundException.java
116   ${CMAKE_HOME_DIRECTORY}/org/simgrid/msg/File.java
117   ${CMAKE_HOME_DIRECTORY}/org/simgrid/msg/JniException.java
118   ${CMAKE_HOME_DIRECTORY}/org/simgrid/msg/Msg.java
119   ${CMAKE_HOME_DIRECTORY}/org/simgrid/msg/MsgException.java
120   ${CMAKE_HOME_DIRECTORY}/org/simgrid/msg/NativeException.java
121   ${CMAKE_HOME_DIRECTORY}/org/simgrid/msg/Process.java
122   ${CMAKE_HOME_DIRECTORY}/org/simgrid/msg/ProcessKilledError.java
123   ${CMAKE_HOME_DIRECTORY}/org/simgrid/msg/ProcessNotFoundException.java
124   ${CMAKE_HOME_DIRECTORY}/org/simgrid/msg/Task.java
125   ${CMAKE_HOME_DIRECTORY}/org/simgrid/msg/TaskCancelledException.java
126   ${CMAKE_HOME_DIRECTORY}/org/simgrid/msg/TimeoutException.java
127   ${CMAKE_HOME_DIRECTORY}/org/simgrid/msg/TransferFailureException.java 
128   ${CMAKE_HOME_DIRECTORY}/org/simgrid/msg/Mutex.java
129   ${CMAKE_HOME_DIRECTORY}/org/simgrid/msg/Comm.java
130   ${CMAKE_HOME_DIRECTORY}/org/simgrid/msg/RngStream.java
131 )
132 set(JTRACE_JAVA_SRC
133         org/simgrid/trace/Trace.java
134 )
135
136 set(JAVA_EXAMPLES
137   ${CMAKE_HOME_DIRECTORY}/examples/async/AsyncTest.java
138   ${CMAKE_HOME_DIRECTORY}/examples/async/FinalizeTask.java  
139   ${CMAKE_HOME_DIRECTORY}/examples/async/Forwarder.java
140   ${CMAKE_HOME_DIRECTORY}/examples/async/Master.java  
141   ${CMAKE_HOME_DIRECTORY}/examples/async/Slave.java
142   ${CMAKE_HOME_DIRECTORY}/examples/bittorrent/Bittorrent.java
143   ${CMAKE_HOME_DIRECTORY}/examples/bittorrent/Common.java
144   ${CMAKE_HOME_DIRECTORY}/examples/bittorrent/Connection.java
145   ${CMAKE_HOME_DIRECTORY}/examples/bittorrent/MessageTask.java
146   ${CMAKE_HOME_DIRECTORY}/examples/bittorrent/Peer.java
147   ${CMAKE_HOME_DIRECTORY}/examples/bittorrent/Tracker.java
148   ${CMAKE_HOME_DIRECTORY}/examples/bittorrent/TrackerTask.java
149   ${CMAKE_HOME_DIRECTORY}/examples/chord/Chord.java
150   ${CMAKE_HOME_DIRECTORY}/examples/chord/Common.java
151   ${CMAKE_HOME_DIRECTORY}/examples/chord/Node.java
152   ${CMAKE_HOME_DIRECTORY}/examples/chord/ChordTask.java
153   ${CMAKE_HOME_DIRECTORY}/examples/chord/FindSuccessorAnswerTask.java
154   ${CMAKE_HOME_DIRECTORY}/examples/chord/FindSuccessorTask.java
155   ${CMAKE_HOME_DIRECTORY}/examples/chord/GetPredecessorAnswerTask.java
156   ${CMAKE_HOME_DIRECTORY}/examples/chord/NotifyTask.java
157   ${CMAKE_HOME_DIRECTORY}/examples/commTime/FinalizeTask.java
158   ${CMAKE_HOME_DIRECTORY}/examples/commTime/Master.java
159   ${CMAKE_HOME_DIRECTORY}/examples/commTime/Slave.java
160   ${CMAKE_HOME_DIRECTORY}/examples/commTime/CommTimeTest.java
161   ${CMAKE_HOME_DIRECTORY}/examples/io/IO.java
162   ${CMAKE_HOME_DIRECTORY}/examples/io/Node.java
163   ${CMAKE_HOME_DIRECTORY}/examples/masterslave/FinalizeTask.java
164   ${CMAKE_HOME_DIRECTORY}/examples/masterslave/Forwarder.java
165   ${CMAKE_HOME_DIRECTORY}/examples/masterslave/Master.java
166   ${CMAKE_HOME_DIRECTORY}/examples/masterslave/Masterslave.java
167   ${CMAKE_HOME_DIRECTORY}/examples/masterslave/Slave.java       
168   ${CMAKE_HOME_DIRECTORY}/examples/master_slave_bypass/Master.java
169   ${CMAKE_HOME_DIRECTORY}/examples/master_slave_bypass/MsBypass.java
170   ${CMAKE_HOME_DIRECTORY}/examples/master_slave_bypass/Slave.java
171   ${CMAKE_HOME_DIRECTORY}/examples/master_slave_bypass/FinalizeTask.java
172   ${CMAKE_HOME_DIRECTORY}/examples/master_slave_kill/Master.java
173   ${CMAKE_HOME_DIRECTORY}/examples/master_slave_kill/MsKill.java
174   ${CMAKE_HOME_DIRECTORY}/examples/master_slave_kill/Slave.java
175   ${CMAKE_HOME_DIRECTORY}/examples/master_slave_kill/FinalizeTask.java
176   ${CMAKE_HOME_DIRECTORY}/examples/migration/Emigrant.java
177   ${CMAKE_HOME_DIRECTORY}/examples/migration/Migration.java
178   ${CMAKE_HOME_DIRECTORY}/examples/migration/Policeman.java
179   ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/centralized/MutexCentral.java
180   ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/centralized/GrantTask.java
181   ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/centralized/Coordinator.java
182   ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/centralized/ReleaseTask.java
183   ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/centralized/Node.java
184   ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/centralized/RequestTask.java
185   ${CMAKE_HOME_DIRECTORY}/examples/pingPong/PingPongTask.java
186   ${CMAKE_HOME_DIRECTORY}/examples/pingPong/Sender.java
187   ${CMAKE_HOME_DIRECTORY}/examples/pingPong/Receiver.java
188   ${CMAKE_HOME_DIRECTORY}/examples/pingPong/PingPongTest.java
189   ${CMAKE_HOME_DIRECTORY}/examples/startKillTime/Master.java
190   ${CMAKE_HOME_DIRECTORY}/examples/startKillTime/Slave.java
191   ${CMAKE_HOME_DIRECTORY}/examples/startKillTime/StartKillTime.java
192   ${CMAKE_HOME_DIRECTORY}/examples/tracing/PingPongTask.java
193   ${CMAKE_HOME_DIRECTORY}/examples/suspend/DreamMaster.java
194   ${CMAKE_HOME_DIRECTORY}/examples/suspend/LazyGuy.java
195   ${CMAKE_HOME_DIRECTORY}/examples/suspend/Suspend.java
196   ${CMAKE_HOME_DIRECTORY}/examples/tracing/Sender.java
197   ${CMAKE_HOME_DIRECTORY}/examples/tracing/Receiver.java
198   ${CMAKE_HOME_DIRECTORY}/examples/tracing/TracingTest.java
199
200 )
201
202 set(CMAKE_SRC
203   ${CMAKE_HOME_DIRECTORY}/ChangeLog
204   ${CMAKE_HOME_DIRECTORY}/CMakeLists.txt
205   ${CMAKE_HOME_DIRECTORY}/doxygen_postprocesser.pl
206   ${CMAKE_HOME_DIRECTORY}/FindJavaSG.cmake
207   ${CMAKE_HOME_DIRECTORY}/FindSimGrid.cmake
208   ${CMAKE_HOME_DIRECTORY}/GenerateDoc.cmake
209   ${CMAKE_HOME_DIRECTORY}/README
210 )
211
212 set(CMAKE_DOC_SRC
213   ${CMAKE_HOME_DIRECTORY}/doc/Doxyfile.in
214   ${CMAKE_HOME_DIRECTORY}/doc/footer.html.in
215   ${CMAKE_HOME_DIRECTORY}/doc/index.doc
216   ${CMAKE_HOME_DIRECTORY}/doc/install.doc
217 )
218
219 set(XML_FILES
220   ${CMAKE_HOME_DIRECTORY}/examples/master_slave_bypass/platform.xml
221   ${CMAKE_HOME_DIRECTORY}/examples/bittorrent/bittorrent.xml
222   ${CMAKE_HOME_DIRECTORY}/examples/platform.xml
223   ${CMAKE_HOME_DIRECTORY}/examples/commTime/commTimeDeployment.xml
224   ${CMAKE_HOME_DIRECTORY}/examples/async/asyncDeployment.xml
225   ${CMAKE_HOME_DIRECTORY}/examples/migration/migrationDeployment.xml
226   ${CMAKE_HOME_DIRECTORY}/examples/masterslave/deploy.xml
227   ${CMAKE_HOME_DIRECTORY}/examples/masterslave/masterslaveDeployment.xml
228   ${CMAKE_HOME_DIRECTORY}/examples/chord/chord100.xml
229   ${CMAKE_HOME_DIRECTORY}/examples/chord/chord.xml
230   ${CMAKE_HOME_DIRECTORY}/examples/chord/chord10.xml
231   ${CMAKE_HOME_DIRECTORY}/examples/chord/chord10000.xml
232   ${CMAKE_HOME_DIRECTORY}/examples/chord/chord1000.xml
233   ${CMAKE_HOME_DIRECTORY}/examples/chord/chord90.xml
234   ${CMAKE_HOME_DIRECTORY}/examples/suspend/suspendDeployment.xml
235   ${CMAKE_HOME_DIRECTORY}/examples/master_slave_kill/platform.xml
236   ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/centralized/mutex_centralized_deployment.xml
237   ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/ring3.xml
238   ${CMAKE_HOME_DIRECTORY}/examples/priority/priorityDeployment.xml
239   ${CMAKE_HOME_DIRECTORY}/examples/pingPong/pingPongDeployment.xml
240   ${CMAKE_HOME_DIRECTORY}/examples/startKillTime/deployment_kill.xml
241   ${CMAKE_HOME_DIRECTORY}/examples/startKillTime/deployment_start.xml
242   ${CMAKE_HOME_DIRECTORY}/examples/startKillTime/deployment_start_kill.xml
243   ${CMAKE_HOME_DIRECTORY}/examples/startKillTime/deployment.xml
244   ${CMAKE_HOME_DIRECTORY}/examples/io/storage.xml
245   ${CMAKE_HOME_DIRECTORY}/examples/tracing/tracingPingPongDeployment.xml
246 )
247
248 set(TESH_FILES
249   ${CMAKE_HOME_DIRECTORY}/examples/master_slave_bypass/bypass.tesh
250   ${CMAKE_HOME_DIRECTORY}/examples/bittorrent/bittorrent.tesh
251   ${CMAKE_HOME_DIRECTORY}/examples/commTime/commtime.tesh
252   ${CMAKE_HOME_DIRECTORY}/examples/async/async.tesh
253   ${CMAKE_HOME_DIRECTORY}/examples/migration/migration.tesh
254   ${CMAKE_HOME_DIRECTORY}/examples/masterslave/masterslave.tesh
255   ${CMAKE_HOME_DIRECTORY}/examples/chord/chord.tesh
256   ${CMAKE_HOME_DIRECTORY}/examples/suspend/suspend.tesh
257   ${CMAKE_HOME_DIRECTORY}/examples/master_slave_kill/kill.tesh
258   ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/mutualexclusion.tesh
259   ${CMAKE_HOME_DIRECTORY}/examples/priority/priority.tesh
260   ${CMAKE_HOME_DIRECTORY}/examples/pingPong/pingpong.tesh
261   ${CMAKE_HOME_DIRECTORY}/examples/startKillTime/startKillTime.tesh
262   ${CMAKE_HOME_DIRECTORY}/examples/tracing/tracingPingPong.tesh
263 )
264
265 set(source_to_pack
266   ${CMAKE_SRC}
267   ${JMSG_C_SRC}
268   ${JTRACE_C_SRC}
269   ${JMSG_JAVA_SRC}
270   ${JTRACE_JAVA_SRC}
271   ${JAVA_EXAMPLES}
272   ${XML_FILES}
273   ${CMAKE_DOC_SRC}
274   ${TESH_FILES}
275 )
276
277 string(REPLACE "org/" "classes/org/" JMSG_JAVA_SRC_CLASS "${JMSG_JAVA_SRC}")
278 string(REPLACE ".java" ".class" JMSG_JAVA_SRC_CLASS "${JMSG_JAVA_SRC_CLASS}")
279
280 string(REPLACE "org/" "classes/org/" JTRACE_JAVA_SRC_CLASS "${JTRACE_JAVA_SRC}")
281 string(REPLACE ".java" ".class" JTRACE_JAVA_SRC_CLASS "${JTRACE_JAVA_SRC_CLASS}")
282
283 string(REPLACE ".java" ".class" JAVA_EXAMPLES_CLASS "${JAVA_EXAMPLES}")
284
285 #########
286 # FLAGS #
287 #########
288 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 ")
289 set(INCLUDE_PATH "-I${CMAKE_HOME_DIRECTORY}/src -I${SIMGRID_INCLUDES} ")
290 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${INCLUDE_PATH}")
291
292 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=int-to-pointer-cast -Wno-error=pointer-to-int-cast")
293 if(COMPILER_C_VERSION_MAJOR_MINOR MATCHES "4.6")
294   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=unused-but-set-variable")
295 endif(COMPILER_C_VERSION_MAJOR_MINOR MATCHES "4.6")
296
297 ###########
298 # TARGETS #
299 ###########
300 # SG_java
301 add_library(SG_java SHARED ${JMSG_C_SRC})
302 if(WIN32)
303   set_target_properties(SG_java PROPERTIES LINK_FLAGS "-Wl,--subsystem,windows,--kill-at ${SIMGRID_LIB}" PREFIX "")
304   find_path(PEXPORTS_PATH NAMES pexports.exe PATHS NO_DEFAULT_PATHS)
305   message(STATUS "pexports: ${PEXPORTS_PATH}")
306   if(PEXPORTS_PATH)
307     add_custom_command(TARGET SG_java POST_BUILD
308     COMMAND ${PEXPORTS_PATH}/pexports.exe ${CMAKE_BINARY_DIR}/SG_java.dll > ${CMAKE_BINARY_DIR}/SG_java.def)
309   endif(PEXPORTS_PATH)
310 else(WIN32)
311   target_link_libraries(SG_java pcre pthread simgrid)
312   set_target_properties(SG_java PROPERTIES LINK_FLAGS "-L${SIMGRID_LIB_PATH}")
313 endif(WIN32)
314
315 if(HAVE_TRACING)
316 # SG_java_tracing
317 add_library(SG_java_tracing SHARED ${JTRACE_C_SRC})
318   if(WIN32)
319     set_target_properties(SG_java_tracing PROPERTIES LINK_FLAGS "-Wl,--subsystem,windows,--kill-at ${SIMGRID_LIB}" PREFIX "")
320     find_path(PEXPORTS_PATH NAMES pexports.exe PATHS NO_DEFAULT_PATHS)
321     message(STATUS "pexports: ${PEXPORTS_PATH}")
322     if(PEXPORTS_PATH)
323       add_custom_command(TARGET SG_java_tracing POST_BUILD
324       COMMAND ${PEXPORTS_PATH}/pexports.exe ${CMAKE_BINARY_DIR}/SG_java_tracing.dll > ${CMAKE_BINARY_DIR}/SG_java_tracing.def)
325     endif(PEXPORTS_PATH)
326   else(WIN32)
327     target_link_libraries(SG_java_tracing pcre pthread simgrid)
328     set_target_properties(SG_java_tracing PROPERTIES LINK_FLAGS "-L${SIMGRID_LIB_PATH}")
329   endif(WIN32)
330 endif(HAVE_TRACING)
331
332 # java_classes
333 add_custom_command(
334   OUTPUT  ${JMSG_JAVA_SRC_CLASS}
335   DEPENDS ${JMSG_JAVA_SRC}
336   COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_HOME_DIRECTORY}/classes/"
337   COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/classes/
338     -cp ${CMAKE_HOME_DIRECTORY}/classes/ ${JMSG_JAVA_SRC}
339   COMMENT "Compiling java sources of core library..."                                   
340 )
341 add_custom_target(java_classes ALL
342   DEPENDS ${JMSG_JAVA_SRC_CLASS}
343 )
344
345 if(HAVE_TRACING)
346   add_custom_command(
347     OUTPUT  ${JTRACE_JAVA_SRC_CLASS}
348     DEPENDS ${JTRACE_JAVA_SRC}
349     COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_HOME_DIRECTORY}/classes/"
350     COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/classes/
351       -cp ${CMAKE_HOME_DIRECTORY}/classes/ ${JAVA_FILES_TRACE}
352     COMMENT "Compiling java sources of core libraries..."                                       
353   )
354   add_custom_command(TARGET java_classes
355     DEPENDS ${JTRACE_JAVA_SRC_CLASS}
356   )
357 endif(HAVE_TRACING)
358
359 # simgrid_jar
360 add_custom_target(simgrid_jar ALL
361   COMMAND ${JAVA_ARCHIVE} -cvf ${CMAKE_HOME_DIRECTORY}/simgrid.jar .
362   COMMENT "Building simgrid.jar..."
363   WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/classes 
364 )
365
366 # simgrid_java_examples
367 set(JAVA_EXAMPLES_CLASS
368   ${JAVA_EXAMPLES_CLASS}
369   ${CMAKE_HOME_DIRECTORY}/examples/bittorrent/MessageTask$Type.class
370   ${CMAKE_HOME_DIRECTORY}/examples/bittorrent/Peer$1.class
371   ${CMAKE_HOME_DIRECTORY}/examples/bittorrent/TrackerTask$Type.class
372   ${CMAKE_HOME_DIRECTORY}/examples/chord/GetPredecessorTask.class
373   ${CMAKE_HOME_DIRECTORY}/examples/priority/Test.class
374   ${CMAKE_HOME_DIRECTORY}/examples/priority/Priority.class
375 )
376
377 add_custom_command(
378   COMMENT "Build examples for java"
379   OUTPUT  ${JAVA_EXAMPLES_CLASS}
380   DEPENDS ${JAVA_EXAMPLES}
381   COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/async/*.java
382   COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/bittorrent/*.java
383   COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/chord/*.java
384   COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/commTime/*.java
385   COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/io/*.java
386   COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/masterslave/*.java
387   COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/master_slave_bypass/*.java
388   COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/master_slave_kill/*.java
389   COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/migration/*.java
390   COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/centralized/*.java                               
391   COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/pingPong/*.java
392   COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/priority/*.java          
393   COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/startKillTime/*.java
394   COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/suspend/*.java
395 )
396 if(HAVE_TRACING)
397   add_custom_command(
398     DEPENDS ${JAVA_EXAMPLES}
399     COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/tracing/*.java
400 )
401 endif(HAVE_TRACING)
402
403 add_custom_target(simgrid_java_examples ALL
404   DEPENDS ${JAVA_EXAMPLES_CLASS}
405 )
406
407 ########################
408 # Declare dependencies #
409 ########################
410 add_dependencies(simgrid_jar java_classes)
411 add_dependencies(simgrid_java_examples simgrid_jar SG_java)
412 if(HAVE_TRACING)
413   add_dependencies(SG_java_tracing)
414 endif(HAVE_TRACING)
415
416 #####################
417 # Declare our tests #
418 #####################
419 INCLUDE(CTest)
420 ENABLE_TESTING()
421
422 ADD_TEST(async           ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/async/async.tesh)
423 ADD_TEST(bittorrent      ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/bittorrent/bittorrent.tesh)
424 ADD_TEST(bypass          ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/master_slave_bypass/bypass.tesh)
425 ADD_TEST(commTime        ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/commTime/commtime.tesh)
426 ADD_TEST(chord           ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/chord/chord.tesh)
427 ADD_TEST(kill            ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/master_slave_kill/kill.tesh)
428 ADD_TEST(masterslave     ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/masterslave/masterslave.tesh)
429 ADD_TEST(migration       ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/migration/migration.tesh)
430 ADD_TEST(mutualExclusion ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/mutualexclusion.tesh)
431 ADD_TEST(pingPong        ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/pingPong/pingpong.tesh)
432 ADD_TEST(priority        ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/priority/priority.tesh)
433 ADD_TEST(startKillTime   ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/startKillTime/startKillTime.tesh)
434 ADD_TEST(suspend         ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/suspend/suspend.tesh)
435 #Don't forget to put new test in this list!!!
436 set(test_list async bittorrent bypass chord commTime kill masterslave migration mutualExclusion pingPong priority startKillTime)
437 if(HAVE_TRACING)
438   ADD_TEST(tracing         ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/tracing/tracingPingPong.tesh)
439   set(test_list "${test_list} tracing")
440 endif(HAVE_TRACING)
441 ##########################################
442 # Set the  DYLD_LIBRARY_PATH for mac     #
443 ##########################################
444 if(APPLE)
445   if($ENV{DYLD_LIBRARY_PATH})
446     set_tests_properties(${test_list}
447     PROPERTIES ENVIRONMENT "DYLD_LIBRARY_PATH=${CMAKE_HOME_DIRECTORY}/lib:${SIMGRID_LIB_PATH}")
448   else($ENV{DYLD_LIBRARY_PATH})
449     set_tests_properties(${test_list}
450     PROPERTIES ENVIRONMENT "DYLD_LIBRARY_PATH=$ENV{DYLD_LIBRARY_PATH}:${CMAKE_HOME_DIRECTORY}/lib:${SIMGRID_LIB_PATH}")
451   endif($ENV{DYLD_LIBRARY_PATH})
452 else(APPLE)
453 ##########################################
454 # Set the  LD_LIBRARY_PATH for our tests #
455 ##########################################
456   if(NOT WIN32)
457     if($ENV{LD_LIBRARY_PATH})
458       set_tests_properties(${test_list}
459       PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_HOME_DIRECTORY}/lib:${SIMGRID_LIB_PATH}")
460     else($ENV{LD_LIBRARY_PATH})
461       set_tests_properties(${test_list}
462       PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}:${CMAKE_HOME_DIRECTORY}/lib:${SIMGRID_LIB_PATH}")
463     endif($ENV{LD_LIBRARY_PATH})
464   endif(NOT WIN32)
465 endif(APPLE)
466
467 ###########
468 # Install #
469 ###########
470 install(TARGETS SG_java
471   DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/java/)
472
473 if(HAVE_TRACING)
474   install(TARGETS SG_java_tracing
475     DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/java/)
476 endif(HAVE_TRACING)
477  
478 install(FILES ${CMAKE_HOME_DIRECTORY}/simgrid.jar
479   DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/java/)
480
481
482 #########
483 # Dist  #
484 #########
485 add_custom_target(dist-dir
486   COMMENT "Generating the distribution directory"
487   COMMAND test -e ${DIST_NAME}/ && chmod -R a+w ${DIST_NAME}/ || true
488   COMMAND ${CMAKE_COMMAND} -E remove_directory ${DIST_NAME}/
489   COMMAND ${CMAKE_COMMAND} -E make_directory ${DIST_NAME}
490   COMMAND ${CMAKE_COMMAND} -E make_directory ${DIST_NAME}/doc/html/
491   COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_HOME_DIRECTORY}/doc/html/ ${DIST_NAME}/doc/html/
492 )
493
494 set(dirs_in_tarball "")
495 foreach(file ${source_to_pack})
496
497   # This damn prefix is still set somewhere (seems to be in subdirs)
498   string(REPLACE "${CMAKE_HOME_DIRECTORY}/" "" file "${file}")
499   
500   # Create the directory on need
501   get_filename_component(file_location ${file} PATH)
502   string(REGEX MATCH ";${file_location};" OPERATION "${dirs_in_tarball}")
503   if(NOT OPERATION)
504     set(dirs_in_tarball "${dirs_in_tarball};${file_location};")
505     add_custom_command(
506       TARGET dist-dir
507       COMMAND ${CMAKE_COMMAND} -E make_directory ${DIST_NAME}/${file_location}/
508     )       
509   endif(NOT OPERATION)
510    
511    # Actually copy the file
512   add_custom_command(
513     TARGET dist-dir
514     COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_HOME_DIRECTORY}/${file} ${DIST_NAME}/${file_location}/
515   )
516 endforeach(file ${source_to_pack})
517
518 add_custom_target(dist
519   DEPENDS ${CMAKE_BINARY_DIR}/${DIST_NAME}.tar.gz
520   COMMENT "Generated ${DIST_NAME}"
521 )
522 add_custom_command(
523   OUTPUT ${CMAKE_BINARY_DIR}/${DIST_NAME}.tar.gz        
524   COMMENT "Compressing the archive from the distribution directory"
525   COMMAND ${CMAKE_COMMAND} -E tar cf ${DIST_NAME}.tar ${DIST_NAME}/
526   COMMAND gzip -9v ${DIST_NAME}.tar
527   COMMAND ${CMAKE_COMMAND} -E remove_directory ${DIST_NAME}/
528 )
529 add_dependencies(dist dist-dir)
530
531 ##########################
532 # Extra make clean files #
533 ##########################
534 SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES
535   ${CMAKE_HOME_DIRECTORY}/simgrid.jar
536 )
537
538 ########
539 # NOTE #
540 ########
541 file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/Testing/Notes/)
542 file(WRITE ${CMAKE_BINARY_DIR}/Testing/Notes/Build  "GIT version : ${GIT_VERSION}\n")
543 file(APPEND ${CMAKE_BINARY_DIR}/Testing/Notes/Build "Release     : ${DIST_NAME}\n")
544 file(APPEND ${CMAKE_BINARY_DIR}/Testing/Notes/Build "Pipol user  : $ENV{PIPOL_USER}\n")
545 file(APPEND ${CMAKE_BINARY_DIR}/Testing/Notes/Build "Pipol image : $ENV{PIPOL_IMAGE}\n")
546
547 #######
548 # DOC #
549 #######
550 set(WARNING "This file is generated, don't edit it!")
551 set(srcdir ${CMAKE_HOME_DIRECTORY})
552 include(GenerateDoc.cmake)