Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync externals #327

Merged
merged 2 commits into from
Mar 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions externals/nitro/CMakeLists-CODA.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ endif()

ExternalProject_Add_Step(coda-oss
waf-configure
COMMAND python waf configure --prefix=${CODA_INSTALL_DIR} "${configure_flags}"
COMMAND ${PYTHON} waf configure --prefix=${CODA_INSTALL_DIR} "${configure_flags}"
DEPENDERS build
ALWAYS 0
WORKING_DIRECTORY ${CODA_DIR})

list(JOIN coda_modules , install_targets)
ExternalProject_Add_Step(coda-oss
waf-build
COMMAND python waf install
--target=mt-c++,math-c++,io-c++,mem-c++,sys-c++,str-c++,except-c++,j2k_config,J2K,JPEG
waf-build-${module}
COMMAND ${PYTHON} waf install --target=${install_targets}
DEPENDEES waf-configure
DEPENDERS build
ALWAYS 0
Expand Down
86 changes: 27 additions & 59 deletions externals/nitro/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,68 +4,34 @@ cmake_minimum_required(VERSION 3.11)

project("nitro")

if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Select Build Type" FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
include(common_build.cmake)

if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
message("Overriding default CMAKE_INSTALL_PREFIX of ${CMAKE_INSTALL_PREFIX}")
set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/install${CMAKE_SYSTEM_NAME}-${CMAKE_BUILD_TYPE}" CACHE PATH "Install directory" FORCE)
if(PYTHON_HOME)
set(Python_ROOT_DIR ${PYTHON_HOME})
endif()

include(CMakeLists-CODA.txt)
set(CMAKE_C_STANDARD 90)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
find_package(Python COMPONENTS Interpreter Development NumPy)
list(APPEND coda_modules except-c++ io-c++ sys-c++ mt-c++ str-c++
math-c++ xml.lite-c++ JPEG J2K)

if (UNIX)
add_compile_options(-Wno-deprecated -Wno-deprecated-declarations)
elseif(MSVC)
add_definitions(-DWIN32_LEAN_AND_MEAN
-DNOMINMAX
-D_CRT_SECURE_NO_WARNINGS
-D_SCL_SECURE_NO_WARNINGS
-D_USE_MATH_DEFINES)
if (Python_NumPy_FOUND AND NOT MSVC)
list(APPEND coda_modules numpyutils-c++)
endif()
if (Python_FOUND)
set(PYTHON ${Python_EXECUTABLE})
else()
set(PYTHON python)
endif()

function(common_module_config module)
target_include_directories(${module} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_BINARY_DIR}/include)
install(TARGETS ${module})
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
DESTINATION include)
endfunction()

function(add_unittests unittests ext deps module)
foreach(TEST_NAME ${unittests})
add_executable(${TEST_NAME} unittests/${TEST_NAME}.${ext})
target_link_libraries(${TEST_NAME} ${deps})
add_test(${TEST_NAME} ${TEST_NAME})
install(TARGETS ${TEST_NAME} DESTINATION unittests/${module})
endforeach()
endfunction()

function(add_coda_module module)
add_library(${module} STATIC IMPORTED)
if(UNIX)
set_target_properties(${module} PROPERTIES
IMPORTED_LOCATION ${CODA_INSTALL_DIR}/lib/lib${module}.a)
elseif(MSVC)
set_target_properties(${module} PROPERTIES
IMPORTED_LOCATION ${CODA_INSTALL_DIR}/lib/${module}.lib)
else()
message(FATAL_ERROR "Unsupported platform")
endif()
endfunction()
if (NOT DEFINED CODA_INSTALL_DIR)
include(CMakeLists-CODA.txt)
else()
add_library(coda-oss INTERFACE)
endif()

add_coda_module(except-c++)
add_coda_module(io-c++)
add_coda_module(sys-c++)
add_coda_module(mt-c++)
add_coda_module(str-c++)
add_coda_module(math-c++)
foreach(module ${coda_modules})
add_coda_module(${module})
endforeach()

add_library(coda_oss_config INTERFACE)
target_include_directories(coda_oss_config INTERFACE ${CODA_DIR}/target/moudules/c++/config/include/)
Expand All @@ -74,10 +40,12 @@ add_dependencies(coda_oss_config coda-oss)
# Everyone can include coda's headers
include_directories(${CODA_INSTALL_DIR}/include)

# TestCase.h lives here
include_directories(${CODA_DIR}/modules/c++/include)

enable_testing()
set(NITRO_C_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/modules/c)
add_subdirectory(modules/c)
add_subdirectory(modules/c++)
# add_subdirectory(modules/python)
if (NOT MSVC)
add_subdirectory(modules/python)
endif()
add_subdirectory(modules/java)
add_subdirectory(modules/mex)
18 changes: 11 additions & 7 deletions externals/nitro/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,24 @@ Sample Build Scenario
Problems and Configurations
---------------------------

- If your system compiler does not fully support C++11, you may have to
specify a different one during the configure step. e.g.
- The Python layer will not build on Windows
- Nothing will build on WSL
- Both these problems are due to how coda-oss's waf talks to Python. They will
be addressed once CODA-OSS is building with CMake.
- If your system compiler does not fully support C++11, you may have to
specify a different one during the configure step. e.g.

cmake -DCMAKE_C_COMPILER=/some/path/gcc/4.9.1/bin/gcc -DCMAKE_CXX_COMPILER=/...../bin/g++ ..
cmake -DCMAKE_C_COMPILER=/some/path/gcc/4.9.1/bin/gcc -DCMAKE_CXX_COMPILER=/...../bin/g++ ..

- NITRO will construct a default local install location for you. Pass -DCMAKE_INSTALL_PREFIX to override.
- NITRO will construct a default local install location for you. Pass -DCMAKE_INSTALL_PREFIX to override.

- Java, MATLAB, Python, C++ bindings all build. Just make sure the relevant tools
are on your PATH

- Debug symbols are available by default. Configure release type with [-DCMAKE_BUILD_TYPE](https://cmake.org/cmake/help/v3.0/variable/CMAKE_BUILD_TYPE.html)

- If the CMake build system does not support a required feature that Waf does, open
a ticket or a pull request!
- If the CMake build system does not support a required feature that Waf does, create
an issue or a pull request!


Building with Waf
Expand Down Expand Up @@ -213,4 +217,4 @@ NITRO already knows where they are installed, and you don't have to
do anything.

If you want to override this behavior, you can set the
`NITF_PLUGIN_PATH` environment variable to your preferred location.
`NITF_PLUGIN_PATH` environment variable to your preferred location.
55 changes: 55 additions & 0 deletions externals/nitro/common_build.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
set(CMAKE_C_STANDARD 90)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Select Build Type" FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()

if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
message("Overriding default CMAKE_INSTALL_PREFIX of ${CMAKE_INSTALL_PREFIX}")
set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/install${CMAKE_SYSTEM_NAME}-${CMAKE_BUILD_TYPE}" CACHE PATH "Install directory" FORCE)
endif()

if (UNIX)
add_compile_options(-Wno-deprecated -Wno-deprecated-declarations)
elseif(MSVC)
add_definitions(-DWIN32_LEAN_AND_MEAN
-DNOMINMAX
-D_CRT_SECURE_NO_WARNINGS
-D_SCL_SECURE_NO_WARNINGS
-D_USE_MATH_DEFINES)
endif()

function(common_module_config module)
target_include_directories(${module} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_BINARY_DIR}/include)
install(TARGETS ${module})
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
DESTINATION include)
endfunction()

function(add_unittests unittests ext deps module)
foreach(TEST_NAME ${unittests})
add_executable(${TEST_NAME} unittests/${TEST_NAME}.${ext})
target_link_libraries(${TEST_NAME} ${deps})
add_test(${TEST_NAME} ${TEST_NAME})
install(TARGETS ${TEST_NAME} DESTINATION unittests/${module})
endforeach()
endfunction()

function(add_coda_module module)
add_library(${module} STATIC IMPORTED)
if(UNIX)
set_target_properties(${module} PROPERTIES
IMPORTED_LOCATION ${CODA_INSTALL_DIR}/lib/lib${module}.a)
elseif(MSVC)
set_target_properties(${module} PROPERTIES
IMPORTED_LOCATION ${CODA_INSTALL_DIR}/lib/${module}.lib)
else()
message(FATAL_ERROR "Unsupported platform")
endif()
endfunction()

6 changes: 2 additions & 4 deletions externals/nitro/modules/c++/nitf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,18 @@ add_library(nitf-c++ source/BandInfo.cpp
source/Writer.cpp)

common_module_config(nitf-c++)
target_link_libraries(nitf-c++ nitf except-c++ io-c++ mt-c++ sys-c++ str-c++)
target_link_libraries(nitf-c++ nitf-c except-c++ io-c++ mt-c++ sys-c++ str-c++)
if (MSVC)
target_link_libraries(nitf-c++ wsock32 ws2_32)
endif()
target_compile_features(nitf-c++ PUBLIC cxx_inheriting_constructors)

add_dependencies(nitf-c++ coda-oss nitf)

set(unittest_srcs test_field++
test_image_blocker
test_image_segment_blank_nm_compression
test_image_segment_computer
test_nitf_buffer_list
test_tre_mods++)

set(unittest_deps nitf-c++ nitf math-c++)
set(unittest_deps nitf-c++ math-c++)
add_unittests("${unittest_srcs}" cpp "${unittest_deps}" nitf)
56 changes: 28 additions & 28 deletions externals/nitro/modules/c/cgm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
add_library(cgm source/CircleElement.c
source/CircularArcCloseElement.c
source/CircularArcElement.c
source/Color.c
source/Element.c
source/EllipseElement.c
source/EllipticalArcCloseElement.c
source/EllipticalArcElement.c
source/FillAttributes.c
source/LineAttributes.c
source/Metafile.c
source/MetafileReader.c
source/MetafileWriter.c
source/NITFWriteHandler.c
source/Picture.c
source/PictureBody.c
source/PolyLineElement.c
source/PolySetElement.c
source/PolygonElement.c
source/Rectangle.c
source/RectangleElement.c
source/Text.c
source/TextAttributes.c
source/TextElement.c
source/Vertex.c
source/VertexClose.c)
common_module_config(cgm)
target_link_libraries(cgm nitf)
add_library(cgm-c source/CircleElement.c
source/CircularArcCloseElement.c
source/CircularArcElement.c
source/Color.c
source/Element.c
source/EllipseElement.c
source/EllipticalArcCloseElement.c
source/EllipticalArcElement.c
source/FillAttributes.c
source/LineAttributes.c
source/Metafile.c
source/MetafileReader.c
source/MetafileWriter.c
source/NITFWriteHandler.c
source/Picture.c
source/PictureBody.c
source/PolyLineElement.c
source/PolySetElement.c
source/PolygonElement.c
source/Rectangle.c
source/RectangleElement.c
source/Text.c
source/TextAttributes.c
source/TextElement.c
source/Vertex.c
source/VertexClose.c)
common_module_config(cgm-c)
target_link_libraries(cgm-c nitf-c)
12 changes: 3 additions & 9 deletions externals/nitro/modules/c/j2k/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
add_library(J2K STATIC IMPORTED)
set_target_properties(J2K PROPERTIES
IMPORTED_LOCATION ${CODA_INSTALL_DIR}/lib/libopenjpeg.a
INTERFACE_INCLUDE_DIRECTORIES ${CODA_INSTALL_DIR}/include)
target_link_libraries(J2K INTERFACE m)

add_library(j2k_config INTERFACE)
target_include_directories(j2k_config INTERFACE ${CODA_DIR}/target/modules/drivers/j2k/include/)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/j2k/j2k_config.h.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/include/j2k/j2k_config.h)

add_library(j2k-c source/Container.c
source/Component.c
Expand All @@ -19,4 +13,4 @@ add_library(j2k-c source/Container.c
common_module_config(j2k-c)
add_dependencies(j2k-c coda-oss)

target_link_libraries(j2k-c j2k_config J2K nrt nitf)
target_link_libraries(j2k-c j2k_config J2K nitf-c)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef NITFO_J2K_CONFIG_H
#define NITFO_J2K_CONFIG_H

#cmakedefine HAVE_OPENJPEG_H @HAVE_OPENJPEG_H@

#endif
2 changes: 1 addition & 1 deletion externals/nitro/modules/c/j2k/source/JasPerImpl.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/

#include "j2k/j2k_config.h"

#ifdef HAVE_JASPER_H

#include "j2k/Container.h"
Expand Down
7 changes: 1 addition & 6 deletions externals/nitro/modules/c/jpeg/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
add_library(JPEG STATIC IMPORTED)
set_target_properties(JPEG PROPERTIES
IMPORTED_LOCATION ${CODA_INSTALL_DIR}/lib/liblibjpeg.a
INTERFACE_INCLUDE_DIRECTORIES ${CODA_INSTALL_DIR}/include)

add_library(jpeg-c source/LibjpegDecompress.c)
add_dependencies(jpeg-c coda-oss)
target_link_libraries(jpeg-c JPEG nitf)
target_link_libraries(jpeg-c JPEG nitf-c)
target_include_directories(jpeg-c PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
install(TARGETS jpeg-c)
Loading