Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove old script to launch java examples.
[simgrid.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.8)
2 project(simgrid-java C)
3 set(UPDATE_TYPE svn)
4 set(CMAKE_C_FLAGS "" CACHE TYPE INTERNAL FORCE)
5 set(CMAKE_EXE_LINKER_FLAGS "" CACHE TYPE INTERNAL FORCE)
6 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_HOME_DIRECTORY}/lib")
7
8
9 set(soversion 1)
10 ###############################
11 # Test the build dependencies #
12 ###############################
13 include(FindSimGrid.cmake)
14 include(FindJavaSG.cmake)
15
16 ###############################
17 # Declare our package content #
18 ###############################
19 set(JMSG_C_SRC
20         src/smx_context_java.h
21         src/smx_context_java.c
22         src/jxbt_utilities.c
23         src/jxbt_utilities.h
24         src/jmsg.c 
25         src/jmsg.h
26         src/jmsg_host.c
27         src/jmsg_host.h
28         src/jmsg_process.c
29         src/jmsg_process.h
30         src/jmsg_task.c
31         src/jmsg_task.h
32         src/jmsg_application_handler.c
33         src/jmsg_application_handler.h
34 )
35
36 set(JMSG_JAVA_SRC
37         org/simgrid/msg/ApplicationHandler.java
38         org/simgrid/msg/Host.java
39         org/simgrid/msg/HostFailureException.java       
40         org/simgrid/msg/HostNotFoundException.java      
41         org/simgrid/msg/JniException.java
42         org/simgrid/msg/Msg.java
43         org/simgrid/msg/MsgException.java
44         org/simgrid/msg/MsgNative.java
45         org/simgrid/msg/NativeException.java
46         org/simgrid/msg/Process.java
47         org/simgrid/msg/ProcessNotFoundException.java
48         org/simgrid/msg/Sem.java
49         org/simgrid/msg/Task.java
50         org/simgrid/msg/TaskCancelledException.java
51         org/simgrid/msg/TimeoutException.java
52         org/simgrid/msg/TransferFailureException.java   
53 )
54
55 set(JAVA_EXAMPLES
56         examples/mutualExclusion/centralized/MutexCentral.java
57         examples/mutualExclusion/centralized/GrantTask.java
58         examples/mutualExclusion/centralized/Coordinator.java
59         examples/mutualExclusion/centralized/ReleaseTask.java
60         examples/mutualExclusion/centralized/Node.java
61         examples/mutualExclusion/centralized/RequestTask.java
62         examples/basic/FinalizeTask.java
63         examples/basic/Forwarder.java
64         examples/basic/Master.java
65         examples/basic/BasicTest.java
66         examples/basic/Slave.java
67         examples/commTime/FinalizeTask.java
68         examples/commTime/Master.java
69         examples/commTime/Slave.java
70         examples/commTime/CommTimeTest.java
71         examples/pingPong/PingPongTask.java
72         examples/pingPong/Sender.java
73         examples/pingPong/Receiver.java
74         examples/pingPong/PingPongTest.java
75 )
76
77 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g -Wall -Wunused -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wchar-subscripts -Wcomment -Wformat -Wwrite-strings -Wno-unused-function -Wno-unused-parameter -Wno-strict-aliasing -Wno-format-nonliteral -Werror ")
78
79 set(INCLUDE_PATH "-I${CMAKE_HOME_DIRECTORY}/src -I$ENV{SIMGRID_ROOT}/include -I$ENV{SIMGRID_ROOT}/src -I$ENV{SIMGRID_ROOT}/src/include")
80 set(LIB_PATH "-L$ENV{SIMGRID_ROOT}/lib")
81
82 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${INCLUDE_PATH} ${LIB_PATH}")
83
84 string(REPLACE "org/" "${CMAKE_HOME_DIRECTORY}/org/" JAVA_FILES "${JMSG_JAVA_SRC}") 
85
86 string(REPLACE "org/" "${CMAKE_HOME_DIRECTORY}/classes/org/" JMSG_JAVA_SRC_CLASS "${JMSG_JAVA_SRC}")
87 string(REPLACE ".java" ".class" JMSG_JAVA_SRC_CLASS "${JMSG_JAVA_SRC_CLASS}")
88
89 string(REPLACE "examples/" "${CMAKE_HOME_DIRECTORY}/examples/" JAVA_EXAMPLES_CLASS "${JAVA_EXAMPLES}") 
90 string(REPLACE ".java" ".class" JAVA_EXAMPLES_CLASS "${JAVA_EXAMPLES_CLASS}")
91
92 # TARGET SG_java
93 add_library(SG_java SHARED ${JMSG_C_SRC})
94 target_link_libraries(SG_java -lsimgrid)
95 set_target_properties(SG_java PROPERTIES VERSION ${soversion})
96   
97 # TARGET java_classes
98 add_custom_command(
99         OUTPUT  ${JMSG_JAVA_SRC_CLASS}
100         DEPENDS ${JMSG_JAVA_SRC}
101         COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_HOME_DIRECTORY}/classes/"
102         COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/classes/
103                                         -cp ${CMAKE_HOME_DIRECTORY}/classes/ ${JAVA_FILES}
104         COMMENT "Compiling java sources of core library..."                                     
105 )
106 add_custom_target(java_classes ALL
107   DEPENDS ${JMSG_JAVA_SRC_CLASS}                
108 )
109
110 # TARGET simgrid_jar
111 add_custom_target(simgrid_jar ALL
112   COMMAND ${JAVA_ARCHIVE} -cvf ${CMAKE_HOME_DIRECTORY}/simgrid.jar .
113   COMMENT "Building simgrid.jar..."
114   WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/classes 
115 )
116
117 # TARGET simgrid_java_examples
118 add_custom_command(
119         COMMENT "Build examples for java"
120         OUTPUT  ${JAVA_EXAMPLES_CLASS}
121         
122         COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/basic/*.java  
123         COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/pingPong/*.java
124         COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/commTime/*.java
125         COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/centralized/*.java                                 
126 )
127 add_custom_target(simgrid_java_examples ALL
128         DEPENDS ${JAVA_EXAMPLES_CLASS}
129 )
130
131 # Declare dependencies
132 add_dependencies(simgrid_jar java_classes)
133 add_dependencies(simgrid_java_examples simgrid_jar SG_java)
134
135 SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES
136 ${CMAKE_HOME_DIRECTORY}/simgrid.jar
137 )
138
139 #####################
140 # Declare our tests #
141 #####################
142 INCLUDE(CTest)
143 ENABLE_TESTING()
144
145 ADD_TEST(java-basic
146 java -cp .:${CMAKE_HOME_DIRECTORY}/examples:${CMAKE_HOME_DIRECTORY}/simgrid.jar basic/BasicTest ${CMAKE_HOME_DIRECTORY}/examples/platform.xml ${CMAKE_HOME_DIRECTORY}/examples/basic/basicDeployment.xml
147 )
148 ADD_TEST(java-pingPong
149 java -cp .:${CMAKE_HOME_DIRECTORY}/examples:${CMAKE_HOME_DIRECTORY}/simgrid.jar pingPong/PingPongTest ${CMAKE_HOME_DIRECTORY}/examples/platform.xml ${CMAKE_HOME_DIRECTORY}/examples/pingPong/pingPongDeployment.xml
150 )
151
152 ##########################################
153 # Set the  LD_LIBRARY_PATH for our tests #
154 ##########################################
155 message(STATUS "export LD_LIBRARY_PATH=${CMAKE_HOME_DIRECTORY}/lib:$ENV{LD_LIBRARY_PATH}")
156
157 set_tests_properties(java-basic java-pingPong
158 PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_HOME_DIRECTORY}/lib:$ENV{LD_LIBRARY_PATH}")