From 3c9d5fb7454cadc3413085d1359760530946d800 Mon Sep 17 00:00:00 2001 From: Vaughn Holmes Date: Thu, 27 Feb 2025 11:52:50 -0500 Subject: [PATCH 1/3] Fix missing variable --- cmake/CodaBuild.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/CodaBuild.cmake b/cmake/CodaBuild.cmake index be841d3fee..52bfcd0dd3 100644 --- a/cmake/CodaBuild.cmake +++ b/cmake/CodaBuild.cmake @@ -343,7 +343,7 @@ function(coda_fetch_driver) # The returned properties use the lower-cased name string(TOLOWER ${target_name} target_name_lc) if (NOT ${target_name_lc}_POPULATED) # This makes sure we only fetch once. - message("Populating content for external dependency ${driver_name}") + message("Populating content for external dependency ${target_name_lc}") # Now (at configure time) unpack the content. FetchContent_Populate(${target_name}) # Remember where we put stuff From c269ea9706a2a4bd22752fc3782a018304e41c49 Mon Sep 17 00:00:00 2001 From: Vaughn Holmes Date: Thu, 27 Feb 2025 11:54:37 -0500 Subject: [PATCH 2/3] Add logic for ctest invocation in build process --- cmake/CodaBuild.cmake | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cmake/CodaBuild.cmake b/cmake/CodaBuild.cmake index 52bfcd0dd3..5e25fa752b 100644 --- a/cmake/CodaBuild.cmake +++ b/cmake/CodaBuild.cmake @@ -388,6 +388,8 @@ function(coda_add_tests) "DEPS;SOURCES;ARGS;FILTER_LIST" # multi args "${ARGN}" ) + option(${PROJECT_NAME}_AUTO_UNITTEST "run unittests during build" OFF) + if (ARG_UNPARSED_ARGUMENTS) message(FATAL_ERROR "received unexpected argument(s): ${ARG_UNPARSED_ARGUMENTS}") endif() @@ -461,6 +463,18 @@ function(coda_add_tests) RUNTIME DESTINATION "${ARG_DIRECTORY}/${ARG_MODULE_NAME}/${test_subdir}") endif() endforeach() + + if (${ARG_UNITTEST} AND ${PROJECT_NAME}_AUTO_UNITTEST) + set (MOD ${ARG_MODULE_NAME}-${TARGET_LANGUAGE}) + get_target_property(type ${MOD} TYPE) + # Can only define POST_BUILD targets on non-interface libs + if (NOT ${type} STREQUAL "INTERFACE_LIBRARY") + add_custom_command(TARGET ${MOD} POST_BUILD + COMMAND ${CMAKE_CTEST_COMMAND} + --test-dir ${CMAKE_CURRENT_BINARY_DIR} --output-on-failure + DEPENDS ${test_group_tgt}) + endif() + endif() endif() endfunction() From 0081fb6933fede28265ce234775eabc7bb54fd0a Mon Sep 17 00:00:00 2001 From: Vaughn Holmes Date: Thu, 27 Feb 2025 12:32:08 -0500 Subject: [PATCH 3/3] More set cache bool -> option --- cmake/CodaBuild.cmake | 2 +- cmake/CodaFindSystemDependencies.cmake | 12 +++++++----- modules/c++/mt/CMakeLists.txt | 3 +-- modules/c++/re/CMakeLists.txt | 2 +- modules/drivers/CMakeLists.txt | 19 ++++++++++--------- 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/cmake/CodaBuild.cmake b/cmake/CodaBuild.cmake index 5e25fa752b..59272c9bb5 100644 --- a/cmake/CodaBuild.cmake +++ b/cmake/CodaBuild.cmake @@ -45,7 +45,7 @@ macro(coda_setup_msvc_crt) if (CONAN_PACKAGE_NAME) # conan handles this else() - set(STATIC_CRT OFF CACHE BOOL "use static CRT library /MT, or /MTd for Debug (/MD or /MDd if off)") + option(STATIC_CRT "use static CRT library /MT, or /MTd for Debug (/MD or /MDd if off)" OFF) if (STATIC_CRT) set(CODA_MSVC_RUNTIME "/MT") else() diff --git a/cmake/CodaFindSystemDependencies.cmake b/cmake/CodaFindSystemDependencies.cmake index 808361823e..0454d9958b 100644 --- a/cmake/CodaFindSystemDependencies.cmake +++ b/cmake/CodaFindSystemDependencies.cmake @@ -1,5 +1,12 @@ # find and import system dependencies macro(coda_find_system_dependencies) + # creates imported target Boost::serialization, if found + # see https://cmake.org/cmake/help/latest/module/FindBoost.html + # Nothing uses the boost flag? + option(ENABLE_BOOST "Enable building modules dependent on Boost" OFF) + + option(ENABLE_PYTHON "Enable building Python modules" ON) + option(ENABLE_SWIG "Enable generation of SWIG bindings" OFF) # creates imported target Threads::Threads # see https://cmake.org/cmake/help/latest/module/FindThreads.html set(THREADS_PREFER_PTHREAD_FLAG TRUE) @@ -9,9 +16,6 @@ macro(coda_find_system_dependencies) # see https://cmake.org/cmake/help/latest/module/FindCURL.html find_package(CURL) - # creates imported target Boost::serialization, if found - # see https://cmake.org/cmake/help/latest/module/FindBoost.html - set(ENABLE_BOOST OFF CACHE BOOL "Enable building modules dependent on Boost") # sets the following variables if Python installation found: # Python_FOUND - flag indicating system has the requested components @@ -32,10 +36,8 @@ macro(coda_find_system_dependencies) # Python_NumPy_INCLUDE_DIRS - NumPy include directories # # see https://cmake.org/cmake/help/latest/module/FindPython.html - set(ENABLE_PYTHON ON CACHE BOOL "Enable building Python modules") set(PYTHON_VERSION "" CACHE STRING "Hint for which version of Python to find") set(PYTHON_HOME "" CACHE PATH "Path to existing Python installation") - set(ENABLE_SWIG OFF CACHE BOOL "Enable generation of SWIG bindings") if (PYTHON_HOME) # specifying PYTHON_HOME implies ENABLE_PYTHON set(ENABLE_PYTHON ON CACHE BOOL "Enable building Python modules" FORCE) diff --git a/modules/c++/mt/CMakeLists.txt b/modules/c++/mt/CMakeLists.txt index 540c222472..162ae4ce75 100644 --- a/modules/c++/mt/CMakeLists.txt +++ b/modules/c++/mt/CMakeLists.txt @@ -1,7 +1,6 @@ set(MODULE_NAME mt) -set(MT_DEFAULT_PINNING OFF CACHE BOOL - "Use affinity-based CPU pinning by default in MT") +option(MT_DEFAULT_PINNING "Use affinity-based CPU pinning by default in MT" OFF) coda_generate_module_config_header(${MODULE_NAME}) coda_add_module( diff --git a/modules/c++/re/CMakeLists.txt b/modules/c++/re/CMakeLists.txt index 5142faea19..5449afd0e4 100644 --- a/modules/c++/re/CMakeLists.txt +++ b/modules/c++/re/CMakeLists.txt @@ -2,7 +2,7 @@ set(MODULE_NAME re) set(MODULE_DEPS sys-c++) # Enable to use std::regex instead of PCRE. -set(RE_ENABLE_STD_REGEX OFF CACHE BOOL "use std::regex instead of pcre") +option(RE_ENABLE_STD_REGEX "use std::regex instead of pcre" OFF) if (RE_ENABLE_STD_REGEX OR ENABLE_PCRE) coda_generate_module_config_header(${MODULE_NAME}) diff --git a/modules/drivers/CMakeLists.txt b/modules/drivers/CMakeLists.txt index e9aeba4a1a..1eaaf71f45 100644 --- a/modules/drivers/CMakeLists.txt +++ b/modules/drivers/CMakeLists.txt @@ -1,3 +1,13 @@ +# Declare options +option(ENABLE_XML "enable XML" ON) +option(ENABLE_J2K "enable J2K library" ON) +option(ENABLE_JARS "include jars in the install" ON) +option(ENABLE_JPEG "enable use of libjpeg" ON) +option(ENABLE_PCRE "enable PCRE library" ON) +option(ENABLE_UUID "enable UUID library" ON) +option(ENABLE_ZIP "enable zlib" ON) +option(CODA_ENABLE_HDF5 "enable hdf5" ON) + # Turn off all warnings; this is code we don't control. if (MSVC) add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS) @@ -13,8 +23,6 @@ endif() #add_subdirectory("curl") # this is handled in coda_find_system_dependencies #add_subdirectory("numpy") # this is handled in coda_find_system_dependencies - -set(ENABLE_XML ON CACHE BOOL "enable XML") if(NOT CONAN_PACKAGE_NAME) set(XML_HOME "" CACHE PATH "path to pre-existing XML library installation") if(ENABLE_XML OR XML_HOME) @@ -24,7 +32,6 @@ endif() #add_subdirectory("gsl") # nothing to do -set(ENABLE_J2K ON CACHE BOOL "enable J2K library") if(NOT CONAN_PACKAGE_NAME) set(J2K_HOME "" CACHE PATH "path to J2K installation") if (ENABLE_J2K OR J2K_HOME) @@ -32,12 +39,10 @@ if(NOT CONAN_PACKAGE_NAME) endif() endif() -set(ENABLE_JARS ON CACHE BOOL "include jars in the install") if (ENABLE_JARS) add_subdirectory("jars") endif() -set(ENABLE_JPEG ON CACHE BOOL "enable use of libjpeg") if (NOT CONAN_PACKAGE_NAME) set(JPEG_HOME "" CACHE PATH "path to libjpeg installation") if (ENABLE_JPEG OR JPEG_HOME) @@ -45,7 +50,6 @@ if (NOT CONAN_PACKAGE_NAME) endif() endif() -set(ENABLE_PCRE ON CACHE BOOL "enable PCRE library") if (NOT CONAN_PACKAGE_NAME) set(PCRE_HOME "" CACHE PATH "path to PCRE installation") if (ENABLE_PCRE OR PCRE_HOME) @@ -59,12 +63,10 @@ if (SQL_LAYER OR SQL_HOME) add_subdirectory("sql") endif() -set(ENABLE_UUID ON CACHE BOOL "enable UUID library") if (ENABLE_UUID OR UUID_HOME) add_subdirectory("uuid") endif() -set(ENABLE_ZIP ON CACHE BOOL "enable zlib") if (NOT CONAN_PACKAGE_NAME) set(ZIP_HOME "" CACHE PATH "path to pre-existing zlib installation, if not provided zlib will be built") if (ENABLE_ZIP OR ZIP_HOME) @@ -72,7 +74,6 @@ if (NOT CONAN_PACKAGE_NAME) endif() endif() -set(CODA_ENABLE_HDF5 ON CACHE BOOL "enable hdf5") set(CODA_HDF5_HOME "" CACHE PATH "path to pre-existing HDF5 installation, if not provided HDF5 will be built") if (CODA_ENABLE_HDF5 OR CODA_HDF5_HOME) add_subdirectory("hdf5")