CMakeLists.txt
1.92 KB
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
45
46
47
48
49
50
# SWIG
#set(CMAKE_SWIG_OUTDIR swig)
#FIND_PACKAGE(SWIG REQUIRED)
set (JMORFEUSZ_VERSION "0.1.0")
find_package(JNI REQUIRED)
#INCLUDE(${SWIG_USE_FILE})
include(UseJava)
find_package(Java REQUIRED)
# SWIG Java
include_directories (${JAVA_INCLUDE_PATH})
include_directories (${JAVA_INCLUDE_PATH2})
include_directories (..)
set (SWIG_JAVA_OUTFILE swigJAVA.cpp)
set (JAVA_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/pl/waw/ipipan/morfeusz")
add_custom_command (
OUTPUT ${SWIG_JAVA_OUTFILE}
COMMAND swig -java -c++ -package pl.waw.ipipan.morfeusz -o ${SWIG_JAVA_OUTFILE} -outdir ${JAVA_SRC_DIR} ${CMAKE_SOURCE_DIR}/morfeusz/morfeusz.i
DEPENDS libmorfeusz
)
add_library (libjmorfeusz SHARED ${SWIG_JAVA_OUTFILE})
set_target_properties (libjmorfeusz PROPERTIES OUTPUT_NAME "jmorfeusz")
target_link_libraries (libjmorfeusz ${JAVA_LIBRARIES} libmorfeusz)
add_dependencies (libjmorfeusz ${SWIG_JAVA_OUTFILE})
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set (CMAKE_SHARED_LINKER_FLAGS "-s -Os -static-libstdc++ -static-libgcc -D_JNI_IMPLEMENTATION_ -Wl,--kill-at")
endif ()
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set (CMAKE_SHARED_LIBRARY_SUFFIX ".jnilib")
endif ()
set (CMAKE_JAVA_TARGET_VERSION ${JMORFEUSZ_VERSION})
set (CMAKE_JAVA_TARGET_OUTPUT_NAME jmorfeusz)
# build jmorfeusz
file(GLOB_RECURSE JAVA_SOURCES ${JAVA_SRC_DIR} "*.java")
add_jar (jmorfeusz
SOURCES "${JAVA_SOURCES}"
DEPENDS libjmorfeusz)
add_custom_target(jmorfeusz-copy-readme
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/README" "${CMAKE_CURRENT_BINARY_DIR}/README")
add_custom_target(package-java
COMMAND mkdir -p "${TARGET_DIR}" && ${CMAKE_COMMAND} -E tar "cfvz" "${TARGET_DIR}/jmorfeusz-${JMORFEUSZ_VERSION}-${CMAKE_SYSTEM_NAME}-${ARCHITECTURE}.tar.gz" "${CMAKE_CURRENT_BINARY_DIR}/*.jar" "${CMAKE_CURRENT_BINARY_DIR}/*${CMAKE_SHARED_LIBRARY_SUFFIX}" "${CMAKE_CURRENT_BINARY_DIR}/README"
DEPENDS jmorfeusz jmorfeusz-copy-readme libjmorfeusz)