openjpeg/wrapping/java/openjp2/CMakeLists.txt

49 lines
1.3 KiB
CMake

#JavaOpenJPEG/CMakeLists.txt
# First thing define the common source:
set(openjpegjni_SRCS
JavaOpenJPEGDecoder.c
JavaOpenJPEG.c
)
# JNI binding:
find_package(JNI REQUIRED)
include_directories(${JNI_INCLUDE_DIRS})
# required header file:
include_directories(
${OPENJPEG_BINARY_DIR}/src/lib/openjp2 # opj_config.h
${OPENJPEG_SOURCE_DIR}/src/lib/openjp2
${OPENJPEG_SOURCE_DIR}/src/bin/common
${OPENJPEG_SOURCE_DIR}/src/bin/jp2
)
add_library(openjpegjni MODULE
${openjpegjni_SRCS}
)
# build jar:
find_package(Java 1.5 REQUIRED) # javac, jar
# build dep list:
file(GLOB java_srcs "java-sources/org/openJpeg/*.java")
# make sure target javac dir exists:
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/classes)
# Build java
add_custom_command(
OUTPUT ${LIBRARY_OUTPUT_PATH}/openjpeg.jar
COMMAND ${Java_JAVAC_EXECUTABLE} -sourcepath "${CMAKE_CURRENT_SOURCE_DIR}/java-sources"
${java_srcs} -d ${CMAKE_CURRENT_BINARY_DIR}/classes
COMMAND ${Java_JAR_EXECUTABLE} cvf ${LIBRARY_OUTPUT_PATH}/openjpeg.jar org
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/classes
DEPENDS ${java_srcs}
COMMENT "javac *.java; jar cvf -> openjpeg.jar"
)
# name the target
add_custom_target(OpenJPEGJavaJar ALL
DEPENDS ${LIBRARY_OUTPUT_PATH}/openjpeg.jar
COMMENT "building openjpeg.jar"
)