Skip to content

Commit

Permalink
Fix non-Baselibs build
Browse files Browse the repository at this point in the history
  • Loading branch information
mathomp4 committed Mar 27, 2024
1 parent 486b72f commit b3cf531
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 25 deletions.
9 changes: 7 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@
CMakeUserPresets.json

# Ignore possible symlinked build and install directories
build-*
install-*
# Note: we can't use a / at the end because they might be
# symlink to a directory
build*
install*

# If you build with spack libraries, you can get spack log files
spack*.log

*.swp
*.swo
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed bug with split restart files
- Removed unnecessary memory allocation for tile reads. This is critical for high res runs on SCU17
- Fixes to allow SCM model to run
- Fixed non-Baselibs build using `ESMF::ESMF` target

### Removed

Expand Down
17 changes: 2 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,21 +148,8 @@ if (NOT Baselibs_FOUND)
endif()

if (NOT TARGET ESMF::ESMF)
find_package(ESMF 8.6.0 MODULE REQUIRED)

# ESMF as used in MAPL requires MPI
# NOTE: This looks odd because some versions of FindESMF.cmake out in the
# world provide an "esmf" target while others provide "ESMF". So we
# need this ugliness to support both.
if (TARGET ESMF::ESMF)
target_link_libraries(ESMF::ESMF INTERFACE MPI::MPI_Fortran)
else()
target_link_libraries(ESMF::ESMF INTERFACE MPI::MPI_Fortran)
# MAPL and GEOS use lowercase target due to historical reasons but
# the latest FindESMF.cmake file from ESMF produces an ESMF target.
add_library(ESMF::ESMF ALIAS ESMF)
add_library(ESMF::ESMF ALIAS esmf)
endif()
find_package(ESMF 8.6.1 MODULE REQUIRED)
target_link_libraries(ESMF::ESMF INTERFACE MPI::MPI_Fortran)
endif ()
else ()
# This is an ESMF version test when using Baselibs which doesn't use the
Expand Down
16 changes: 8 additions & 8 deletions cmake/FindESMF.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -96,22 +96,22 @@ if(EXISTS ${ESMFMKFILE})
message(WARNING "Static ESMF library (libesmf.a) not found in \
${ESMF_LIBSDIR}. Try setting USE_ESMF_STATIC_LIBS=OFF")
endif()
if(NOT TARGET ESMF)
add_library(ESMF STATIC IMPORTED)
if(NOT TARGET ESMF::ESMF)
add_library(ESMF::ESMF STATIC IMPORTED)
endif()
else()
find_library(ESMF_LIBRARY_LOCATION NAMES esmf PATHS ${ESMF_LIBSDIR} NO_DEFAULT_PATH)
if(ESMF_LIBRARY_LOCATION MATCHES "ESMF_LIBRARY_LOCATION-NOTFOUND")
message(WARNING "ESMF library not found in ${ESMF_LIBSDIR}.")
endif()
if(NOT TARGET ESMF)
add_library(ESMF UNKNOWN IMPORTED)
if(NOT TARGET ESMF::ESMF)
add_library(ESMF::ESMF UNKNOWN IMPORTED)
endif()
endif()

# Add target alias to facilitate unambiguous linking
if(NOT TARGET ESMF::ESMF)
add_library(ESMF::ESMF ALIAS ESMF)
# Add ESMF as an alias to ESMF::ESMF for backward compatibility
if(NOT TARGET ESMF)
add_library(ESMF ALIAS ESMF::ESMF)
endif()

# Add ESMF include directories
Expand All @@ -135,7 +135,7 @@ if(EXISTS ${ESMFMKFILE})
ESMF_F90COMPILEPATHS
VERSION_VAR ESMF_VERSION)

set_target_properties(ESMF PROPERTIES
set_target_properties(ESMF::ESMF PROPERTIES
IMPORTED_LOCATION "${ESMF_LIBRARY_LOCATION}"
INTERFACE_INCLUDE_DIRECTORIES "${ESMF_INCLUDE_DIRECTORIES}"
INTERFACE_LINK_LIBRARIES "${ESMF_INTERFACE_LINK_LIBRARIES}")
Expand Down

0 comments on commit b3cf531

Please sign in to comment.