Logo AND Algorithmique Numérique Distribuée

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