Skip to content

Commit

Permalink
Update cmake file for compat with older versions of sundials
Browse files Browse the repository at this point in the history
  • Loading branch information
langmm committed Dec 18, 2024
1 parent 9114093 commit 04d4800
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 43 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
87 changes: 46 additions & 41 deletions cmake/FindSUNDIALS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -49,47 +49,6 @@
# This module exports the target SUNDIALS::<component> 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)
Expand Down Expand Up @@ -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}")
Expand Down

0 comments on commit 04d4800

Please sign in to comment.