Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Another fix in build depends.
[simgrid.git] / examples / java / commTime / CMakeLists.txt
index 0545440..320b5c8 100644 (file)
@@ -1,5 +1,6 @@
 cmake_minimum_required(VERSION 2.6)
 
+set(example java_commTime)
 set(sources
   ${CMAKE_CURRENT_SOURCE_DIR}/CommTimeTest.java
   ${CMAKE_CURRENT_SOURCE_DIR}/FinalizeTask.java
@@ -8,11 +9,16 @@ set(sources
   )
 
 if(enable_java)
-  add_custom_target(java_commTime ALL
-    COMMENT "Building java_commTime..."
-    COMMAND ${JAVA_COMPILE} -cp ${CMAKE_BINARY_DIR}/simgrid.jar
-                            -d ${CMAKE_CURRENT_BINARY_DIR}/.. ${sources})
-  add_dependencies(java_commTime 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