message(STATUS "Arithmetic decoding support disabled")
endif()
-if(NOT DEFINED WITH_JNI)
- set(WITH_JNI 0)
+if(NOT DEFINED WITH_JAVA)
+ set(WITH_JAVA 0)
endif()
-if(WITH_JNI)
- message(STATUS "TurboJPEG/OSS JNI wrapper enabled")
+if(WITH_JAVA)
+ message(STATUS "TurboJPEG/OSS Java wrapper enabled")
else()
- message(STATUS "TurboJPEG/OSS JNI wrapper disabled")
+ message(STATUS "TurboJPEG/OSS Java wrapper disabled")
endif()
set(JPEG_LIB_VERSION 62)
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR})
-if(WITH_JNI)
- include(CheckIncludeFiles)
- check_include_files(jni.h HAVE_JNI_H)
- if(NOT HAVE_JNI_H)
- message(FATAL_ERROR "Cannot find jni.h. Be sure to add the Java include directories to the INCLUDE environment variable (MSVC) or the CPATH environment variable (GCC).")
- endif()
+if(WITH_JAVA)
+ find_package(Java)
+ find_package(JNI)
endif()
message(STATUS "Not using SIMD acceleration")
endif()
+if(WITH_JAVA)
+ add_subdirectory(java)
+endif()
+
add_subdirectory(sharedlib)
add_library(jpeg-static STATIC ${JPEG_SOURCES} ${SIMD_OBJS})
endif()
set(TURBOJPEG_SOURCES turbojpegl.c transupp.c)
-if(WITH_JNI)
+if(WITH_JAVA)
set(TURBOJPEG_SOURCES ${TURBOJPEG_SOURCES} turbojpeg-jni.c)
+ include_directories(${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2})
endif()
add_library(turbojpeg SHARED ${TURBOJPEG_SOURCES})
# Tests
#
+if(MSVC_IDE)
+ set(OBJDIR "\${CTEST_CONFIGURATION_TYPE}/")
+else()
+ set(OBJDIR "")
+endif()
+
enable_testing()
+if(WITH_JAVA)
+add_test(TJUnitTest ${JAVA_RUNTIME} -cp java/${OBJDIR}turbojpeg.jar -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR} TJUnitTest)
+add_test(TJUnitTest-yuv ${JAVA_RUNTIME} -cp java/${OBJDIR}turbojpeg.jar -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR} TJUnitTest -yuv)
+add_test(TJUnitTest-bi ${JAVA_RUNTIME} -cp java/${OBJDIR}turbojpeg.jar -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR} TJUnitTest -bi)
+add_test(TJUnitTest-bi-yuv ${JAVA_RUNTIME} -cp java/${OBJDIR}turbojpeg.jar -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR} TJUnitTest -bi -yuv)
+endif()
add_test(jpegut jpegut)
add_test(jpegut-yuv jpegut -yuv)
add_test(cjpeg-int sharedlib/cjpeg -dct int -outfile testoutint.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
set(INST_DEFS ${INST_DEFS} -DWIN64)
endif()
+if(WITH_JAVA)
+ set(INST_DEFS ${INST_DEFS} -DJAVA)
+endif()
+
if(MSVC_IDE)
set(INST_DEFS ${INST_DEFS} "-DBUILDDIR=$(OutDir)\\")
else()
--- /dev/null
+set(JAR_FILE turbojpeg.jar)
+set(MANIFEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/MANIFEST.MF)
+
+set(JAVA_CLASSNAMES org/libjpegturbo/turbojpeg/TJ
+ org/libjpegturbo/turbojpeg/TJCompressor
+ org/libjpegturbo/turbojpeg/TJDecompressor
+ org/libjpegturbo/turbojpeg/TJTransform
+ org/libjpegturbo/turbojpeg/TJTransformer
+ TJUnitTest
+ TJExample)
+
+if(MSVC_IDE)
+ set(OBJDIR "${CMAKE_CURRENT_BINARY_DIR}/$(OutDir)")
+else()
+ set(OBJDIR ${CMAKE_CURRENT_BINARY_DIR})
+endif()
+
+set(JAVA_SOURCES "")
+set(JAVA_CLASSES "")
+set(JAVA_CLASSES_FULL "")
+foreach(class ${JAVA_CLASSNAMES})
+ set(JAVA_SOURCES ${JAVA_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/${class}.java)
+ set(JAVA_CLASSES ${JAVA_CLASSES} ${class}.class)
+ set(JAVA_CLASSES_FULL ${JAVA_CLASSES_FULL} ${OBJDIR}/${class}.class)
+endforeach()
+
+if(MSVC_IDE)
+ set(JAVA_CLASSES ${JAVA_CLASSES}
+ org/libjpegturbo/turbojpeg/TJ$ScalingFactor.class)
+else()
+ set(JAVA_CLASSES ${JAVA_CLASSES}
+ org/libjpegturbo/turbojpeg/TJ$$ScalingFactor.class)
+endif()
+
+add_custom_command(OUTPUT ${JAVA_CLASSES_FULL} DEPENDS ${JAVA_SOURCES}
+ COMMAND ${JAVA_COMPILE} -d ${OBJDIR} ARGS ${JAVA_SOURCES})
+
+add_custom_command(OUTPUT ${JAR_FILE} DEPENDS ${JAVA_CLASSES_FULL}
+ ${MANIFEST_FILE}
+ COMMAND ${JAVA_ARCHIVE} cfm ${JAR_FILE} ${MANIFEST_FILE} ${JAVA_CLASSES}
+ WORKING_DIRECTORY ${OBJDIR})
+
+add_custom_target(java ALL DEPENDS ${JAR_FILE})
+
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${JAR_FILE} DESTINATION classes)
endif
-EXTRA_DIST = MANIFEST.MF ${JAVASOURCES} ${JNIHEADERS} doc
+EXTRA_DIST = MANIFEST.MF ${JAVASOURCES} ${JNIHEADERS} doc CMakeLists.txt
File "@CMAKE_BINARY_DIR@\${BUILDDIR}turbojpeg-static.lib"
File "@CMAKE_BINARY_DIR@\sharedlib\${BUILDDIR}jpeg.lib"
File "@CMAKE_BINARY_DIR@\${BUILDDIR}jpeg-static.lib"
+!endif
+!ifdef JAVA
+ SetOutPath $INSTDIR\classes
+ File "@CMAKE_BINARY_DIR@\java\${BUILDDIR}turbojpeg.jar"
!endif
SetOutPath $INSTDIR\include
File "@CMAKE_BINARY_DIR@\jconfig.h"
Delete $INSTDIR\lib\jpeg-static.lib
Delete $INSTDIR\lib\turbojpeg.lib
Delete $INSTDIR\lib\turbojpeg-static.lib
+!endif
+!ifdef JAVA
+ Delete $INSTDIR\classes\turbojpeg.jar
!endif
Delete $INSTDIR\bin\cjpeg.exe
Delete $INSTDIR\bin\djpeg.exe
RMDir "$INSTDIR\include"
RMDir "$INSTDIR\lib"
RMDir "$INSTDIR\doc"
+!ifdef JAVA
+ RMDir "$INSTDIR\classes"
+!endif
RMDir "$INSTDIR\bin"
RMDir "$INSTDIR"