|
1
|
|
|
2
3
|
set (JMORFEUSZ_VERSION "0.1.0")
find_package(JNI REQUIRED)
|
|
4
|
include(UseJava)
|
|
5
|
find_package(Java REQUIRED)
|
|
6
|
|
|
7
8
|
include_directories (${JAVA_INCLUDE_PATH})
include_directories (${JAVA_INCLUDE_PATH2})
|
|
9
|
include_directories (${CMAKE_SOURCE_DIR}/morfeusz)
|
|
10
|
|
|
11
|
set (SWIG_JAVA_OUTFILE "${CMAKE_CURRENT_BINARY_DIR}/swigJAVA.cpp")
|
|
12
|
file (COPY pl DESTINATION .)
|
|
13
|
|
|
14
|
set (JAVA_SRC_DIR "${CMAKE_CURRENT_BINARY_DIR}/pl/sgjp/morfeusz")
|
|
15
|
|
|
16
17
|
add_custom_command (
OUTPUT ${SWIG_JAVA_OUTFILE}
|
|
18
|
COMMAND swig -java -c++ -package pl.sgjp.morfeusz -o ${SWIG_JAVA_OUTFILE} -outdir ${JAVA_SRC_DIR} ${CMAKE_SOURCE_DIR}/morfeusz/wrappers/morfeusz.i
|
|
19
20
|
DEPENDS libmorfeusz
)
|
|
21
|
add_custom_target(generate-java-wrapper ALL
|
|
22
|
DEPENDS ${SWIG_JAVA_OUTFILE})
|
|
23
|
|
|
24
|
add_library (libjmorfeusz SHARED ${SWIG_JAVA_OUTFILE})
|
|
25
|
add_dependencies (libjmorfeusz generate_java_wrapper)
|
|
26
27
|
set_target_properties (libjmorfeusz PROPERTIES OUTPUT_NAME "jmorfeusz")
target_link_libraries (libjmorfeusz ${JAVA_LIBRARIES} libmorfeusz)
|
|
28
29
30
31
|
if ( CMAKE_COMPILER_IS_GNUCC )
set_property( TARGET libjmorfeusz APPEND_STRING PROPERTY COMPILE_FLAGS -w )
endif ( CMAKE_COMPILER_IS_GNUCC )
|
|
32
33
34
35
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set (CMAKE_SHARED_LINKER_FLAGS "-s -Os -static-libstdc++ -static-libgcc -D_JNI_IMPLEMENTATION_ -Wl,--kill-at")
endif ()
|
|
36
|
|
|
37
38
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set (CMAKE_SHARED_LIBRARY_SUFFIX ".jnilib")
|
|
39
|
#~ set (CMAKE_SHARED_LINKER_FLAGS "${-dylib")
|
|
40
|
endif ()
|
|
41
|
|
|
42
43
44
|
set (CMAKE_JAVA_TARGET_VERSION ${JMORFEUSZ_VERSION})
set (CMAKE_JAVA_TARGET_OUTPUT_NAME jmorfeusz)
|
|
45
46
47
48
49
50
51
52
53
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
get_filename_component (LIBMORFEUSZ_DIR ${CMAKE_CURRENT_BINARY_DIR} DIRECTORY)
add_custom_target (jmorfeusz-repair-libmorfeusz-link
COMMAND ${INSTALL_NAME_TOOL} -change ${LIBMORFEUSZ_DIR}/libmorfeusz2.dylib libmorfeusz2.dylib ${CMAKE_CURRENT_BINARY_DIR}/libjmorfeusz.jnilib
DEPENDS libjmorfeusz)
add_custom_target (jmorfeusz-repair-libjmorfeusz-id
COMMAND ${INSTALL_NAME_TOOL} -id libjmorfeusz.jnilib ${CMAKE_CURRENT_BINARY_DIR}/libjmorfeusz.jnilib
DEPENDS libjmorfeusz jmorfeusz-repair-libmorfeusz-link)
endif ()
|
|
54
|
|
|
55
|
# build jmorfeusz
|
|
56
|
file(GLOB_RECURSE JAVA_SOURCES "${JAVA_SRC_DIR}" "${JAVA_SRC_DIR}/*.java")
|
|
57
|
add_jar (jmorfeusz
|
|
58
|
SOURCES "${JAVA_SOURCES}"
|
|
59
|
ENTRY_POINT pl/sgjp/morfeusz/app/App
|
|
60
61
|
DEPENDS libjmorfeusz generate-java-wrapper)
|
|
62
|
add_custom_target(generate-javadoc
|
|
63
|
COMMAND javadoc
|
|
64
|
-d "${TARGET_DIR}/javadoc"
|
|
65
66
67
68
|
-sourcepath "${CMAKE_CURRENT_BINARY_DIR}"
-windowtitle "JMorfeusz - Morfeusz Java binding"
-use
-link http://docs.oracle.com/javase/7/docs/api/
|
|
69
|
-charset utf8
|
|
70
|
pl.sgjp.morfeusz
|
|
71
72
|
DEPENDS jmorfeusz)
|
|
73
|
add_custom_target(package-javadoc
|
|
74
|
COMMAND mkdir -p "${TARGET_DIR}" && ${CMAKE_COMMAND} -E tar "cfvz" "${TARGET_DIR}/javadoc.tgz" "${TARGET_DIR}/javadoc"
|
|
75
|
DEPENDS generate-javadoc)
|
|
76
|
|
|
77
78
79
80
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
add_dependencies(jmorfeusz jmorfeusz-repair-libmorfeusz-link jmorfeusz-repair-libjmorfeusz-id)
endif ()
|
|
81
|
add_custom_target (jmorfeusz-copy-readme
|
|
82
83
|
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/README" "${CMAKE_CURRENT_BINARY_DIR}/README")
|
|
84
|
|
|
85
|
add_custom_target(package-java
|
|
86
|
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"
|
|
87
|
DEPENDS jmorfeusz package-javadoc jmorfeusz-copy-readme libjmorfeusz)
|