• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1find_package(Java REQUIRED)
2find_package(JNI REQUIRED)
3
4# Allow the Java compiler flags to be set using an environment variable
5if(NOT DEFINED CMAKE_JAVA_COMPILE_FLAGS AND DEFINED ENV{JAVAFLAGS})
6  set(CMAKE_JAVA_COMPILE_FLAGS $ENV{JAVAFLAGS})
7endif()
8
9include(UseJava)
10
11set(CMAKE_JAVA_COMPILE_FLAGS "${CMAKE_JAVA_COMPILE_FLAGS} -J-Dfile.encoding=UTF8")
12message(STATUS "CMAKE_JAVA_COMPILE_FLAGS = ${CMAKE_JAVA_COMPILE_FLAGS}")
13string(REGEX REPLACE " " ";" CMAKE_JAVA_COMPILE_FLAGS "${CMAKE_JAVA_COMPILE_FLAGS}")
14
15set(JAVAARGS "" CACHE STRING "Additional arguments to pass to java when running unit tests (example: -d32)")
16message(STATUS "JAVAARGS = ${JAVAARGS}")
17
18set(JAVA_SOURCES org/libjpegturbo/turbojpeg/TJ.java
19  org/libjpegturbo/turbojpeg/TJCompressor.java
20  org/libjpegturbo/turbojpeg/TJCustomFilter.java
21  org/libjpegturbo/turbojpeg/TJDecompressor.java
22  org/libjpegturbo/turbojpeg/TJException.java
23  org/libjpegturbo/turbojpeg/TJScalingFactor.java
24  org/libjpegturbo/turbojpeg/TJTransform.java
25  org/libjpegturbo/turbojpeg/TJTransformer.java
26  org/libjpegturbo/turbojpeg/YUVImage.java
27  TJUnitTest.java
28  TJExample.java
29  TJBench.java)
30
31set(TURBOJPEG_DLL_NAME "turbojpeg")
32if(MINGW)
33  set(TURBOJPEG_DLL_NAME "libturbojpeg")
34endif()
35if(WIN32)
36  configure_file(org/libjpegturbo/turbojpeg/TJLoader-win.java.in
37    ${CMAKE_CURRENT_BINARY_DIR}/org/libjpegturbo/turbojpeg/TJLoader.java)
38else()
39  configure_file(org/libjpegturbo/turbojpeg/TJLoader-unix.java.in
40    ${CMAKE_CURRENT_BINARY_DIR}/org/libjpegturbo/turbojpeg/TJLoader.java)
41endif()
42set(JAVA_SOURCES ${JAVA_SOURCES}
43  ${CMAKE_CURRENT_BINARY_DIR}/org/libjpegturbo/turbojpeg/TJLoader.java)
44
45if(MSYS)
46  # UGLY HACK ALERT: If we don't do this, then UseJava.cmake will separate
47  # class path members with a semicolon, which is interpreted as a command
48  # separator by the MSYS shell.
49  set(CMAKE_HOST_SYSTEM_NAME_BAK ${CMAKE_HOST_SYSTEM_NAME})
50  set(CMAKE_HOST_SYSTEM_NAME "MSYS")
51endif()
52add_jar(turbojpeg-java ${JAVA_SOURCES} OUTPUT_NAME turbojpeg
53  ENTRY_POINT TJExample)
54if(MSYS)
55  set(CMAKE_HOST_SYSTEM_NAME ${CMAKE_HOST_SYSTEM_NAME_BAK})
56endif()
57
58add_custom_target(javadoc COMMAND
59  javadoc -notimestamp -d ${CMAKE_CURRENT_SOURCE_DIR}/doc -sourcepath ${CMAKE_CURRENT_SOURCE_DIR} org.libjpegturbo.turbojpeg)
60set(JAVACLASSPATH ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/turbojpeg-java.dir)
61add_custom_target(javah
62  COMMAND javah -d ${CMAKE_CURRENT_SOURCE_DIR} -classpath ${JAVACLASSPATH} org.libjpegturbo.turbojpeg.TJ
63  COMMAND javah -d ${CMAKE_CURRENT_SOURCE_DIR} -classpath ${JAVACLASSPATH} org.libjpegturbo.turbojpeg.TJCompressor
64  COMMAND javah -d ${CMAKE_CURRENT_SOURCE_DIR} -classpath ${JAVACLASSPATH} org.libjpegturbo.turbojpeg.TJDecompressor
65  COMMAND javah -d ${CMAKE_CURRENT_SOURCE_DIR} -classpath ${JAVACLASSPATH} org.libjpegturbo.turbojpeg.TJTransformer)
66
67if(NOT DEFINED CMAKE_INSTALL_DEFAULT_JAVADIR)
68  set(CMAKE_INSTALL_DEFAULT_JAVADIR "<CMAKE_INSTALL_DATAROOTDIR>/java")
69endif()
70GNUInstallDirs_set_install_dir(JAVADIR
71  "The directory into which Java classes should be installed")
72GNUInstallDirs_get_absolute_install_dir(CMAKE_INSTALL_FULL_JAVADIR
73  CMAKE_INSTALL_JAVADIR)
74set(CMAKE_INSTALL_JAVADIR ${CMAKE_INSTALL_JAVADIR} PARENT_SCOPE)
75set(CMAKE_INSTALL_FULL_JAVADIR ${CMAKE_INSTALL_FULL_JAVADIR} PARENT_SCOPE)
76report_directory(JAVADIR)
77install_jar(turbojpeg-java ${CMAKE_INSTALL_JAVADIR})
78mark_as_advanced(CLEAR CMAKE_INSTALL_JAVADIR)
79