Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Change way for cleaning generated files.
[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 # compile all .java files with javac to .class
18 ADD_CUSTOM_COMMAND(
19   OUTPUT ${JAVA_CLASSES}
20   DEPENDS ${JAVA_FILES} ${CMAKE_CURRENT_BINARY_DIR}/classes/
21   COMMAND ${JAVA_COMPILE} -d ${CMAKE_CURRENT_BINARY_DIR}/classes/
22                           -cp ${CMAKE_CURRENT_BINARY_DIR}/classes/
23                           ${JAVA_FILES}
24   COMMENT "Compiling java sources of core library..."
25 )
26
27 ADD_CUSTOM_TARGET(simgrid_java ALL
28                   DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/simgrid.jar simgrid)
29
30 ADD_CUSTOM_COMMAND(
31   OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/simgrid.jar
32   DEPENDS ${JAVA_CLASSES}
33   WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/classes  
34   COMMAND ${JAVA_ARCHIVE} -cvf ${CMAKE_CURRENT_BINARY_DIR}/simgrid.jar .
35   COMMENT "Building simgrid.jar..."
36 )
37
38 ADD_CUSTOM_COMMAND(
39         OUTPUT  ${PROJECT_DIRECTORY}/examples/java/basic/BasicTest.class
40                         ${PROJECT_DIRECTORY}/examples/java/basic/FinalizeTask.class
41                         ${PROJECT_DIRECTORY}/examples/java/basic/Forwarder.class
42                         ${PROJECT_DIRECTORY}/examples/java/basic/Slave.class
43                         ${PROJECT_DIRECTORY}/examples/java/basic/Master.class
44                         ${PROJECT_DIRECTORY}/examples/java/ping_pong/PingPongTest.class
45                         ${PROJECT_DIRECTORY}/examples/java/ping_pong/Sender.class
46                         ${PROJECT_DIRECTORY}/examples/java/ping_pong/PingPongTask.class
47                         ${PROJECT_DIRECTORY}/examples/java/ping_pong/Receiver.class
48                         ${PROJECT_DIRECTORY}/examples/java/comm_time/FinalizeTask.class
49                         ${PROJECT_DIRECTORY}/examples/java/comm_time/CommTimeTest.class
50                         ${PROJECT_DIRECTORY}/examples/java/comm_time/Slave.class
51                         ${PROJECT_DIRECTORY}/examples/java/comm_time/Master.class
52                         ${PROJECT_DIRECTORY}/examples/java/suspend/SuspendTest.class
53                         ${PROJECT_DIRECTORY}/examples/java/suspend/LazyGuy.class
54                         ${PROJECT_DIRECTORY}/examples/java/suspend/DreamMaster.class
55                         
56         DEPENDS simgrid
57             ${CMAKE_CURRENT_BINARY_DIR}/simgrid.jar
58                         ${PROJECT_DIRECTORY}/examples/java/basic/*.java
59                         ${PROJECT_DIRECTORY}/examples/java/ping_pong/*.java
60                         ${PROJECT_DIRECTORY}/examples/java/comm_time/*.java
61                         ${PROJECT_DIRECTORY}/examples/java/suspend/*.java
62                         
63         COMMENT "Build examples for java"       
64         
65         COMMAND ${JAVA_COMPILE} -d ${PROJECT_DIRECTORY}/examples/java/basic -cp ${CMAKE_CURRENT_BINARY_DIR}/simgrid.jar ${PROJECT_DIRECTORY}/examples/java/basic/*.java  
66         COMMAND ${JAVA_COMPILE} -d ${PROJECT_DIRECTORY}/examples/java/ping_pong -cp ${CMAKE_CURRENT_BINARY_DIR}/simgrid.jar ${PROJECT_DIRECTORY}/examples/java/ping_pong/*.java
67         COMMAND ${JAVA_COMPILE} -d ${PROJECT_DIRECTORY}/examples/java/comm_time -cp ${CMAKE_CURRENT_BINARY_DIR}/simgrid.jar ${PROJECT_DIRECTORY}/examples/java/comm_time/*.java
68         COMMAND ${JAVA_COMPILE} -d ${PROJECT_DIRECTORY}/examples/java/suspend -cp ${CMAKE_CURRENT_BINARY_DIR}/simgrid.jar ${PROJECT_DIRECTORY}/examples/java/suspend/*.java
69 )
70
71 ADD_CUSTOM_TARGET(simgrid_java_examples ALL
72                   DEPENDS       ${PROJECT_DIRECTORY}/examples/java/basic/BasicTest.class
73                                                         ${PROJECT_DIRECTORY}/examples/java/basic/FinalizeTask.class
74                                                         ${PROJECT_DIRECTORY}/examples/java/basic/Forwarder.class
75                                                         ${PROJECT_DIRECTORY}/examples/java/basic/Slave.class
76                                                         ${PROJECT_DIRECTORY}/examples/java/basic/Master.class
77                                                         ${PROJECT_DIRECTORY}/examples/java/ping_pong/PingPongTest.class
78                                                         ${PROJECT_DIRECTORY}/examples/java/ping_pong/Sender.class
79                                                         ${PROJECT_DIRECTORY}/examples/java/ping_pong/PingPongTask.class
80                                                         ${PROJECT_DIRECTORY}/examples/java/ping_pong/Receiver.class
81                                                         ${PROJECT_DIRECTORY}/examples/java/comm_time/FinalizeTask.class
82                                                         ${PROJECT_DIRECTORY}/examples/java/comm_time/CommTimeTest.class
83                                                         ${PROJECT_DIRECTORY}/examples/java/comm_time/Slave.class
84                                                         ${PROJECT_DIRECTORY}/examples/java/comm_time/Master.class
85                                                         ${PROJECT_DIRECTORY}/examples/java/suspend/SuspendTest.class
86                                                         ${PROJECT_DIRECTORY}/examples/java/suspend/LazyGuy.class
87                                                         ${PROJECT_DIRECTORY}/examples/java/suspend/DreamMaster.class
88 )