Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Simplify the cmake around java examples
[simgrid.git] / teshsuite / java / CMakeLists.txt
index 3c6e4c6..c6dcb7a 100644 (file)
@@ -9,25 +9,17 @@ foreach(example semaphoregc sleephostoff)
   set(tesh_files   ${tesh_files}   ${CMAKE_CURRENT_SOURCE_DIR}/${example}/${example}.tesh)
 
   if(enable_java)
-    add_custom_command(
-      COMMENT "Building ${example}..."
-      OUTPUT  java-${example}_compiled
-      DEPENDS ${sources} simgrid-java_jar ${SIMGRID_JAR}
-      COMMAND ${JAVA_COMPILE} -classpath ${SIMGRID_JAR} -d ${CMAKE_CURRENT_BINARY_DIR} ${sources}
-      COMMAND ${CMAKE_COMMAND} -E remove ${example}/java-${example}_compiled
-      COMMAND ${CMAKE_COMMAND} -E touch ${example}/java-${example}_compiled
-    )
-    add_custom_target(java-${example} ALL DEPENDS java-${example}_compiled)
+    string (REPLACE "-" "/" example_dir ${example})
+    add_jar(java-${example} SOURCES ${sources}
+            INCLUDE_JARS ${SIMGRID_JAR}
+           OUTPUT_NAME ${example}
+           OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/${example_dir})
     add_dependencies(java-all java-${example})
-    set_target_properties(java-${example}  PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${example})
+    
+    ADD_TESH(tesh-java-${example}  --setenv javacmd=${Java_JAVA_EXECUTABLE} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --setenv LD_LIBRARY_PATH=${TESH_LIBRARY_PATH} --setenv classpath=${TESH_CLASSPATH}:${example}.jar --cd ${CMAKE_BINARY_DIR}/teshsuite/java/${example_dir}  ${CMAKE_HOME_DIRECTORY}/teshsuite/java/${example_dir}/${example}.tesh)
   endif()
   set(examples_src ${examples_src} ${sources})
 endforeach()
 
-set(examples_src ${examples_src} ${sources}                                                    PARENT_SCOPE)
+set(examples_src ${examples_src}                                                               PARENT_SCOPE)
 set(tesh_files   ${tesh_files}                                                                 PARENT_SCOPE)
-
-if(enable_java)
-  ADD_TESH(tesh-java-semaphoregc  --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --setenv LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/teshsuite/java/semaphoregc  ${CMAKE_HOME_DIRECTORY}/teshsuite/java/semaphoregc/semaphoregc.tesh)
-  ADD_TESH(tesh-java-sleephostoff --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --setenv LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/teshsuite/java/sleephostoff ${CMAKE_HOME_DIRECTORY}/teshsuite/java/sleephostoff/sleephostoff.tesh)
-endif()