Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add AS support in MSG and java bindings
[simgrid.git] / examples / java / bittorrent / CMakeLists.txt
index 50e0e32..a245baa 100644 (file)
@@ -1,27 +1,42 @@
 cmake_minimum_required(VERSION 2.6)
 
+set(example java_bittorrent)
+set(sources
+  ${CMAKE_CURRENT_SOURCE_DIR}/Bittorrent.java
+  ${CMAKE_CURRENT_SOURCE_DIR}/Common.java
+  ${CMAKE_CURRENT_SOURCE_DIR}/Connection.java
+  ${CMAKE_CURRENT_SOURCE_DIR}/MessageTask.java
+  ${CMAKE_CURRENT_SOURCE_DIR}/Peer.java
+  ${CMAKE_CURRENT_SOURCE_DIR}/Tracker.java
+  ${CMAKE_CURRENT_SOURCE_DIR}/TrackerTask.java
+  )
+
 if(enable_java)
-  add_custom_target(java_bittorrent ALL
-    COMMAND ${JAVA_COMPILE} -cp ${CMAKE_BINARY_DIR}/simgrid.jar
-                            -d ${CMAKE_CURRENT_BINARY_DIR}/..
-                            ${CMAKE_CURRENT_SOURCE_DIR}/*.java)
-  add_dependencies(java_bittorrent SG_java_jar)
+  add_custom_command(
+    COMMENT "Building ${example}..."
+    OUTPUT ${example}_compiled
+    DEPENDS ${sources} SG_java_jar ${SIMGRID_JAR}
+    COMMAND ${JAVA_COMPILE} -cp ${SIMGRID_JAR}
+                             -d ${CMAKE_CURRENT_BINARY_DIR}/.. ${sources}
+    COMMAND ${CMAKE_COMMAND} -E remove ${example}_compiled
+    COMMAND ${CMAKE_COMMAND} -E touch ${example}_compiled
+  )
+  add_custom_target(${example} ALL DEPENDS ${example}_compiled)
 endif()
 
 set(tesh_files
   ${tesh_files}
-  examples/bittorrent/bittorrent.tesh
+  ${CMAKE_CURRENT_SOURCE_DIR}/bittorrent.tesh
   PARENT_SCOPE
   )
 set(xml_files
   ${xml_files}
+  ${CMAKE_CURRENT_SOURCE_DIR}/bittorrent.xml
   PARENT_SCOPE
   )
 set(examples_src
   ${examples_src}
-  examples/bittorrent/MessageTask.java
-  examples/bittorrent/Peer.java
-  examples/bittorrent/TrackerTask.java
+  ${sources}
   PARENT_SCOPE
   )
 set(bin_files
@@ -30,6 +45,6 @@ set(bin_files
   )
 set(txt_files
   ${txt_files}
+  ${CMAKE_CURRENT_SOURCE_DIR}/generate.py
   PARENT_SCOPE
   )
-