Skip to content

Commit

Permalink
Merge pull request #2493 from boutproject/cmake-netcdf-fixes
Browse files Browse the repository at this point in the history
CMake fixes for netCDF
  • Loading branch information
ZedThree authored Feb 1, 2022
2 parents 97509a3 + f292ae5 commit 1c44d41
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 9 additions & 1 deletion bout++Config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,18 @@ endif()
if(EXISTS "@ScoreP_ROOT@")
set(ScoreP_ROOT "@ScoreP_ROOT@")
endif()
if(EXISTS "@netCDF_ROOT@")
set(netCDF_ROOT "@netCDF_ROOT@")
elseif(EXISTS "@NC_CONFIG@")
set(NC_CONFIG "@NC_CONFIG@")
endif()
if(EXISTS "@netCDFCxx_ROOT@")
set(netCDFCxx_ROOT "@netCDFCxx_ROOT@")
elseif(EXISTS "@NCXX4_CONFIG@")
set(NCXX4_CONFIG "@NCXX4_CONFIG@")
elseif(EXISTS "@NCXX_BINARY_DIR@")
list(APPEND CMAKE_PREFIX_PATH "@NCXX_BINARY_DIR@")
# If we downloaded netCDF-cxx4, then we need to add its build directory to our search paths
list(APPEND CMAKE_PREFIX_PATH "@NCXX_BINARY_DIR@")
endif()
if(EXISTS "@HDF5F_ROOT@")
set(HDF5F_ROOT "@HDF5F_ROOT@")
Expand Down
4 changes: 3 additions & 1 deletion cmake/FindnetCDFCxx.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ mark_as_advanced(netCDF_CXX_LIBRARY)

bout_inspect_netcdf_config(_ncxx4_version "${NCXX4_CONFIG}" "--version")
if (_ncxx4_version)
string(REGEX REPLACE "netCDF-cxx4 \([0-9]+\.[0-9]+\.[0-9]+\)" "\\1" netCDFCxx_VERSION "${_ncxx4_version}")
# Change to lower case before matching, to avoid case problems
string(TOLOWER "${_ncxx4_version}" _ncxx4_version_lower)
string(REGEX REPLACE "netcdf-cxx4 \([0-9]+\\.[0-9]+\\.[0-9]+\).*" "\\1" netCDFCxx_VERSION "${_ncxx4_version_lower}")
message(STATUS "Found netCDFCxx version ${netCDFCxx_VERSION}")
else ()
message(WARNING "Couldn't get NetCDF version")
Expand Down

0 comments on commit 1c44d41

Please sign in to comment.