v5: Split external library configuration out of FindBaselibs.cmake - #560
Open
mathomp4 wants to merge 7 commits into
Open
v5: Split external library configuration out of FindBaselibs.cmake#560mathomp4 wants to merge 7 commits into
mathomp4 wants to merge 7 commits into
Conversation
Move NetCDF/HDF5/ESMF/FMS dependency-target creation out of FindBaselibs.cmake into two new files: - ConfigureBaselibs.cmake: creates targets from a Baselibs install - ConfigureExternalLibraries.cmake: creates the same targets via find_package() for Spack or other non-Baselibs package managers FindBaselibs.cmake now only detects BASEDIR and sets Baselibs_FOUND. The top-level project includes whichever configuration file matches Baselibs_FOUND, removing the need to duplicate the non-Baselibs find_package() calls in every project's CMakeLists.txt. This mirrors the same split done on release/v4 (feature/v4-external-libs), adapted for v5's single-precision FMS::fms target (no FMS::fms_r4/fms_r8 split, no FV_PRECISION-based component selection).
|
This PR is being prevented from merging because you have not added one of our required labels: 0 diff, 0 diff trivial, Non 0-diff, 0 diff structural, 0-diff trivial, Not 0-diff, 0-diff, automatic, 0-diff uncoupled, github_actions. Please add one so that the PR can be merged. |
Rather than requiring every top-level project's CMakeLists.txt to include(ConfigureBaselibs) or include(ConfigureExternalLibraries) based on Baselibs_FOUND, do it automatically in esma.cmake right after FindBaselibs is included. Top-level projects that previously had an inline 'if (NOT Baselibs_FOUND) ... endif()' block for Spack support can simply remove it.
Some ZLIB providers (e.g. zlib-ng's CMake config package used by certain Spack stacks) already export a target literally named ZLIB::zlib, causing the unconditional add_library(... ALIAS ...) call to fail with 'target already exists'. Guard it like the ESMF aliases.
Projects like MAPL don't use FMS, so don't require it via find_package when the project hasn't set FV_PRECISION. This mirrors the existing convention already used in ConfigureBaselibs.cmake for the Baselibs case.
Baselibs' esmf.mk has no CMake-style version string, so find_package() cannot enforce a minimum version the way ConfigureExternalLibraries.cmake does. Check ESMF_VERSION explicitly instead so Baselibs and Spack builds enforce the same 8.6.1 minimum.
Instead of hardcoding an 8.6.1 minimum in both ConfigureBaselibs.cmake and ConfigureExternalLibraries.cmake, consult a single ESMA_ESMF_MIN_VERSION variable that esma.cmake defaults to 8.6.1 if unset. Downstream projects with stricter requirements (e.g. MAPL3 needing ESMF 9.0.0) can now just set(ESMA_ESMF_MIN_VERSION 9.0.0) before include(esma) instead of writing their own version-guard boilerplate for both the Baselibs and Spack cases.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
FindBaselibs.cmakeinto two new files:external_libraries/ConfigureBaselibs.cmake: creates targets from a Baselibs installexternal_libraries/ConfigureExternalLibraries.cmake: creates the same targets viafind_package()for Spack or other non-Baselibs package managersFindBaselibs.cmakenow only detectsBASEDIRand setsBaselibs_FOUNDesma.cmakeautomaticallyinclude()s the right one (ConfigureBaselibsorConfigureExternalLibraries) based onBaselibs_FOUND, right afterinclude(FindBaselibs)CHANGELOG.mdunder[Unreleased]This mirrors #559 (
feature/v4-external-libstargetingrelease/v4), adapted for v5's single-precisionFMS::fmstarget (noFMS::fms_r4/FMS::fms_r8split, noFV_PRECISION-based component selection infind_package(FMS ...)).Because the dispatch now lives in
esma.cmake, downstream projects (like GEOSgcm) don't need to add anything to their top-levelCMakeLists.txt. The only change needed there is to remove the old inline Spack/non-Baselibs block, e.g.:Fixes since initial version
ZLIB::zlibalias creation withif(NOT TARGET ZLIB::zlib)inConfigureExternalLibraries.cmake; some ZLIB providers (e.g. zlib-ng's CMake config package) already export a target with that exact name.ConfigureExternalLibraries.cmake, only look for FMS viafind_packagewhenFV_PRECISIONis defined. Library projects like MAPL don't use FMS and don't setFV_PRECISION, so they're no longer forced to have it installed. This mirrors the existingFV_PRECISIONconvention already used inConfigureBaselibs.cmakefor the Baselibs case.ConfigureBaselibs.cmake, enforce a minimum ESMF version (matchingConfigureExternalLibraries.cmake) by checkingESMF_VERSIONexplicitly, since Baselibs'esmf.mkhas no CMake-style version string forfind_package()to check.ESMA_ESMF_MIN_VERSIONvariable (default8.6.1), settable by a downstream project beforeinclude(esma), so projects with stricter ESMF requirements (e.g. MAPL3 needing 9.0.0) don't need their own version-guard boilerplate.Test plan