From 4a96b21fc4991bb6ce4f019107cb8b02b43e273c Mon Sep 17 00:00:00 2001 From: program-- Date: Wed, 6 Sep 2023 13:13:55 -0700 Subject: [PATCH 01/39] cmake: reorg root CMakeLists; rm unused FindNetCDF; update FindUDUNITS2 --- CMakeLists.txt | 419 ++++++++++++++++--------------- cmake/FindNetCDF.cmake | 131 ---------- cmake/modules/FindUDUNITS2.cmake | 18 +- src/core/mediator/CMakeLists.txt | 4 +- 4 files changed, 233 insertions(+), 339 deletions(-) delete mode 100644 cmake/FindNetCDF.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e44af1020..b60bdf046f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,225 +1,198 @@ -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. +# 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}/modules") + +# 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" ON) +option(NGEN_WITH_UDUNITS "Build with UDUNITS2 support" ON) +option(NGEN_WITH_BMI_FORTRAN "Build with Fortran BMI support" ON) +option(NGEN_WITH_BMI_C "Build with C BMI support" ON) +option(NGEN_WITH_PYTHON "Build with embedded Python support" ON) +option(NGEN_WITH_TESTS "Build with unit tests" ON) + +# These options require dependency on some of the above options +# Syntax: cmake_dependent_option(