Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add a simgrid_java target to rebuild the jar file; look at the right location of...
[simgrid.git] / buildtools / Cmake / MakeJava.cmake
1 set(JAVA_FILES ${JMSG_JAVA_SRC})
2 set(JAVA_CLASSES ${JAVA_FILES})
3
4 string(REPLACE "src/java/" "${PROJECT_DIRECTORY}/src/java/"
5                JAVA_FILES "${JAVA_FILES}")
6
7 string(REPLACE "src/java/simgrid/msg" "${CMAKE_CURRENT_BINARY_DIR}/classes/simgrid/msg"
8                JAVA_CLASSES "${JAVA_CLASSES}")
9 string(REPLACE ".java" ".class;" 
10                JAVA_CLASSES "${JAVA_CLASSES}")
11                
12
13 add_custom_command(
14   OUTPUT  ${CMAKE_CURRENT_BINARY_DIR}/classes/
15   COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/classes/")
16   
17 ADD_CUSTOM_COMMAND(
18   TARGET clean
19   COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_CURRENT_BINARY_DIR}/classes/)
20
21 # compile all .java files with javac to .class
22 ADD_CUSTOM_COMMAND(
23   OUTPUT ${JAVA_CLASSES}
24   DEPENDS ${JAVA_FILES} ${CMAKE_CURRENT_BINARY_DIR}/classes/
25   COMMAND ${JAVA_COMPILE} -d ${CMAKE_CURRENT_BINARY_DIR}/classes/
26                           -cp ${CMAKE_CURRENT_BINARY_DIR}/classes/
27                           ${JAVA_FILES}
28   COMMENT "Compiling java sources of core library..."
29 )
30
31 ADD_CUSTOM_TARGET(simgrid_java ALL
32                   DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/simgrid.jar)
33
34 ADD_CUSTOM_COMMAND(
35   OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/simgrid.jar
36   DEPENDS ${JAVA_CLASSES}
37   WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/classes  
38   COMMAND ${JAVA_ARCHIVE} -cvf ${CMAKE_CURRENT_BINARY_DIR}/simgrid.jar .
39   COMMENT "Building simgrid.jar..."
40 )
41
42 ADD_CUSTOM_TARGET(java_basic ALL
43   COMMAND ${JAVA_COMPILE} -d ${PROJECT_DIRECTORY}/examples/java/basic -cp ${CMAKE_CURRENT_BINARY_DIR}/simgrid.jar ${PROJECT_DIRECTORY}/examples/java/basic/*.java
44   DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/simgrid.jar ${PROJECT_DIRECTORY}/examples/java/basic/*.java
45 )
46         
47 ADD_CUSTOM_TARGET(java_ping_pong ALL
48   COMMAND ${JAVA_COMPILE} -d ${PROJECT_DIRECTORY}/examples/java/ping_pong -cp ${CMAKE_CURRENT_BINARY_DIR}/simgrid.jar ${PROJECT_DIRECTORY}/examples/java/ping_pong/*.java
49   DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/simgrid.jar ${PROJECT_DIRECTORY}/examples/java/ping_pong/*.java
50 )
51         
52 ADD_CUSTOM_TARGET(java_comm_time ALL
53   COMMAND ${JAVA_COMPILE} -d ${PROJECT_DIRECTORY}/examples/java/comm_time -cp ${CMAKE_CURRENT_BINARY_DIR}/simgrid.jar ${PROJECT_DIRECTORY}/examples/java/comm_time/*.java
54   DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/simgrid.jar ${PROJECT_DIRECTORY}/examples/java/comm_time/*.java
55 )
56         
57 ADD_CUSTOM_TARGET(java_suspend ALL
58   COMMAND ${JAVA_COMPILE} -d ${PROJECT_DIRECTORY}/examples/java/suspend -cp ${CMAKE_CURRENT_BINARY_DIR}/simgrid.jar ${PROJECT_DIRECTORY}/examples/java/suspend/*.java
59   DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/simgrid.jar ${PROJECT_DIRECTORY}/examples/java/suspend/*.java
60 )