Blame view

morfeusz/java/CMakeLists.txt 3.03 KB
Michał Lenart authored
1
2
# SWIG
#set(CMAKE_SWIG_OUTDIR swig)
Michał Lenart authored
3
#FIND_PACKAGE(SWIG REQUIRED)
Michał Lenart authored
4
5
set (JMORFEUSZ_VERSION "0.1.0")
find_package(JNI REQUIRED)
Michał Lenart authored
6
#INCLUDE(${SWIG_USE_FILE})
Michał Lenart authored
7
include(UseJava)
Michał Lenart authored
8
find_package(Java REQUIRED)
Michał Lenart authored
9
10

# SWIG Java
Michał Lenart authored
11
12
13
14
15
include_directories (${JAVA_INCLUDE_PATH})
include_directories (${JAVA_INCLUDE_PATH2})
include_directories (..)

set (SWIG_JAVA_OUTFILE swigJAVA.cpp)
Michał Lenart authored
16
set (JAVA_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/pl/waw/ipipan/morfeusz")
Michał Lenart authored
17
18
add_custom_command ( 
    OUTPUT ${SWIG_JAVA_OUTFILE}
Michał Lenart authored
19
    COMMAND swig -java -c++ -package pl.waw.ipipan.morfeusz  -o ${SWIG_JAVA_OUTFILE} -outdir ${JAVA_SRC_DIR} ${CMAKE_SOURCE_DIR}/morfeusz/morfeusz.i
Michał Lenart authored
20
21
    DEPENDS libmorfeusz
)
Michał Lenart authored
22
Michał Lenart authored
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})
Michał Lenart authored
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 ()
Michał Lenart authored
31
Michał Lenart authored
32
33
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
    set (CMAKE_SHARED_LIBRARY_SUFFIX ".jnilib")
Michał Lenart authored
34
    #~ set (CMAKE_SHARED_LINKER_FLAGS "${-dylib")
Michał Lenart authored
35
endif ()
Michał Lenart authored
36
Michał Lenart authored
37
38
39
set (CMAKE_JAVA_TARGET_VERSION ${JMORFEUSZ_VERSION})
set (CMAKE_JAVA_TARGET_OUTPUT_NAME jmorfeusz)
Michał Lenart authored
40
41
42
43
44
45
46
47
48
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
49
50
51
52
#~ add_custom_target (jmorfeusz-repair-library
    #~ COMMAND ${DARWIN64_ROOT}/x86_64-apple-darwin9/bin/x86_64-apple-darwin9-install_name_tool -change /home/mlenart/xxx/morfeusz/buildall/build-Darwin-amd64/morfeusz/libmorfeusz2.dylib morfeusz2 ${PROJECT_BINARY_DIR}/morfeusz/java/libjmorfeusz.jnilib
    #~ DEPENDS libjmorfeusz)
Michał Lenart authored
53
# build jmorfeusz
Michał Lenart authored
54
file(GLOB_RECURSE JAVA_SOURCES ${JAVA_SRC_DIR} "*.java")
Michał Lenart authored
55
add_jar (jmorfeusz
Michał Lenart authored
56
57
    SOURCES "${JAVA_SOURCES}"
    DEPENDS libjmorfeusz)
Michał Lenart authored
58
Michał Lenart authored
59
60
61
62
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
    add_dependencies(jmorfeusz jmorfeusz-repair-libmorfeusz-link jmorfeusz-repair-libjmorfeusz-id)
endif ()
Michał Lenart authored
63
add_custom_target (jmorfeusz-copy-readme
Michał Lenart authored
64
65
    COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/README" "${CMAKE_CURRENT_BINARY_DIR}/README")
Michał Lenart authored
66
Michał Lenart authored
67
add_custom_target(package-java
Michał Lenart authored
68
    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
69
    DEPENDS jmorfeusz jmorfeusz-copy-readme libjmorfeusz)