Logo AND Algorithmique Numérique Distribuée

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