Blame view

morfeusz/wrappers/java/CMakeLists.txt 3.52 KB
Michał Lenart authored
1
Michał Lenart authored
2
3
set (JMORFEUSZ_VERSION "0.1.0")
find_package(JNI REQUIRED)
Michał Lenart authored
4
include(UseJava)
Michał Lenart authored
5
find_package(Java REQUIRED)
Michał Lenart authored
6
Michał Lenart authored
7
8
include_directories (${JAVA_INCLUDE_PATH})
include_directories (${JAVA_INCLUDE_PATH2})
Michał Lenart authored
9
include_directories (${CMAKE_SOURCE_DIR}/morfeusz)
Michał Lenart authored
10
Michał Lenart authored
11
set (SWIG_JAVA_OUTFILE "${CMAKE_CURRENT_BINARY_DIR}/swigJAVA.cpp")
Michał Lenart authored
12
file (COPY pl DESTINATION .)
Michał Lenart authored
13
Michał Lenart authored
14
set (JAVA_SRC_DIR "${CMAKE_CURRENT_BINARY_DIR}/pl/sgjp/morfeusz")
Michał Lenart authored
15
Michał Lenart authored
16
17
add_custom_command (
    OUTPUT ${SWIG_JAVA_OUTFILE}
Michał Lenart authored
18
    COMMAND swig -java -c++ -package pl.sgjp.morfeusz  -o ${SWIG_JAVA_OUTFILE} -outdir ${JAVA_SRC_DIR} ${CMAKE_SOURCE_DIR}/morfeusz/wrappers/morfeusz.i
Michał Lenart authored
19
20
    DEPENDS libmorfeusz
)
Michał Lenart authored
21
add_custom_target(generate-java-wrapper ALL
Michał Lenart authored
22
    DEPENDS ${SWIG_JAVA_OUTFILE})
Michał Lenart authored
23
Michał Lenart authored
24
add_library (libjmorfeusz SHARED ${SWIG_JAVA_OUTFILE})
Michał Lenart authored
25
add_dependencies (libjmorfeusz generate_java_wrapper)
Michał Lenart authored
26
27
set_target_properties (libjmorfeusz PROPERTIES OUTPUT_NAME "jmorfeusz")
target_link_libraries (libjmorfeusz ${JAVA_LIBRARIES} libmorfeusz)
Michał Lenart authored
28
29
30
31

if ( CMAKE_COMPILER_IS_GNUCC )
    set_property( TARGET libjmorfeusz APPEND_STRING PROPERTY COMPILE_FLAGS -w )
endif ( CMAKE_COMPILER_IS_GNUCC )
Michał Lenart authored
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 ()
Michał Lenart authored
36
Michał Lenart authored
37
38
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
    set (CMAKE_SHARED_LIBRARY_SUFFIX ".jnilib")
Michał Lenart authored
39
    #~ set (CMAKE_SHARED_LINKER_FLAGS "${-dylib")
Michał Lenart authored
40
endif ()
Michał Lenart authored
41
Michał Lenart authored
42
43
44
set (CMAKE_JAVA_TARGET_VERSION ${JMORFEUSZ_VERSION})
set (CMAKE_JAVA_TARGET_OUTPUT_NAME jmorfeusz)
Michał Lenart authored
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 ()
Michał Lenart authored
54
Michał Lenart authored
55
# build jmorfeusz
Michał Lenart authored
56
file(GLOB_RECURSE JAVA_SOURCES "${JAVA_SRC_DIR}" "${JAVA_SRC_DIR}/*.java")
Michał Lenart authored
57
add_jar (jmorfeusz
Michał Lenart authored
58
    SOURCES "${JAVA_SOURCES}"
Michał Lenart authored
59
    ENTRY_POINT pl/sgjp/morfeusz/app/App
Michał Lenart authored
60
61
    DEPENDS libjmorfeusz generate-java-wrapper)
Michał Lenart authored
62
add_custom_target(generate-javadoc
Michał Lenart authored
63
    COMMAND javadoc
Michał Lenart authored
64
        -d "${TARGET_DIR}/javadoc"
Michał Lenart authored
65
66
67
68
        -sourcepath "${CMAKE_CURRENT_BINARY_DIR}"
        -windowtitle "JMorfeusz - Morfeusz Java binding"
        -use
        -link http://docs.oracle.com/javase/7/docs/api/
Michał Lenart authored
69
        -charset utf8
Michał Lenart authored
70
        pl.sgjp.morfeusz
Michał Lenart authored
71
72
    DEPENDS jmorfeusz)
Michał Lenart authored
73
add_custom_target(package-javadoc
Michał Lenart authored
74
    COMMAND mkdir -p "${TARGET_DIR}" && ${CMAKE_COMMAND} -E tar "cfvz" "${TARGET_DIR}/javadoc.tgz" "${TARGET_DIR}/javadoc"
Michał Lenart authored
75
    DEPENDS generate-javadoc)
Michał Lenart authored
76
Michał Lenart authored
77
78
79
80
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
    add_dependencies(jmorfeusz jmorfeusz-repair-libmorfeusz-link jmorfeusz-repair-libjmorfeusz-id)
endif ()
Michał Lenart authored
81
add_custom_target (jmorfeusz-copy-readme
Michał Lenart authored
82
83
    COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/README" "${CMAKE_CURRENT_BINARY_DIR}/README")
Michał Lenart authored
84
Michał Lenart authored
85
add_custom_target(package-java
Michał Lenart authored
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"
Michał Lenart authored
87
    DEPENDS jmorfeusz package-javadoc jmorfeusz-copy-readme libjmorfeusz)