|
1
|
|
|
2
|
set (JMORFEUSZ_VERSION "${Morfeusz_LIB_VERSION}")
|
|
3
|
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
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
get_filename_component (LIBMORFEUSZ_DIR ${CMAKE_CURRENT_BINARY_DIR} DIRECTORY)
add_custom_target (jmorfeusz-repair-libmorfeusz-link
|
|
48
49
50
51
52
|
COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/gui-libs
COMMAND ${INSTALL_NAME_TOOL} -change /usr/x86_64-apple-darwin9/x86_64-apple-darwin9/lib/libstdc++.6.dylib /usr/lib/libstdc++.6.dylib ${CMAKE_CURRENT_BINARY_DIR}/libjmorfeusz.jnilib
COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/libjmorfeusz.jnilib ${CMAKE_CURRENT_BINARY_DIR}/gui-libs/
# COMMAND ${INSTALL_NAME_TOOL} -change libmorfeusz2.dylib libmorfeusz2.dylib ${CMAKE_CURRENT_BINARY_DIR}/libjmorfeusz.jnilib
COMMAND ${INSTALL_NAME_TOOL} -change libmorfeusz2.dylib @executable_path/libmorfeusz2.dylib ${CMAKE_CURRENT_BINARY_DIR}/gui-libs/libjmorfeusz.jnilib
|
|
53
54
|
DEPENDS libjmorfeusz)
add_custom_target (jmorfeusz-repair-libjmorfeusz-id
|
|
55
56
57
|
COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/gui-libs
COMMAND ${INSTALL_NAME_TOOL} -id libjmorfeusz.jnilib ${CMAKE_CURRENT_BINARY_DIR}/libjmorfeusz.jnilib
COMMAND ${INSTALL_NAME_TOOL} -id @executable_path/libjmorfeusz.jnilib ${CMAKE_CURRENT_BINARY_DIR}/gui-libs/libjmorfeusz.jnilib
|
|
58
59
|
DEPENDS libjmorfeusz jmorfeusz-repair-libmorfeusz-link)
endif ()
|
|
60
|
|
|
61
|
# build jmorfeusz
|
|
62
|
file(GLOB_RECURSE JAVA_SOURCES "${JAVA_SRC_DIR}" "${JAVA_SRC_DIR}/*.java")
|
|
63
|
add_jar (jmorfeusz
|
|
64
65
66
67
|
SOURCES "${JAVA_SOURCES}"
ENTRY_POINT pl/sgjp/morfeusz/app/App
)
add_dependencies(jmorfeusz libjmorfeusz)
|
|
68
|
|
|
69
|
add_custom_target(generate-javadoc
|
|
70
|
COMMAND javadoc
|
|
71
|
-d "${CMAKE_CURRENT_BINARY_DIR}/javadoc"
|
|
72
73
74
75
|
-sourcepath "${CMAKE_CURRENT_BINARY_DIR}"
-windowtitle "JMorfeusz - Morfeusz Java binding"
-use
-link http://docs.oracle.com/javase/7/docs/api/
|
|
76
|
-charset utf8
|
|
77
|
pl.sgjp.morfeusz
|
|
78
79
|
DEPENDS jmorfeusz)
|
|
80
|
add_custom_target(package-javadoc
|
|
81
|
COMMAND mkdir -p "${TARGET_DIR}" && ${CMAKE_COMMAND} -E tar "cfvz" "${TARGET_DIR}/jmorfeusz-javadoc.tgz" "${CMAKE_CURRENT_BINARY_DIR}/javadoc"
|
|
82
|
DEPENDS generate-javadoc)
|
|
83
|
|
|
84
85
86
87
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
add_dependencies(jmorfeusz jmorfeusz-repair-libmorfeusz-link jmorfeusz-repair-libjmorfeusz-id)
endif ()
|
|
88
|
add_custom_target (jmorfeusz-copy-readme
|
|
89
90
|
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/README" "${CMAKE_CURRENT_BINARY_DIR}/README")
|
|
91
|
|
|
92
|
add_custom_target(package-java
|
|
93
|
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"
|
|
94
|
DEPENDS jmorfeusz package-javadoc jmorfeusz-copy-readme libjmorfeusz)
|
|
95
96
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
|
97
98
99
100
|
add_custom_target(java-deb
COMMAND "${PROJECT_SOURCE_DIR}/createJavaDeb.sh" "${CMAKE_CURRENT_BINARY_DIR}" "${Morfeusz_DEB_VERSION}" "${ARCHITECTURE}" "${TARGET_DIR}"
DEPENDS jmorfeusz libjmorfeusz
)
|
|
101
|
endif ()
|