@@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.4)
22
33list (APPEND CMAKE_MODULE_PATH ${CIME_CMAKE_MODULE_DIRECTORY} )
44list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR} /../../share/cmake" )
5+ list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR} /../components/cmeps/cmake" )
56
67FIND_PATH (NETCDFC_FOUND libnetcdf.a ${NETCDF_C_DIR} /lib)
78FIND_PATH (NETCDFF_FOUND libnetcdff.a ${NETCDF_FORTRAN_DIR} /lib)
@@ -19,6 +20,23 @@ include(CIME_utils)
1920
2021set (HLM_ROOT "../../" )
2122
23+ if (DEFINED ENV{ESMF_ROOT})
24+ list (APPEND CMAKE_MODULE_PATH $ENV{ESMF_ROOT} /cmake)
25+ endif ()
26+ find_package (ESMF REQUIRED)
27+
28+ # This adds include directories needed for ESMF
29+ set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${ESMF_F90COMPILEPATHS} " )
30+ # This (which is *not* done in the share CMakeLists.txt) adds all directories and
31+ # libraries needed when linking ESMF, including any dependencies of ESMF. (But note that
32+ # this does *not* include the "-lesmf" itself). In particular, note that this includes any
33+ # link flags needed to link against PIO, which is needed on some systems (including
34+ # derecho); bringing in these PIO-related link flags via this ESMF mechanism allows us to
35+ # avoid explicitly including PIO as a link library, which wouldn't work on systems where
36+ # there is no separate PIO library and instead ESMF is built with its internal PIO
37+ # library.
38+ link_libraries (${ESMF_INTERFACE_LINK_LIBRARIES} )
39+
2240# Add source directories from other share code (csm_share, etc.)
2341add_subdirectory (${HLM_ROOT} /share/src csm_share)
2442add_subdirectory (${HLM_ROOT} /share/unit_test_stubs/util csm_share_stubs)
@@ -90,6 +108,7 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR})
90108
91109# Directories and libraries to include in the link step
92110link_directories (${CMAKE_CURRENT_BINARY_DIR} )
111+ link_libraries (esmf)
93112
94113# Add the main test directory
95114add_subdirectory (${HLM_ROOT} /src/fates/testing)
0 commit comments