Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search for static ESMF library first, set NETCDF cmake variable if environment variable is set #23

Merged
merged 2 commits into from
Feb 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions Modules/FindESMF.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,21 @@ if (ESMF_FOUND)
set(ESMF_F90COMPILEPATHS ${tmp})

add_library(esmf UNKNOWN IMPORTED)
find_library(esmf_lib NAMES esmf_fullylinked PATHS ${ESMF_LIBSDIR})
# Look for static library, if not found try dynamic library
find_library(esmf_lib NAMES libesmf.a PATHS ${ESMF_LIBSDIR})
if(esmf_lib MATCHES "esmf_lib-NOTFOUND")
message(STATUS "Dynamic/fully-linked ESMF library not found, searching for static library instead")
find_library(esmf_lib NAMES esmf PATHS ${ESMF_LIBSDIR})
message(STATUS "Static ESMF library not found, searching for dynamic library instead")
find_library(esmf_lib NAMES esmf_fullylinked PATHS ${ESMF_LIBSDIR})
if(esmf_lib MATCHES "esmf_lib-NOTFOUND")
message(WARNING "Neither the dynamic nor the static ESMF library was found")
else()
message(STATUS "Found ESMF library: ${esmf_lib}")
endif()
set(ESMF_INTERFACE_LINK_LIBRARIES "")
else()
# When linking the static library, also need the ESMF linker flags; strip any leading/trailing whitespaces
string(STRIP "${ESMF_F90ESMFLINKRPATHS} ${ESMF_F90ESMFLINKPATHS} ${ESMF_F90LINKLIBS} ${ESMF_F90LINKOPTS}" ESMF_INTERFACE_LINK_LIBRARIES)
else()
set(ESMF_INTERFACE_LINK_LIBRARIES "")
message(STATUS "Found ESMF library: ${esmf_lib}")
endif()

set_target_properties(esmf PROPERTIES
Expand Down
1 change: 1 addition & 0 deletions Modules/FindNetCDF.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ if(DEFINED NETCDF)
set(NETCDF_DIR ${NETCDF})
elseif(DEFINED ENV{NETCDF})
set(NETCDF_DIR $ENV{NETCDF})
set(NETCDF $ENV{NETCDF})
endif()
if(DEFINED ENV{NETCDF_FORTRAN})
set(NETCDF_FORTRAN $ENV{NETCDF_FORTRAN})
Expand Down