Logo AND Algorithmique Numérique Distribuée

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