Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Simplify the cmake around java examples
[simgrid.git] / examples / deprecated / java / CMakeLists.txt
index 99a610f..bad11f3 100644 (file)
@@ -16,8 +16,6 @@ set(trace-pingpong_files        Main  PingPongTask Receiver Sender)
 set(energy-consumption_files    Main  EnergyConsumer)
 set(energy-pstate_files         Main  PstateRunner)
 set(energy-vm_files             Main  EnergyVMRunner)
-set(io-file_files               Main  Node)
-set(io-storage_files            Main  Client)
 set(process-kill_files          Main  Killer  Victim)
 set(process-migration_files     Main  Emigrant  Policeman)
 set(process-startkilltime_files Main  Sleeper)
@@ -31,7 +29,7 @@ if(enable_java)
 endif()
 
 foreach (example app-bittorrent app-centralizedmutex app-masterworker app-pingpong app-tokenring async-yield async-waitall async-dsend
-         cloud-migration cloud-masterworker dht-chord dht-kademlia energy-consumption energy-pstate energy-vm hostload io-file io-storage
+         cloud-migration cloud-masterworker dht-chord dht-kademlia energy-consumption energy-pstate energy-vm hostload
          process-kill process-migration process-startkilltime process-suspend task-priority trace-pingpong)
   string (REPLACE "-" "/" example_dir ${example})
   set (srcdir ${CMAKE_CURRENT_SOURCE_DIR}/${example_dir})
@@ -40,17 +38,14 @@ foreach (example app-bittorrent app-centralizedmutex app-masterworker app-pingpo
   endforeach()
 
   if(enable_java)
-    add_custom_command(
-      COMMENT "Building java-${example}..."
-      OUTPUT ${example_dir}/java-${example}_compiled
-      DEPENDS ${example_sources} simgrid-java_jar ${SIMGRID_JAR}
-      COMMAND ${CMAKE_COMMAND} -E make_directory ${example_dir}
-      COMMAND ${JAVA_COMPILE} -classpath ${SIMGRID_JAR} -d ${CMAKE_CURRENT_BINARY_DIR} ${${example}_sources}
-      COMMAND ${CMAKE_COMMAND} -E remove ${example_dir}/java-${example}_compiled
-      COMMAND ${CMAKE_COMMAND} -E touch ${example_dir}/java-${example}_compiled
-    )
-    add_custom_target(java-${example} ALL DEPENDS ${example_dir}/java-${example}_compiled)
+    add_jar(java-${example} SOURCES ${${example}_sources}
+            INCLUDE_JARS ${SIMGRID_JAR}
+           OUTPUT_NAME ${example}
+           OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/${example_dir})
     add_dependencies(java-all java-${example})
+    
+    string (REPLACE "-" "/" example_dir ${example})
+    ADD_TESH(java-${example}  --setenv javacmd=${Java_JAVA_EXECUTABLE} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/deprecated/java --setenv LD_LIBRARY_PATH=${TESH_LIBRARY_PATH} --setenv classpath="${TESH_CLASSPATH}:${example}.jar" --cd ${CMAKE_BINARY_DIR}/examples/deprecated/java/${example_dir} ${CMAKE_HOME_DIRECTORY}/examples/deprecated/java/${example_dir}/${example}.tesh)
   endif()
   set(examples_src  ${examples_src}  ${${example}_sources})
   set(tesh_files    ${tesh_files}    ${CMAKE_CURRENT_SOURCE_DIR}/${example_dir}/${example}.tesh)
@@ -68,12 +63,3 @@ set(xml_files     ${xml_files}     ${CMAKE_CURRENT_SOURCE_DIR}/app/bittorrent/bi
                                    ${CMAKE_CURRENT_SOURCE_DIR}/dht/kademlia/kademlia.xml
                                    ${CMAKE_CURRENT_SOURCE_DIR}/process/startkilltime/startkilltime.xml
                                    ${CMAKE_CURRENT_SOURCE_DIR}/task/priority/priority.xml                  PARENT_SCOPE)
-
-if(enable_java)
-  foreach (example app-bittorrent app-centralizedmutex app-masterworker app-pingpong app-tokenring async-yield async-waitall async-dsend
-           cloud-migration cloud-masterworker dht-chord dht-kademlia energy-consumption energy-pstate energy-vm hostload io-file io-storage
-           process-kill process-migration process-startkilltime process-suspend task-priority trace-pingpong)
-    string (REPLACE "-" "/" example_dir ${example})
-    ADD_TESH(java-${example}  --setenv javacmd=${Java_JAVA_EXECUTABLE} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/deprecated/java --setenv LD_LIBRARY_PATH=${TESH_LIBRARY_PATH} --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/examples/deprecated/java/${example_dir} ${CMAKE_HOME_DIRECTORY}/examples/deprecated/java/${example_dir}/${example}.tesh)
-  endforeach()
-endif()