From 5c526e45ad094c6b024eb41586f34b3e628a5610 Mon Sep 17 00:00:00 2001 From: Sean Bryan <39685865+SeanBryan51@users.noreply.github.com> Date: Wed, 17 Apr 2024 14:42:41 +1000 Subject: [PATCH] Unset LDFLAGS and CMAKE_PREFIX_PATH variables (#282) CABLE is linked against incorrect libraries for netcdf and MPI when running benchcab (v4.0.2) from the hh5 conda environment. The issue is due to environment variables being set which affect the behaviour of the build, notably LDFLAGS and CMAKE_PREFIX_PATH, which point CMake to find the netcdf and MPI libraries installed in the current conda environment. This change unsets these variables so that CMake finds the appropriate libraries which get loaded in as modules. Fixes #279 --- src/benchcab/model.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/benchcab/model.py b/src/benchcab/model.py index 52deafe..9bc6485 100644 --- a/src/benchcab/model.py +++ b/src/benchcab/model.py @@ -129,6 +129,15 @@ def build(self, modules: list[str], mpi=False): [internal.CMAKE_MODULE, *modules] ): env = os.environ.copy() + + # This is required to prevent CMake from finding the conda + # installation of netcdf-fortran (#279): + env.pop("LDFLAGS", None) + + # This is required to prevent CMake from finding MPI libraries in + # the conda environment (#279): + env.pop("CMAKE_PREFIX_PATH", None) + # This is required so that the netcdf-fortran library is discoverable by # pkg-config: prepend_path(