Skip to content

Commit

Permalink
Guard all Find modules from repetition so users don't have to
Browse files Browse the repository at this point in the history
Fix mpas netcdf dep, should be public
  • Loading branch information
jgfouca committed Sep 28, 2023
1 parent 1de6606 commit 3fcd94e
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 9 deletions.
6 changes: 2 additions & 4 deletions components/cmake/common_setup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,8 @@ endif()
# Have to do this here for now because the macros must be loaded in order for
# the netcdf cmake variables to be set. Once scorpio has a good package-config,
# this won't be necessary
if (NOT TARGET netcdf)
find_package(NETCDF REQUIRED)
target_link_libraries(spio INTERFACE netcdf)
endif()
find_package(NETCDF REQUIRED)
target_link_libraries(spio INTERFACE netcdf)

# Set HAVE_SLASHPROC on LINUX systems which are not bluegene or Darwin (OSx)
string(FIND "${CPPDEFS}" "-DLINUX" HAS_DLINUX)
Expand Down
11 changes: 7 additions & 4 deletions components/cmake/modules/FindCsmShare.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
# The "csm_share" target
#

if (TARGET csm_share)
return()
endif()

# Build the name of the path where libcsm_share should be located
if (USE_ESMF_LIB)
set(ESMFDIR "esmf")
Expand All @@ -22,10 +26,9 @@ set(CSM_SHARE "${INSTALL_SHAREDPATH}/${COMP_INTERFACE}/${ESMFDIR}/${NINST_VALUE}
# Look for libcsm_share in the complex path we built above
find_library(CSM_SHARE_LIB csm_share REQUIRED PATHS ${CSM_SHARE})

# Grab mct if we don't already have it
if (NOT TARGET mct)
find_package(MCT REQUIRED)
endif()
# Grab mct and spio if we don't already have it
find_package(MCT REQUIRED)
find_package(PIO REQUIRED)

# Create the interface library, and set target properties
add_library (csm_share INTERFACE)
Expand Down
4 changes: 4 additions & 0 deletions components/cmake/modules/FindMCT.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
# The "mct" target
#

if (TARGET mct)
return()
endif()

# Look for libmct in INSTALL_SHAREDPATH/lib
find_library(MCT_LIB mct REQUIRED PATHS ${INSTALL_SHAREDPATH}/lib)
find_library(MPEU_LIB mpeu REQUIRED PATHS ${INSTALL_SHAREDPATH}/lib $ENV{mct_ROOT})
Expand Down
4 changes: 4 additions & 0 deletions components/cmake/modules/FindNETCDF.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
# The "netcdf" target
#

if (TARGET netcdf)
return()
endif()

# Pnetcdf is optional, and only if not running serial
if (NOT MPILIB STREQUAL mpi-serial)
if (PNETCDF_PATH)
Expand Down
4 changes: 4 additions & 0 deletions components/cmake/modules/FindPIO.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
# The "spio" target
#

if (TARGET spio)
return()
endif()

if (NOT PIO_LIBDIR)
set(PIO_LIBDIR "${INSTALL_SHAREDPATH}/lib")
endif()
Expand Down
3 changes: 2 additions & 1 deletion components/mpas-framework/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/operators/operators.cmake)
add_library(common)
target_compile_definitions(common PRIVATE ${CPPDEFS})
target_include_directories(common PRIVATE ${INCLUDES})
target_link_libraries(common PRIVATE netcdf)
find_package(NETCDF REQUIRED)
target_link_libraries(common PUBLIC netcdf)

genf90_targets("${COMMON_RAW_SOURCES}" "${INCLUDES}" "${CPPDEFS}" "" "")
target_sources(common PRIVATE ${SOURCES})
Expand Down

0 comments on commit 3fcd94e

Please sign in to comment.