1 set(JAR_FILE turbojpeg.jar) 2 set(MANIFEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/MANIFEST.MF) 3 4 set(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 16 if(MSVC_IDE) 17 set(OBJDIR "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}") 18 else() 19 set(OBJDIR ${CMAKE_CURRENT_BINARY_DIR}) 20 endif() 21 22 set(TURBOJPEG_DLL_NAME "turbojpeg") 23 if(MINGW) 24 set(TURBOJPEG_DLL_NAME "libturbojpeg") 25 endif() 26 configure_file(org/libjpegturbo/turbojpeg/TJLoader.java.in 27 ${CMAKE_CURRENT_BINARY_DIR}/org/libjpegturbo/turbojpeg/TJLoader.java) 28 29 set(JAVA_SOURCES "") 30 set(JAVA_CLASSES "") 31 set(JAVA_CLASSES_FULL "") 32 foreach(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) 36 endforeach() 37 38 set(JAVA_SOURCES ${JAVA_SOURCES} 39 ${CMAKE_CURRENT_BINARY_DIR}/org/libjpegturbo/turbojpeg/TJLoader.java) 40 set(JAVA_CLASSES ${JAVA_CLASSES} 41 org/libjpegturbo/turbojpeg/TJLoader.class) 42 set(JAVA_CLASSES_FULL ${JAVA_CLASSES_FULL} 43 ${OBJDIR}/org/libjpegturbo/turbojpeg/TJLoader.class) 44 45 string(REGEX REPLACE " " ";" JAVACFLAGS "${JAVACFLAGS}") 46 add_custom_command(OUTPUT ${JAVA_CLASSES_FULL} DEPENDS ${JAVA_SOURCES} 47 COMMAND ${JAVA_COMPILE} ARGS ${JAVACFLAGS} -d ${OBJDIR} ${JAVA_SOURCES}) 48 49 add_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 54 add_custom_target(java ALL DEPENDS ${JAR_FILE}) 55 56 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${JAR_FILE} DESTINATION classes) 57