From 04d480081eb6db9c09827d8a902586e2edc77a0c Mon Sep 17 00:00:00 2001 From: Meagan Lang Date: Tue, 17 Dec 2024 19:44:11 -0500 Subject: [PATCH] Update cmake file for compat with older versions of sundials --- CMakeLists.txt | 4 +- cmake/FindSUNDIALS.cmake | 87 +++++++++++++++++++++------------------- 2 files changed, 48 insertions(+), 43 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b17d89..197ed9b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -175,9 +175,9 @@ add_library(EPhotosynthesis SHARED ${SOURCES}) add_executable(ePhoto bin/ePhotosynthesis.cpp) find_package(Boost 1.36.0 REQUIRED COMPONENTS regex) -find_package(SUNDIALS REQUIRED CONFIG COMPONENTS kinsol cvode core) +find_package(SUNDIALS REQUIRED CONFIG COMPONENTS kinsol cvode) if (NOT SUNDIALS_LIBRARIES) - set(SUNDIALS_LIBRARIES SUNDIALS::kinsol SUNDIALS::cvode SUNDIALS::core) + set(SUNDIALS_LIBRARIES SUNDIALS::kinsol SUNDIALS::cvode) endif() message(STATUS "SUNDIALS_LIBRARIES = ${SUNDIALS_LIBRARIES}") message(STATUS "SUNDIALS_INCLUDE_DIRS = ${SUNDIALS_INCLUDE_DIRS}") diff --git a/cmake/FindSUNDIALS.cmake b/cmake/FindSUNDIALS.cmake index 3b7018d..ad15e37 100644 --- a/cmake/FindSUNDIALS.cmake +++ b/cmake/FindSUNDIALS.cmake @@ -49,47 +49,6 @@ # This module exports the target SUNDIALS:: if it was found. -# List of the valid SUNDIALS components -set(SUNDIALS_VALID_COMPONENTS - core - cvode - cvodes - ida - idas - kinsol - sunlinsolklu - sunlinsoldense - sunlinsolspbcgs - sunlinsollapackdense - sunmatrixsparse - sunmatrixdense - sunmatrixband - nvecserial - nvecopenmp - nvecpthreads -) - -if (NOT SUNDIALS_FIND_COMPONENTS) - set(SUNDIALS_WANT_COMPONENTS ${SUNDIALS_VALID_COMPONENTS}) -else() - # add the extra specified components, ensuring that they are valid. - foreach(_COMPONENT ${SUNDIALS_FIND_COMPONENTS}) - string(TOLOWER ${_COMPONENT} _COMPONENT_LOWER) - string(FIND _COMPONENT_LOWER "sundials_" IDX_PREFIX) - if(IDX_PREFIX EQUAL 0) - string(SUBSTRING _COMPONENT_LOWER 9 -1 _COMPONENT_LOWER) - endif() - list(FIND SUNDIALS_VALID_COMPONENTS ${_COMPONENT_LOWER} COMPONENT_LOCATION) - if (${COMPONENT_LOCATION} EQUAL -1) - message(FATAL_ERROR "\"${_COMPONENT_LOWER}\" is not a valid SUNDIALS component.") - else() - list(APPEND SUNDIALS_WANT_COMPONENTS ${_COMPONENT_LOWER}) - endif() - endforeach() -endif() - - - find_package(PkgConfig QUIET) if (PKG_CONFIG_FOUND) pkg_check_modules(PKGCONFIG_SUNDIALS QUIET sundials) @@ -175,6 +134,52 @@ if (SUNDIALS_INCLUDE_DIR) endif() + +# List of the valid SUNDIALS components +set(SUNDIALS_VALID_COMPONENTS + cvode + cvodes + ida + idas + kinsol + sunlinsolklu + sunlinsoldense + sunlinsolspbcgs + sunlinsollapackdense + sunmatrixsparse + sunmatrixdense + sunmatrixband + nvecserial + nvecopenmp + nvecpthreads +) +if(SUNDIALS_VERSION VERSION_GREATER_EQUAL "7.0.0") + list(APPEND SUNDIALS_VALID_COMPONENTS core) +else() + list(APPEND SUNDIALS_VALID_COMPONENTS generic) +endif() + +if (NOT SUNDIALS_FIND_COMPONENTS) + set(SUNDIALS_WANT_COMPONENTS ${SUNDIALS_VALID_COMPONENTS}) +else() + # add the extra specified components, ensuring that they are valid. + foreach(_COMPONENT ${SUNDIALS_FIND_COMPONENTS}) + string(TOLOWER ${_COMPONENT} _COMPONENT_LOWER) + string(FIND _COMPONENT_LOWER "sundials_" IDX_PREFIX) + if(IDX_PREFIX EQUAL 0) + string(SUBSTRING _COMPONENT_LOWER 9 -1 _COMPONENT_LOWER) + endif() + list(FIND SUNDIALS_VALID_COMPONENTS ${_COMPONENT_LOWER} COMPONENT_LOCATION) + if (${COMPONENT_LOCATION} EQUAL -1) + message(FATAL_ERROR "\"${_COMPONENT_LOWER}\" is not a valid SUNDIALS component.") + else() + list(APPEND SUNDIALS_WANT_COMPONENTS ${_COMPONENT_LOWER}) + endif() + endforeach() +endif() + + + # find the SUNDIALS libraries foreach(LIB ${SUNDIALS_WANT_COMPONENTS}) set(PREFIXED_LIB "sundials_${LIB}")