Blame view

morfeusz/wrappers/java/CMakeLists.txt 4.5 KB
Michał Lenart authored
1
Marcin Woliński authored
2
set (JMORFEUSZ_VERSION "${Morfeusz_LIB_VERSION}")
Michał Lenart authored
3
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
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
    get_filename_component (LIBMORFEUSZ_DIR ${CMAKE_CURRENT_BINARY_DIR} DIRECTORY)
    add_custom_target (jmorfeusz-repair-libmorfeusz-link
Jan Szejko authored
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
Michał Lenart authored
53
54
        DEPENDS libjmorfeusz)
    add_custom_target (jmorfeusz-repair-libjmorfeusz-id
Jan Szejko authored
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
Michał Lenart authored
58
59
        DEPENDS libjmorfeusz jmorfeusz-repair-libmorfeusz-link)
endif ()
Michał Lenart authored
60
Michał Lenart authored
61
# build jmorfeusz
Michał Lenart authored
62
file(GLOB_RECURSE JAVA_SOURCES "${JAVA_SRC_DIR}" "${JAVA_SRC_DIR}/*.java")
Michał Lenart authored
63
add_jar (jmorfeusz
Marcin Woliński authored
64
65
66
67
  SOURCES "${JAVA_SOURCES}"
  ENTRY_POINT pl/sgjp/morfeusz/app/App
  )
add_dependencies(jmorfeusz libjmorfeusz)
Michał Lenart authored
68
Michał Lenart authored
69
add_custom_target(generate-javadoc
Michał Lenart authored
70
    COMMAND javadoc
Marcin Woliński authored
71
        -d "${CMAKE_CURRENT_BINARY_DIR}/javadoc"
Michał Lenart authored
72
73
74
75
        -sourcepath "${CMAKE_CURRENT_BINARY_DIR}"
        -windowtitle "JMorfeusz - Morfeusz Java binding"
        -use
        -link http://docs.oracle.com/javase/7/docs/api/
Michał Lenart authored
76
        -charset utf8
Michał Lenart authored
77
        pl.sgjp.morfeusz
Michał Lenart authored
78
79
    DEPENDS jmorfeusz)
Michał Lenart authored
80
add_custom_target(package-javadoc
Marcin Woliński authored
81
    COMMAND mkdir -p "${TARGET_DIR}" && ${CMAKE_COMMAND} -E tar "cfvz" "${TARGET_DIR}/jmorfeusz-javadoc.tgz" "${CMAKE_CURRENT_BINARY_DIR}/javadoc"
Michał Lenart authored
82
    DEPENDS generate-javadoc)
Michał Lenart authored
83
Michał Lenart authored
84
85
86
87
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
    add_dependencies(jmorfeusz jmorfeusz-repair-libmorfeusz-link jmorfeusz-repair-libjmorfeusz-id)
endif ()
Michał Lenart authored
88
add_custom_target (jmorfeusz-copy-readme
Michał Lenart authored
89
90
    COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/README" "${CMAKE_CURRENT_BINARY_DIR}/README")
Michał Lenart authored
91
Michał Lenart authored
92
add_custom_target(package-java
Michał Lenart authored
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"
Michał Lenart authored
94
    DEPENDS jmorfeusz package-javadoc jmorfeusz-copy-readme libjmorfeusz)
Jan Szejko authored
95
96

if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
Marcin Woliński authored
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
    )
Jan Szejko authored
101
endif ()