Skip to content

Commit

Permalink
Clean up handling coda modules and common logic
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanMeans committed Feb 28, 2020
1 parent af59415 commit 5e5cd7e
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 85 deletions.
27 changes: 14 additions & 13 deletions CMakeLists-CODA.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,23 @@ ExternalProject_Add_Step(coda-oss
ALWAYS 0
WORKING_DIRECTORY ${CODA_DIR})

ExternalProject_Add_Step(coda-oss
waf-build
COMMAND ${Python_EXECUTABLE} waf install
--target=mt-c++,math-c++,io-c++,mem-c++,sys-c++,str-c++,except-c++,j2k_config,J2K,JPEG
DEPENDEES waf-configure
DEPENDERS build
ALWAYS 0
WORKING_DIRECTORY ${CODA_DIR})

if(Python_NumPy_FOUND)
foreach(module ${coda_modules})
ExternalProject_Add_Step(coda-oss
waf-build-numpyutils
COMMAND ${Python_EXECUTABLE} waf install --target=numpyutils-c++
waf-build-${module}
COMMAND ${Python_EXECUTABLE} waf install --target=${module}
DEPENDEES waf-configure
DEPENDERS build
ALWAYS 0
WORKING_DIRECTORY ${CODA_DIR})
endforeach()

endif()
#if(Python_NumPy_FOUND)
# ExternalProject_Add_Step(coda-oss
# waf-build-numpyutils
# COMMAND ${Python_EXECUTABLE} waf install --target=numpyutils-c++
# DEPENDEES waf-configure
# DEPENDERS build
# ALWAYS 0
# WORKING_DIRECTORY ${CODA_DIR})
#
#endif()
70 changes: 9 additions & 61 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,76 +4,24 @@ 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()

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()
include(common_build.cmake)

if(PYTHON_HOME)
set(Python_ROOT_DIR ${PYTHON_HOME})
endif()

find_package(Python COMPONENTS Interpreter Development NumPy)

include(CMakeLists-CODA.txt)
set(CMAKE_C_STANDARD 90)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

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)
list(APPEND coda_modules except-c++ io-c++ sys-c++ mt-c++ str-c++ math-c++
xml.lite-c++ JPEG J2K)
if (Python_NumPy_FOUND)
list(APPEND coda_modules numpyutils-c++)
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()
include(CMakeLists-CODA.txt)

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++)
add_coda_module(numpyutils-c++)
add_coda_module(xml.lite-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 Down
55 changes: 55 additions & 0 deletions 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: 0 additions & 6 deletions modules/c/j2k/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
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/)

Expand Down
5 changes: 0 additions & 5 deletions modules/c/jpeg/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
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)
Expand Down

0 comments on commit 5e5cd7e

Please sign in to comment.