From 551e32fc8ce9c1fd0ff6f1dbffd0116635cd3636 Mon Sep 17 00:00:00 2001 From: ulmononian Date: Tue, 20 Jun 2023 14:45:14 -0500 Subject: [PATCH 1/6] Updates to allow for shared scotch. --- cmake/FindSCOTCH.cmake | 17 +++++++++++------ model/src/CMakeLists.txt | 14 ++++++++++---- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/cmake/FindSCOTCH.cmake b/cmake/FindSCOTCH.cmake index c2a3272f4..5b8307232 100644 --- a/cmake/FindSCOTCH.cmake +++ b/cmake/FindSCOTCH.cmake @@ -1,28 +1,33 @@ -message(STATUS "Searching for PTSCOTCHparmetis library ...") -find_library(ptscotchparmetis_lib NAMES libptscotchparmetisv3.a HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib) +sage(STATUS "Searching for PTSCOTCHparmetis library ...") +find_library(ptscotchparmetis_lib NAMES libptscotchparmetisv3 HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib) find_path(ptscotchparmetis_inc parmetis.h HINTS ENV SCOTCH_PATH PATH_SUFFIXES include) message(STATUS "Searching for SCOTCH library ...") -find_library(scotch_lib NAMES libscotch.a HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib) +find_library(scotch_lib NAMES libscotch HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib) find_path(scotch_inc scotch.h HINTS ENV SCOTCH_PATH PATH_SUFFIXES include) message(STATUS "Searching for PTSCOTCH library ...") -find_library(ptscotch_lib NAMES libptscotch.a HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib) +find_library(ptscotch_lib NAMES libptscotch HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib) find_path(ptscotch_inc ptscotch.h HINTS ENV SCOTCH_PATH PATH_SUFFIXES include) message(STATUS "Searching for SCOTCHerr library ...") -find_library(scotcherr_lib NAMES libscotcherr.a HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib) +find_library(scotcherr_lib NAMES libscotcherr HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib) find_path(scotcherr_inc scotch.h HINTS ENV SCOTCH_PATH PATH_SUFFIXES include) message(STATUS "Searching for PTSCOTCHerr library ...") -find_library(ptscotcherr_lib NAMES libptscotcherr.a HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib) +find_library(ptscotcherr_lib NAMES libptscotcherr HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib) find_path(ptscotcherr_inc ptscotch.h HINTS ENV SCOTCH_PATH PATH_SUFFIXES include) add_library(PTSCOTCHparmetis::PTSCOTCHparmetis STATIC IMPORTED) +add_library(PTSCOTCHparmetis::PTSCOTCHparmetis SHARED IMPORTED) add_library(SCOTCH::SCOTCH STATIC IMPORTED) +add_library(SCOTCH::SCOTCH SHARED IMPORTED) add_library(PTSCOTCH::PTSCOTCH STATIC IMPORTED) +add_library(PTSCOTCH::PTSCOTCH SHARED IMPORTED) add_library(SCOTCHerr::SCOTCHerr STATIC IMPORTED) +add_library(SCOTCHerr::SCOTCHerr SHARED IMPORTED) add_library(PTSCOTCHerr::PTSCOTCHerr STATIC IMPORTED) +add_library(PTSCOTCHerr::PTSCOTCHerr SHARED IMPORTED) set_target_properties(SCOTCH::SCOTCH PROPERTIES IMPORTED_LOCATION "${scotch_lib}" diff --git a/model/src/CMakeLists.txt b/model/src/CMakeLists.txt index 7dd7d82a2..c11220053 100644 --- a/model/src/CMakeLists.txt +++ b/model/src/CMakeLists.txt @@ -126,18 +126,23 @@ if(NetCDF_Fortran_FOUND) list(APPEND programs ${netcdf_programs}) endif() -if(MULTI_ESMF) +if(UFS_CAP) # Don't search for ESMF if target already exists (when build WW3 as UFS submodule) if (NOT TARGET esmf) find_package(ESMF MODULE REQUIRED) endif() + + if(UFS_CAP STREQUAL "MULTI_ESMF") + set(cap_src ${esmf_multi_cap_src}) + elseif(UFS_CAP STREQUAL "NUOPC_MESH") + set(cap_src ${nuopc_mesh_cap_src}) + endif() - target_sources(ww3_lib PRIVATE wmesmfmd.F90) + target_sources(ww3_lib PRIVATE ${cap_src}) target_link_libraries(ww3_lib PUBLIC esmf) - set_target_properties(ww3_lib PROPERTIES OUTPUT_NAME "ww3_multi_esmf") # Don't build executables when building WW3 ESMF library set(programs "") -endif() +endif() set_property(SOURCE w3initmd.F90 APPEND @@ -158,6 +163,7 @@ endif() # Handle PDLIB, SCRIP, SCRIPNC build files directly instead of through configuration file if("PDLIB" IN_LIST switches) if("SCOTCH" IN_LIST switches) + set(USE_SHARED_SCOTCH OFF) find_package(SCOTCH REQUIRED) target_sources(ww3_lib PRIVATE ${pdlib_src}) target_link_libraries(ww3_lib PUBLIC PTSCOTCHparmetis::PTSCOTCHparmetis) From 4da539c76e52a6aac61da8af6eb58ee283f8cf8e Mon Sep 17 00:00:00 2001 From: ulmononian Date: Tue, 20 Jun 2023 14:47:32 -0500 Subject: [PATCH 2/6] Revert "Updates to allow for shared scotch." This reverts commit 551e32fc8ce9c1fd0ff6f1dbffd0116635cd3636. --- cmake/FindSCOTCH.cmake | 17 ++++++----------- model/src/CMakeLists.txt | 14 ++++---------- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/cmake/FindSCOTCH.cmake b/cmake/FindSCOTCH.cmake index 5b8307232..c2a3272f4 100644 --- a/cmake/FindSCOTCH.cmake +++ b/cmake/FindSCOTCH.cmake @@ -1,33 +1,28 @@ -sage(STATUS "Searching for PTSCOTCHparmetis library ...") -find_library(ptscotchparmetis_lib NAMES libptscotchparmetisv3 HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib) +message(STATUS "Searching for PTSCOTCHparmetis library ...") +find_library(ptscotchparmetis_lib NAMES libptscotchparmetisv3.a HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib) find_path(ptscotchparmetis_inc parmetis.h HINTS ENV SCOTCH_PATH PATH_SUFFIXES include) message(STATUS "Searching for SCOTCH library ...") -find_library(scotch_lib NAMES libscotch HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib) +find_library(scotch_lib NAMES libscotch.a HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib) find_path(scotch_inc scotch.h HINTS ENV SCOTCH_PATH PATH_SUFFIXES include) message(STATUS "Searching for PTSCOTCH library ...") -find_library(ptscotch_lib NAMES libptscotch HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib) +find_library(ptscotch_lib NAMES libptscotch.a HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib) find_path(ptscotch_inc ptscotch.h HINTS ENV SCOTCH_PATH PATH_SUFFIXES include) message(STATUS "Searching for SCOTCHerr library ...") -find_library(scotcherr_lib NAMES libscotcherr HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib) +find_library(scotcherr_lib NAMES libscotcherr.a HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib) find_path(scotcherr_inc scotch.h HINTS ENV SCOTCH_PATH PATH_SUFFIXES include) message(STATUS "Searching for PTSCOTCHerr library ...") -find_library(ptscotcherr_lib NAMES libptscotcherr HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib) +find_library(ptscotcherr_lib NAMES libptscotcherr.a HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib) find_path(ptscotcherr_inc ptscotch.h HINTS ENV SCOTCH_PATH PATH_SUFFIXES include) add_library(PTSCOTCHparmetis::PTSCOTCHparmetis STATIC IMPORTED) -add_library(PTSCOTCHparmetis::PTSCOTCHparmetis SHARED IMPORTED) add_library(SCOTCH::SCOTCH STATIC IMPORTED) -add_library(SCOTCH::SCOTCH SHARED IMPORTED) add_library(PTSCOTCH::PTSCOTCH STATIC IMPORTED) -add_library(PTSCOTCH::PTSCOTCH SHARED IMPORTED) add_library(SCOTCHerr::SCOTCHerr STATIC IMPORTED) -add_library(SCOTCHerr::SCOTCHerr SHARED IMPORTED) add_library(PTSCOTCHerr::PTSCOTCHerr STATIC IMPORTED) -add_library(PTSCOTCHerr::PTSCOTCHerr SHARED IMPORTED) set_target_properties(SCOTCH::SCOTCH PROPERTIES IMPORTED_LOCATION "${scotch_lib}" diff --git a/model/src/CMakeLists.txt b/model/src/CMakeLists.txt index c11220053..7dd7d82a2 100644 --- a/model/src/CMakeLists.txt +++ b/model/src/CMakeLists.txt @@ -126,23 +126,18 @@ if(NetCDF_Fortran_FOUND) list(APPEND programs ${netcdf_programs}) endif() -if(UFS_CAP) +if(MULTI_ESMF) # Don't search for ESMF if target already exists (when build WW3 as UFS submodule) if (NOT TARGET esmf) find_package(ESMF MODULE REQUIRED) endif() - - if(UFS_CAP STREQUAL "MULTI_ESMF") - set(cap_src ${esmf_multi_cap_src}) - elseif(UFS_CAP STREQUAL "NUOPC_MESH") - set(cap_src ${nuopc_mesh_cap_src}) - endif() - target_sources(ww3_lib PRIVATE ${cap_src}) + target_sources(ww3_lib PRIVATE wmesmfmd.F90) target_link_libraries(ww3_lib PUBLIC esmf) + set_target_properties(ww3_lib PROPERTIES OUTPUT_NAME "ww3_multi_esmf") # Don't build executables when building WW3 ESMF library set(programs "") -endif() +endif() set_property(SOURCE w3initmd.F90 APPEND @@ -163,7 +158,6 @@ endif() # Handle PDLIB, SCRIP, SCRIPNC build files directly instead of through configuration file if("PDLIB" IN_LIST switches) if("SCOTCH" IN_LIST switches) - set(USE_SHARED_SCOTCH OFF) find_package(SCOTCH REQUIRED) target_sources(ww3_lib PRIVATE ${pdlib_src}) target_link_libraries(ww3_lib PUBLIC PTSCOTCHparmetis::PTSCOTCHparmetis) From 3efeb62b881904608fe5e4babfcc159fd3a33a7b Mon Sep 17 00:00:00 2001 From: ulmononian Date: Tue, 20 Jun 2023 14:57:21 -0500 Subject: [PATCH 3/6] Updates to use shared scotch. --- cmake/FindSCOTCH.cmake | 29 +++++++++++++++++++---------- model/src/CMakeLists.txt | 1 + 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/cmake/FindSCOTCH.cmake b/cmake/FindSCOTCH.cmake index c2a3272f4..5644ac3b8 100644 --- a/cmake/FindSCOTCH.cmake +++ b/cmake/FindSCOTCH.cmake @@ -1,28 +1,37 @@ message(STATUS "Searching for PTSCOTCHparmetis library ...") -find_library(ptscotchparmetis_lib NAMES libptscotchparmetisv3.a HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib) +find_library(ptscotchparmetis_lib NAMES libptscotchparmetisv3 HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib) find_path(ptscotchparmetis_inc parmetis.h HINTS ENV SCOTCH_PATH PATH_SUFFIXES include) message(STATUS "Searching for SCOTCH library ...") -find_library(scotch_lib NAMES libscotch.a HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib) +find_library(scotch_lib NAMES libscotch HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib) find_path(scotch_inc scotch.h HINTS ENV SCOTCH_PATH PATH_SUFFIXES include) message(STATUS "Searching for PTSCOTCH library ...") -find_library(ptscotch_lib NAMES libptscotch.a HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib) +find_library(ptscotch_lib NAMES libptscotch HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib) find_path(ptscotch_inc ptscotch.h HINTS ENV SCOTCH_PATH PATH_SUFFIXES include) message(STATUS "Searching for SCOTCHerr library ...") -find_library(scotcherr_lib NAMES libscotcherr.a HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib) +find_library(scotcherr_lib NAMES libscotcherr HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib) find_path(scotcherr_inc scotch.h HINTS ENV SCOTCH_PATH PATH_SUFFIXES include) message(STATUS "Searching for PTSCOTCHerr library ...") -find_library(ptscotcherr_lib NAMES libptscotcherr.a HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib) +find_library(ptscotcherr_lib NAMES libptscotcherr HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib) find_path(ptscotcherr_inc ptscotch.h HINTS ENV SCOTCH_PATH PATH_SUFFIXES include) -add_library(PTSCOTCHparmetis::PTSCOTCHparmetis STATIC IMPORTED) -add_library(SCOTCH::SCOTCH STATIC IMPORTED) -add_library(PTSCOTCH::PTSCOTCH STATIC IMPORTED) -add_library(SCOTCHerr::SCOTCHerr STATIC IMPORTED) -add_library(PTSCOTCHerr::PTSCOTCHerr STATIC IMPORTED) +if(USE_SHARED_SCOTCH) + add_library(PTSCOTCHparmetis::PTSCOTCHparmetis SHARED IMPORTED) + add_library(SCOTCH::SCOTCH SHARED IMPORTED) + add_library(PTSCOTCH::PTSCOTCH SHARED IMPORTED) + add_library(SCOTCHerr::SCOTCHerr SHARED IMPORTED) + add_library(PTSCOTCHerr::PTSCOTCHerr SHARED IMPORTED) +else() + add_library(PTSCOTCHparmetis::PTSCOTCHparmetis STATIC IMPORTED) + add_library(SCOTCH::SCOTCH STATIC IMPORTED) + add_library(PTSCOTCH::PTSCOTCH STATIC IMPORTED) + add_library(SCOTCHerr::SCOTCHerr STATIC IMPORTED) + add_library(PTSCOTCHerr::PTSCOTCHerr STATIC IMPORTED) +endif() + set_target_properties(SCOTCH::SCOTCH PROPERTIES IMPORTED_LOCATION "${scotch_lib}" diff --git a/model/src/CMakeLists.txt b/model/src/CMakeLists.txt index 7dd7d82a2..56681d034 100644 --- a/model/src/CMakeLists.txt +++ b/model/src/CMakeLists.txt @@ -158,6 +158,7 @@ endif() # Handle PDLIB, SCRIP, SCRIPNC build files directly instead of through configuration file if("PDLIB" IN_LIST switches) if("SCOTCH" IN_LIST switches) + set(USE_SHARED_SCOTCH OFF) find_package(SCOTCH REQUIRED) target_sources(ww3_lib PRIVATE ${pdlib_src}) target_link_libraries(ww3_lib PUBLIC PTSCOTCHparmetis::PTSCOTCHparmetis) From 7f4510b37cd96568a3df506f436c32de204468f8 Mon Sep 17 00:00:00 2001 From: ulmononian Date: Tue, 20 Jun 2023 17:50:55 -0500 Subject: [PATCH 4/6] Updates for shared scotch. --- cmake/FindSCOTCH.cmake | 19 ++++++++++++++----- model/src/CMakeLists.txt | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/cmake/FindSCOTCH.cmake b/cmake/FindSCOTCH.cmake index 5644ac3b8..3871b0b8d 100644 --- a/cmake/FindSCOTCH.cmake +++ b/cmake/FindSCOTCH.cmake @@ -1,21 +1,27 @@ +if(USE_SHARED_SCOTCH) + set(LIB_EXT so) +else() + set(LIB_EXT a) +endif() + message(STATUS "Searching for PTSCOTCHparmetis library ...") -find_library(ptscotchparmetis_lib NAMES libptscotchparmetisv3 HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib) +find_library(ptscotchparmetis_lib NAMES libptscotchparmetisv3.${LIB_EXT} HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib) find_path(ptscotchparmetis_inc parmetis.h HINTS ENV SCOTCH_PATH PATH_SUFFIXES include) message(STATUS "Searching for SCOTCH library ...") -find_library(scotch_lib NAMES libscotch HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib) +find_library(scotch_lib NAMES libscotch.${LIB_EXT} HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib) find_path(scotch_inc scotch.h HINTS ENV SCOTCH_PATH PATH_SUFFIXES include) message(STATUS "Searching for PTSCOTCH library ...") -find_library(ptscotch_lib NAMES libptscotch HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib) +find_library(ptscotch_lib NAMES libptscotch.${LIB_EXT} HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib) find_path(ptscotch_inc ptscotch.h HINTS ENV SCOTCH_PATH PATH_SUFFIXES include) message(STATUS "Searching for SCOTCHerr library ...") -find_library(scotcherr_lib NAMES libscotcherr HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib) +find_library(scotcherr_lib NAMES libscotcherr.${LIB_EXT} HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib) find_path(scotcherr_inc scotch.h HINTS ENV SCOTCH_PATH PATH_SUFFIXES include) message(STATUS "Searching for PTSCOTCHerr library ...") -find_library(ptscotcherr_lib NAMES libptscotcherr HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib) +find_library(ptscotcherr_lib NAMES libptscotcherr.${LIB_EXT} HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib) find_path(ptscotcherr_inc ptscotch.h HINTS ENV SCOTCH_PATH PATH_SUFFIXES include) if(USE_SHARED_SCOTCH) @@ -24,14 +30,17 @@ if(USE_SHARED_SCOTCH) add_library(PTSCOTCH::PTSCOTCH SHARED IMPORTED) add_library(SCOTCHerr::SCOTCHerr SHARED IMPORTED) add_library(PTSCOTCHerr::PTSCOTCHerr SHARED IMPORTED) + set(LIBRARY_TYPE "Shared") else() add_library(PTSCOTCHparmetis::PTSCOTCHparmetis STATIC IMPORTED) add_library(SCOTCH::SCOTCH STATIC IMPORTED) add_library(PTSCOTCH::PTSCOTCH STATIC IMPORTED) add_library(SCOTCHerr::SCOTCHerr STATIC IMPORTED) add_library(PTSCOTCHerr::PTSCOTCHerr STATIC IMPORTED) + set(LIBRARY_TYPE "Static") endif() +message(STATUS "Using ${LIBRARY_TYPE} SCOTCH libraries.") set_target_properties(SCOTCH::SCOTCH PROPERTIES IMPORTED_LOCATION "${scotch_lib}" diff --git a/model/src/CMakeLists.txt b/model/src/CMakeLists.txt index 56681d034..e68b41b1d 100644 --- a/model/src/CMakeLists.txt +++ b/model/src/CMakeLists.txt @@ -158,7 +158,7 @@ endif() # Handle PDLIB, SCRIP, SCRIPNC build files directly instead of through configuration file if("PDLIB" IN_LIST switches) if("SCOTCH" IN_LIST switches) - set(USE_SHARED_SCOTCH OFF) + set(USE_SHARED_SCOTCH ON) find_package(SCOTCH REQUIRED) target_sources(ww3_lib PRIVATE ${pdlib_src}) target_link_libraries(ww3_lib PUBLIC PTSCOTCHparmetis::PTSCOTCHparmetis) From 48935e7bcc4cefc2b81e73a3651ab6275372c970 Mon Sep 17 00:00:00 2001 From: Cameron Book <43379611+ulmononian@users.noreply.github.com> Date: Tue, 20 Jun 2023 16:08:27 -0700 Subject: [PATCH 5/6] set default USE_SCOTCH_SHARED to OFF for now --- model/src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/src/CMakeLists.txt b/model/src/CMakeLists.txt index e68b41b1d..56681d034 100644 --- a/model/src/CMakeLists.txt +++ b/model/src/CMakeLists.txt @@ -158,7 +158,7 @@ endif() # Handle PDLIB, SCRIP, SCRIPNC build files directly instead of through configuration file if("PDLIB" IN_LIST switches) if("SCOTCH" IN_LIST switches) - set(USE_SHARED_SCOTCH ON) + set(USE_SHARED_SCOTCH OFF) find_package(SCOTCH REQUIRED) target_sources(ww3_lib PRIVATE ${pdlib_src}) target_link_libraries(ww3_lib PUBLIC PTSCOTCHparmetis::PTSCOTCHparmetis) From d2c4020303b595999367f2e6f4b76ad933ba926c Mon Sep 17 00:00:00 2001 From: ulmononian Date: Wed, 21 Jun 2023 13:03:11 -0500 Subject: [PATCH 6/6] Add command line option for scotch lib choice; adjust findscotch.cmake. --- cmake/FindSCOTCH.cmake | 22 ++++++++++++++++++---- model/src/CMakeLists.txt | 2 +- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/cmake/FindSCOTCH.cmake b/cmake/FindSCOTCH.cmake index 3871b0b8d..7f811e2ec 100644 --- a/cmake/FindSCOTCH.cmake +++ b/cmake/FindSCOTCH.cmake @@ -1,9 +1,13 @@ if(USE_SHARED_SCOTCH) set(LIB_EXT so) + set(LIBRARY_TYPE "Shared") else() set(LIB_EXT a) + set(LIBRARY_TYPE "Static") endif() +message(STATUS "Searching for ${LIBRARY_TYPE} SCOTCH libraries.") + message(STATUS "Searching for PTSCOTCHparmetis library ...") find_library(ptscotchparmetis_lib NAMES libptscotchparmetisv3.${LIB_EXT} HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib) find_path(ptscotchparmetis_inc parmetis.h HINTS ENV SCOTCH_PATH PATH_SUFFIXES include) @@ -24,24 +28,34 @@ message(STATUS "Searching for PTSCOTCHerr library ...") find_library(ptscotcherr_lib NAMES libptscotcherr.${LIB_EXT} HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib) find_path(ptscotcherr_inc ptscotch.h HINTS ENV SCOTCH_PATH PATH_SUFFIXES include) +set(required_libs ${ptscotchparmetis_lib} ${scotch_lib} ${ptscotch_lib} ${scotcherr_lib} ${ptscotcherr_lib}) + +foreach(lib ${required_libs}) + string(REGEX REPLACE "-NOTFOUND$" "" lib_path "${lib}") + if(NOT EXISTS ${lib_path}) + list(APPEND not_found_libs "${lib_path}.${LIB_EXT}") + endif() +endforeach() + +if(not_found_libs) + message(FATAL_ERROR "The following libraries were not found:\n${not_found_libs}\nPlease ensure the required libraries are available.") +endif() + + if(USE_SHARED_SCOTCH) add_library(PTSCOTCHparmetis::PTSCOTCHparmetis SHARED IMPORTED) add_library(SCOTCH::SCOTCH SHARED IMPORTED) add_library(PTSCOTCH::PTSCOTCH SHARED IMPORTED) add_library(SCOTCHerr::SCOTCHerr SHARED IMPORTED) add_library(PTSCOTCHerr::PTSCOTCHerr SHARED IMPORTED) - set(LIBRARY_TYPE "Shared") else() add_library(PTSCOTCHparmetis::PTSCOTCHparmetis STATIC IMPORTED) add_library(SCOTCH::SCOTCH STATIC IMPORTED) add_library(PTSCOTCH::PTSCOTCH STATIC IMPORTED) add_library(SCOTCHerr::SCOTCHerr STATIC IMPORTED) add_library(PTSCOTCHerr::PTSCOTCHerr STATIC IMPORTED) - set(LIBRARY_TYPE "Static") endif() -message(STATUS "Using ${LIBRARY_TYPE} SCOTCH libraries.") - set_target_properties(SCOTCH::SCOTCH PROPERTIES IMPORTED_LOCATION "${scotch_lib}" INTERFACE_INCLUDE_DIRECTORIES "${scotch_inc}") diff --git a/model/src/CMakeLists.txt b/model/src/CMakeLists.txt index 56681d034..b6946140c 100644 --- a/model/src/CMakeLists.txt +++ b/model/src/CMakeLists.txt @@ -158,7 +158,7 @@ endif() # Handle PDLIB, SCRIP, SCRIPNC build files directly instead of through configuration file if("PDLIB" IN_LIST switches) if("SCOTCH" IN_LIST switches) - set(USE_SHARED_SCOTCH OFF) + set(USE_SHARED_SCOTCH OFF CACHE BOOL "Use shared SCOTCH") find_package(SCOTCH REQUIRED) target_sources(ww3_lib PRIVATE ${pdlib_src}) target_link_libraries(ww3_lib PUBLIC PTSCOTCHparmetis::PTSCOTCHparmetis)