forked from timhutton/cmake-swig-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
44 lines (37 loc) · 1.02 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
cmake_minimum_required(VERSION 2.8)
find_package(SWIG REQUIRED)
find_package(Java REQUIRED)
find_package(JNI REQUIRED)
include(UseJava)
include(UseSWIG)
include_directories(${JNI_INCLUDE_DIRS})
set( CMAKE_SWIG_OUTDIR ${CMAKE_CURRENT_BINARY_DIR} )
# Build the C++ code into a dynamic library: example.dll (on Windows) or libexample.so (on Linux)
swig_add_module(
example
java
example.i
example.c
)
# For convenience we copy the dynamic library to the current build folder
add_custom_command(
TARGET example
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:example> ${CMAKE_CURRENT_BINARY_DIR}
)
# Build the Java code into ExampleJNI.jar
add_jar(
ExampleJNI
SOURCES
${CMAKE_SWIG_OUTDIR}/example.java
${CMAKE_SWIG_OUTDIR}/exampleJNI.java
)
add_dependencies( ExampleJNI example )
# Finally build the demonstration code into Main.jar
set(CMAKE_JAVA_JAR_ENTRY_POINT main)
add_jar(
Main
SOURCES main.java
ENTRY_POINT main
)
add_dependencies( Main ExampleJNI )