diff --git a/.github/actions/ngen-build/action.yaml b/.github/actions/ngen-build/action.yaml index da90a7352e..dd7ecdebef 100644 --- a/.github/actions/ngen-build/action.yaml +++ b/.github/actions/ngen-build/action.yaml @@ -39,6 +39,10 @@ inputs: required: false description: 'Activate NetCDF Lumped Forcing Support' default: 'ON' + use_sqlite: + required: false + description: 'Activate SQLite3 suppport for GeoPackage' + default: 'ON' use_troute: required: false description: 'Enable t-route integration support' @@ -176,6 +180,7 @@ runs: -DBMI_FORTRAN_ACTIVE:BOOL=${{ inputs.bmi_fortran }} \ -DNGEN_ACTIVATE_ROUTING:BOOL=${{ inputs.use_troute }} \ -DNETCDF_ACTIVE:BOOL=${{ inputs.use_netcdf }} \ + -DNGEN_WITH_SQLITE:BOOL=${{ inputs.use_sqlite }} \ -DMPI_ACTIVE:BOOL=${{ inputs.use_mpi }} -S . echo "build-dir=$(echo ${{ inputs.build-dir }})" >> $GITHUB_OUTPUT shell: bash diff --git a/.gitignore b/.gitignore index d75b9abf4b..20ffa96238 100644 --- a/.gitignore +++ b/.gitignore @@ -99,6 +99,9 @@ CMakeCache.txt /build /cmake_build* +# Prevent ignoring cmake modules +!cmake/**/*.cmake + # Static Headers include/bmi.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e44af1020..88cab046e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,238 +1,205 @@ -cmake_minimum_required(VERSION 3.14) +# Ensure CMake policies have defaults depending on the CMake version used +# between the two versions specified. e.g. if 3.18 is used, then 3.18 defaults +# will be used instead of 3.17 defaults. +cmake_minimum_required(VERSION 3.17...3.26) +# Policies ==================================================================== # Use `LOCATION` for python lookup strategy # https://cmake.org/cmake/help/latest/policy/CMP0094.html -if(POLICY CMP0094) - cmake_policy(SET CMP0094 NEW) -endif() +cmake_policy(SET CMP0094 NEW) + +# find_package() uses _ROOT variables. +# https://cmake.org/cmake/help/latest/policy/CMP0074.html +cmake_policy(SET CMP0074 NEW) -if(MPI_ACTIVE) - set (CMAKE_CXX_COMPILER "mpicxx") +# find_package() uses upper-case _ROOT variables in conjunction with CMP0074. +# https://cmake.org/cmake/help/latest/policy/CMP0144.html +if(POLICY CMP0144) + cmake_policy(SET CMP0144 NEW) endif() -########### Define project version and use via generated config header +# Project Variables =========================================================== +set(NGEN_ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}") +set(NGEN_SRC_DIR "${NGEN_ROOT_DIR}/src") +set(NGEN_INC_DIR "${NGEN_ROOT_DIR}/include") +set(NGEN_EXT_DIR "${NGEN_ROOT_DIR}/extern") +set(NGEN_MOD_DIR "${NGEN_ROOT_DIR}/cmake") +list(APPEND CMAKE_MODULE_PATH "${NGEN_MOD_DIR}") + +# Provides: +# (1) finds Git package +# (2) Sets ${NGEN_HAS_GIT_DIR} to ON/OFF if ${NGEN_ROOT_DIR}/.git exists +# (3) Function `git_update_submodule` which updates a given submodule +include(GitUpdateSubmodules) + +# Options ===================================================================== +include(CMakeDependentOption) + +option(NGEN_WITH_MPI "Build with MPI support" OFF) +option(NGEN_WITH_NETCDF "Build with NetCDF support" ON) +option(NGEN_WITH_SQLITE "Build with SQLite3 support" OFF) +option(NGEN_WITH_UDUNITS "Build with UDUNITS2 support" ON) +option(NGEN_WITH_BMI_FORTRAN "Build with Fortran BMI support" OFF) +option(NGEN_WITH_BMI_C "Build with C BMI support" ON) +option(NGEN_WITH_PYTHON "Build with embedded Python support" OFF) +option(NGEN_WITH_TESTS "Build with unit tests" ON) +option(NGEN_QUIET "Silence output" OFF) + +# These options require dependency on some of the above options +# Syntax: cmake_dependent_option(