1set(JAR_FILE turbojpeg.jar)
2set(MANIFEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/MANIFEST.MF)
3
4set(JAVA_CLASSNAMES org/libjpegturbo/turbojpeg/TJ
5  org/libjpegturbo/turbojpeg/TJCompressor
6  org/libjpegturbo/turbojpeg/TJCustomFilter
7  org/libjpegturbo/turbojpeg/TJDecompressor
8  org/libjpegturbo/turbojpeg/TJScalingFactor
9  org/libjpegturbo/turbojpeg/TJTransform
10  org/libjpegturbo/turbojpeg/TJTransformer
11  org/libjpegturbo/turbojpeg/YUVImage
12  TJUnitTest
13  TJExample
14  TJBench)
15
16if(MSVC_IDE)
17  set(OBJDIR "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}")
18else()
19  set(OBJDIR ${CMAKE_CURRENT_BINARY_DIR})
20endif()
21
22set(TURBOJPEG_DLL_NAME "turbojpeg")
23if(MINGW)
24  set(TURBOJPEG_DLL_NAME "libturbojpeg")
25endif()
26configure_file(org/libjpegturbo/turbojpeg/TJLoader.java.in
27  ${CMAKE_CURRENT_BINARY_DIR}/org/libjpegturbo/turbojpeg/TJLoader.java)
28
29set(JAVA_SOURCES "")
30set(JAVA_CLASSES "")
31set(JAVA_CLASSES_FULL "")
32foreach(class ${JAVA_CLASSNAMES})
33  set(JAVA_SOURCES ${JAVA_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/${class}.java)
34  set(JAVA_CLASSES ${JAVA_CLASSES} ${class}.class)
35  set(JAVA_CLASSES_FULL ${JAVA_CLASSES_FULL} ${OBJDIR}/${class}.class)
36endforeach()
37
38set(JAVA_SOURCES ${JAVA_SOURCES}
39  ${CMAKE_CURRENT_BINARY_DIR}/org/libjpegturbo/turbojpeg/TJLoader.java)
40set(JAVA_CLASSES ${JAVA_CLASSES}
41  org/libjpegturbo/turbojpeg/TJLoader.class)
42set(JAVA_CLASSES_FULL ${JAVA_CLASSES_FULL}
43  ${OBJDIR}/org/libjpegturbo/turbojpeg/TJLoader.class)
44
45string(REGEX REPLACE " " ";" JAVACFLAGS "${JAVACFLAGS}")
46add_custom_command(OUTPUT ${JAVA_CLASSES_FULL} DEPENDS ${JAVA_SOURCES}
47  COMMAND ${JAVA_COMPILE} ARGS ${JAVACFLAGS} -d ${OBJDIR} ${JAVA_SOURCES})
48
49add_custom_command(OUTPUT ${JAR_FILE} DEPENDS ${JAVA_CLASSES_FULL}
50  ${MANIFEST_FILE}
51  COMMAND ${JAVA_ARCHIVE} cfm ${JAR_FILE} ${MANIFEST_FILE} ${JAVA_CLASSES}
52  WORKING_DIRECTORY ${OBJDIR})
53
54add_custom_target(java ALL DEPENDS ${JAR_FILE})
55
56install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${JAR_FILE} DESTINATION classes)
57