|
1
2
|
# SWIG
#set(CMAKE_SWIG_OUTDIR swig)
|
|
3
|
#FIND_PACKAGE(SWIG REQUIRED)
|
|
4
5
|
set (JMORFEUSZ_VERSION "0.1.0")
find_package(JNI REQUIRED)
|
|
6
|
#INCLUDE(${SWIG_USE_FILE})
|
|
7
|
include(UseJava)
|
|
8
|
find_package(Java REQUIRED)
|
|
9
10
|
# SWIG Java
|
|
11
12
13
14
15
|
include_directories (${JAVA_INCLUDE_PATH})
include_directories (${JAVA_INCLUDE_PATH2})
include_directories (..)
set (SWIG_JAVA_OUTFILE swigJAVA.cpp)
|
|
16
|
set (JAVA_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/pl/waw/ipipan/morfeusz")
|
|
17
18
|
add_custom_command (
OUTPUT ${SWIG_JAVA_OUTFILE}
|
|
19
|
COMMAND swig -java -c++ -package pl.waw.ipipan.morfeusz -o ${SWIG_JAVA_OUTFILE} -outdir ${JAVA_SRC_DIR} ${CMAKE_SOURCE_DIR}/morfeusz/morfeusz.i
|
|
20
21
|
DEPENDS libmorfeusz
)
|
|
22
|
|
|
23
24
25
26
|
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})
|
|
27
28
29
30
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set (CMAKE_SHARED_LINKER_FLAGS "-s -Os -static-libstdc++ -static-libgcc -D_JNI_IMPLEMENTATION_ -Wl,--kill-at")
endif ()
|
|
31
|
|
|
32
33
34
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set (CMAKE_SHARED_LIBRARY_SUFFIX ".jnilib")
endif ()
|
|
35
|
|
|
36
37
38
|
set (CMAKE_JAVA_TARGET_VERSION ${JMORFEUSZ_VERSION})
set (CMAKE_JAVA_TARGET_OUTPUT_NAME jmorfeusz)
|
|
39
|
# build jmorfeusz
|
|
40
|
file(GLOB_RECURSE JAVA_SOURCES ${JAVA_SRC_DIR} "*.java")
|
|
41
|
add_jar (jmorfeusz
|
|
42
43
|
SOURCES "${JAVA_SOURCES}"
DEPENDS libjmorfeusz)
|
|
44
|
|
|
45
46
47
|
add_custom_target(jmorfeusz-copy-readme
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/README" "${CMAKE_CURRENT_BINARY_DIR}/README")
|
|
48
|
add_custom_target(package-java
|
|
49
|
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"
|
|
50
|
DEPENDS jmorfeusz jmorfeusz-copy-readme libjmorfeusz)
|