Skip to content

Commit

Permalink
Unset LDFLAGS and CMAKE_PREFIX_PATH variables (#282)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
SeanBryan51 authored Apr 17, 2024
1 parent 8ca400f commit 5c526e4
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/benchcab/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 5c526e4

Please sign in to comment.