Skip to content

Commit

Permalink
Add Java layer
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanMeans committed Feb 28, 2020
1 parent c49b41c commit 4678a52
Show file tree
Hide file tree
Showing 5 changed files with 202 additions and 0 deletions.
47 changes: 47 additions & 0 deletions modules/java/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
find_package(JNI)
find_package(Java)
include(UseJava)

function(add_java_module target java_files c_files jars)
add_jar(${target}-java ${java_files}
INCLUDE_JARS ${jars}
OUTPUT_NAME ${target})

get_target_property(jar_file ${target}-java JAR_FILE)
get_target_property(class_dir ${target}-java CLASSDIR)

include_directories(${JNI_INCLUDE_DIRS}
${class_dir}
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/src/jni/include/)

add_library(${target}-jni MODULE ${c_files})
set_target_properties(${target}-jni PROPERTIES SUFFIX .jni-c.so)
set_target_properties(${target}-jni PROPERTIES OUTPUT_NAME ${target})
target_link_libraries(${target}-jni ${JNI_LIBRARIES} nrt-c nitf-c cgm-c)
install(TARGETS ${target}-jni DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
install(FILES ${jar_file} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
endfunction()

if (!JNI_FOUND)
message(WARNING "JNI libraries not found. Skipping Java modules")
elseif(!Java_FOUND)
message(WARNING "Java SDK not found. Skipping Java modules")
endif()
#else()
# set(CMAKE_JAVA_COMPILE_FLAGS "-source" "1.5" "-target" "1.5")
#
# # CODA doesn't know how to install jars, so we'll handle it here
# set(jar_path ${CODA_DIR}/modules/drivers/jars)
# set(coda_jars ${jar_path}/commons-io-1.3.2.jar
# ${jar_path}/commons-cli-1.0-beta-2.jar
# ${jar_path}/commons-lang-2.0.jar
# ${jar_path}/commons-logging-1.1.1.jar
# ${jar_path}/log4j-1.2.13.jar)
# install(FILES ${coda_jars} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
#
# add_subdirectory(nitf)
# add_subdirectory(cgm)
# add_subdirectory(nitf.imageio)
# add_subdirectory(nitf.imagej)
#endif()
23 changes: 23 additions & 0 deletions modules/java/cgm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
set(cgm_source_dir ${CMAKE_CURRENT_SOURCE_DIR}/src/java/cgm/)
set(java_files ${cgm_source_dir}/CGMUtils.java
${cgm_source_dir}/CircleElement.java
${cgm_source_dir}/Element.java
${cgm_source_dir}/Metafile.java
${cgm_source_dir}/MetafileReader.java
${cgm_source_dir}/PictureBody.java
${cgm_source_dir}/Picture.java
${cgm_source_dir}/Rectangle.java
${cgm_source_dir}/TextAttributes.java
${cgm_source_dir}/TextElement.java
${cgm_source_dir}/Text.java)

set(cgm_jni_source_dir ${CMAKE_CURRENT_SOURCE_DIR}/src/jni/source/)
set(c_files ${cgm_jni_source_dir}/cgm_Element.c
${cgm_jni_source_dir}/cgm_JNI.c
${cgm_jni_source_dir}/cgm_Metafile.c
${cgm_jni_source_dir}/cgm_MetafileReader.c
${cgm_jni_source_dir}/cgm_Picture.c)

add_java_module(cgm "${java_files}" "${c_files}"
${CMAKE_CURRENT_BINARY_DIR}/../nitf/nitf.jar)
add_dependencies(cgm-java nitf-java cgm-c)
13 changes: 13 additions & 0 deletions modules/java/nitf.imageio/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
set(java_source_dir ${CMAKE_CURRENT_SOURCE_DIR}/src/java/nitf/imageio)
set(java_files ${java_source_dir}/ImageIOUtils.java
${java_source_dir}/NITFReader.java
${java_source_dir}/NITFReaderSpi.java)


add_jar(nitf.imageio-java "${java_files}"
INCLUDE_JARS ${coda_jars}
${CMAKE_CURRENT_BINARY_DIR}/../nitf/nitf.jar
OUTPUT_NAME nitf.imageio)

add_dependencies(nitf.imageio-java nitf-java)
install_jar(nitf.imageio-java ${CMAKE_INSTALL_PREFIX}/lib)
11 changes: 11 additions & 0 deletions modules/java/nitf.imagej/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
set(java_files ${CMAKE_CURRENT_SOURCE_DIR}/src/java/nitf/imagej/NITF_Reader.java)

add_jar(nitf.imagej-java "${java_files}"
INCLUDE_JARS ${coda_jars}
${CMAKE_CURRENT_BINARY_DIR}/../nitf/nitf.jar
${CMAKE_CURRENT_BINARY_DIR}/../nitf.imageio/nitf.imageio.jar
${CMAKE_CURRENT_SOURCE_DIR}/lib/ij-1.42.jar
OUTPUT_NAME nitf.imagej)

add_dependencies(nitf.imagej-java nitf-java nitf.imageio-java)
install_jar(nitf.imagej-java ${CMAKE_INSTALL_PREFIX}/lib)
108 changes: 108 additions & 0 deletions modules/java/nitf/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
set(java_source_dir ${CMAKE_CURRENT_SOURCE_DIR}/src/java/nitf)
set(java_files ${java_source_dir}/BandInfo.java
${java_source_dir}/BandSource.java
${java_source_dir}/BlockingInfo.java
${java_source_dir}/CloneableObject.java
${java_source_dir}/ComponentInfo.java
${java_source_dir}/DESegment.java
${java_source_dir}/DestructibleObject.java
${java_source_dir}/DESubheader.java
${java_source_dir}/DownSampler.java
${java_source_dir}/Extensions.java
${java_source_dir}/Field.java
${java_source_dir}/FieldType.java
${java_source_dir}/FieldWarning.java
${java_source_dir}/FileHeader.java
${java_source_dir}/FileSecurity.java
${java_source_dir}/FileSource.java
${java_source_dir}/GraphicSegment.java
${java_source_dir}/GraphicSubheader.java
${java_source_dir}/ImageReader.java
${java_source_dir}/ImageSegment.java
${java_source_dir}/ImageSource.java
${java_source_dir}/ImageSubheader.java
${java_source_dir}/ImageWriter.java
${java_source_dir}/IOHandle.java
${java_source_dir}/IOInterface.java
${java_source_dir}/LabelSegment.java
${java_source_dir}/LabelSubheader.java
${java_source_dir}/LookupTable.java
${java_source_dir}/MaxDownSampler.java
${java_source_dir}/MemoryDestructor.java
${java_source_dir}/MemoryIO.java
${java_source_dir}/MemorySource.java
${java_source_dir}/NativeIOInterface.java
${java_source_dir}/NITFException.java
${java_source_dir}/NITFObject.java
${java_source_dir}/NITFResourceManager.java
${java_source_dir}/PixelSkipDownSampler.java
${java_source_dir}/PluginRegistry.java
${java_source_dir}/Reader.java
${java_source_dir}/Record.java
${java_source_dir}/RESegment.java
${java_source_dir}/RESubheader.java
${java_source_dir}/SegmentReader.java
${java_source_dir}/SegmentSource.java
${java_source_dir}/SegmentWriter.java
${java_source_dir}/StreamIOWriteHandler.java
${java_source_dir}/SubWindow.java
${java_source_dir}/SumSq2BandDownSampler.java
${java_source_dir}/TextSegment.java
${java_source_dir}/TextSubheader.java
${java_source_dir}/TRE.java
${java_source_dir}/Version.java
${java_source_dir}/WriteHandler.java
${java_source_dir}/Writer.java)

set(jni_source_dir ${CMAKE_CURRENT_SOURCE_DIR}/src/jni/source)
set(c_files ${jni_source_dir}/nitf_BandInfo.c
${jni_source_dir}/nitf_BandSource.c
${jni_source_dir}/nitf_BlockingInfo.c
${jni_source_dir}/nitf_ComponentInfo.c
${jni_source_dir}/nitf_DESegment.c
${jni_source_dir}/nitf_DESubheader.c
${jni_source_dir}/nitf_DownSampler.c
${jni_source_dir}/nitf_Extensions.c
${jni_source_dir}/nitf_Extensions_ExtensionsIterator.c
${jni_source_dir}/nitf_Field.c
${jni_source_dir}/nitf_FieldWarning.c
${jni_source_dir}/nitf_FileHeader.c
${jni_source_dir}/nitf_FileSecurity.c
${jni_source_dir}/nitf_FileSource.c
${jni_source_dir}/nitf_GraphicSegment.c
${jni_source_dir}/nitf_GraphicSubheader.c
${jni_source_dir}/nitf_ImageReader.c
${jni_source_dir}/nitf_ImageSegment.c
${jni_source_dir}/nitf_ImageSource.c
${jni_source_dir}/nitf_ImageSubheader.c
${jni_source_dir}/nitf_ImageWriter.c
${jni_source_dir}/nitf_IOHandle.c
${jni_source_dir}/nitf_IOInterface.c
${jni_source_dir}/nitf_JNI.c
${jni_source_dir}/nitf_LabelSegment.c
${jni_source_dir}/nitf_LabelSubheader.c
${jni_source_dir}/nitf_LookupTable.c
${jni_source_dir}/nitf_MaxDownSampler.c
${jni_source_dir}/nitf_MemorySource.c
${jni_source_dir}/nitf_NativeIOInterface.c
${jni_source_dir}/nitf_PixelSkipDownSampler.c
${jni_source_dir}/nitf_PluginRegistry.c
${jni_source_dir}/nitf_Reader.c
${jni_source_dir}/nitf_Record.c
${jni_source_dir}/nitf_RESegment.c
${jni_source_dir}/nitf_RESubheader.c
${jni_source_dir}/nitf_SegmentReader.c
${jni_source_dir}/nitf_SegmentSource.c
${jni_source_dir}/nitf_SegmentWriter.c
${jni_source_dir}/nitf_SubWindow.c
${jni_source_dir}/nitf_SumSq2BandDownSampler.c
${jni_source_dir}/nitf_TextSegment.c
${jni_source_dir}/nitf_TextSubheader.c
${jni_source_dir}/nitf_TRE.c
${jni_source_dir}/nitf_TRE_TREIterator.c
${jni_source_dir}/nitf_WriteHandler.c
${jni_source_dir}/nitf_Writer.c)

add_java_module(nitf "${java_files}" "${c_files}" "${coda_jars}")
add_dependencies(nitf-java nitf-c)

0 comments on commit 4678a52

Please sign in to comment.