From: Matthias Maier Date: Mon, 11 Dec 2017 16:14:25 +0000 (-0600) Subject: CMake: Simplify and streamline FindSUNDIALS.cmake X-Git-Tag: v9.0.0-rc1~612^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9dfe47e9bafea0f3e0eb1cba16b1c040b2686a3d;p=dealii.git CMake: Simplify and streamline FindSUNDIALS.cmake --- diff --git a/cmake/modules/FindSUNDIALS.cmake b/cmake/modules/FindSUNDIALS.cmake index 30fe2f8eca..c75e6e1d61 100644 --- a/cmake/modules/FindSUNDIALS.cmake +++ b/cmake/modules/FindSUNDIALS.cmake @@ -18,12 +18,9 @@ # # This module exports # -# SUNDIALS_LIB_IDA(S) -# SUNDIALS_LIB_ARKODE -# SUNDIALS_LIB_KINSOL -# SUNDIALS_LIB_PAR -# SUNDIALS_LIB_SER +# SUNDIALS_LIBRARIES # SUNDIALS_INCLUDE_DIR +# SUNDIALS_WITH_IDAS # # Note that sundials headers are typically installed in several directories, # e.g., @@ -43,16 +40,10 @@ DEAL_II_FIND_LIBRARY(SUNDIALS_LIB_IDAS NAMES sundials_idas PATH_SUFFIXES lib${LIB_SUFFIX} lib64 lib ) -IF(SUNDIALS_LIB_IDAS MATCHES "-NOTFOUND") - DEAL_II_FIND_LIBRARY(SUNDIALS_LIB_IDA NAMES sundials_ida - HINTS ${SUNDIALS_DIR} - PATH_SUFFIXES lib${LIB_SUFFIX} lib64 lib - ) - SET(SUNDIALS_IDA_TYPE "IDA") -ELSE() - ADD_DEFINITIONS(-DDEAL_II_WITH_SUNDIALS_IDAS) - SET(SUNDIALS_IDA_TYPE "IDAS") -ENDIF() +DEAL_II_FIND_LIBRARY(SUNDIALS_LIB_IDA NAMES sundials_ida + HINTS ${SUNDIALS_DIR} + PATH_SUFFIXES lib${LIB_SUFFIX} lib64 lib + ) DEAL_II_FIND_LIBRARY(SUNDIALS_LIB_ARKODE NAMES sundials_arkode HINTS ${SUNDIALS_DIR} @@ -69,48 +60,42 @@ DEAL_II_FIND_LIBRARY(SUNDIALS_LIB_SER NAMES sundials_nvecserial PATH_SUFFIXES lib${LIB_SUFFIX} lib64 lib ) -# -# only define the extra hint if ${SUNDIALS_DIR} is nonempty so that we do not -# try to search through the top-level '/include/' directory, should it happen to -# exist -# -STRING(COMPARE EQUAL "${SUNDIALS_DIR}" "" _sundials_dir_is_empty) -IF(NOT ${_sundials_dir_is_empty}) - SET(_sundials_include_hint_dir "${SUNDIALS_DIR}/include/") -ENDIF() - DEAL_II_FIND_PATH(SUNDIALS_INCLUDE_DIR sundials/sundials_nvector.h - HINTS ${SUNDIALS_DIR} "${_sundials_include_hint_dir}" + HINTS ${SUNDIALS_DIR} + PATH_SUFFIXES include ) -SET(_sundials_additional_libs) +SET(_sundials_lib_par) IF(DEAL_II_WITH_MPI) DEAL_II_FIND_LIBRARY(SUNDIALS_LIB_PAR NAMES sundials_nvecparallel HINTS ${SUNDIALS_DIR} PATH_SUFFIXES lib${LIB_SUFFIX} lib64 lib ) - SET(_sundials_additional_libs SUNDIALS_LIB_PAR) -DEAL_II_PACKAGE_HANDLE(SUNDIALS - LIBRARIES REQUIRED - SUNDIALS_LIB_${SUNDIALS_IDA_TYPE} SUNDIALS_LIB_ARKODE SUNDIALS_LIB_KINSOL SUNDIALS_LIB_SER SUNDIALS_LIB_PAR - ${_sundials_additional_libs} - INCLUDE_DIRS REQUIRED SUNDIALS_INCLUDE_DIR - USER_INCLUDE_DIRS REQUIRED SUNDIALS_INCLUDE_DIR - CLEAR - SUNDIALS_LIB_${SUNDIALS_IDA_TYPE} SUNDIALS_LIB_ARKODE SUNDIALS_LIB_KINSOL - SUNDIALS_LIB_SER SUNDIALS_LIB_PAR - ) + SET(_sundials_lib_par "SUNDIALS_LIB_PAR") +ENDIF() + +# +# If IDAS is available, we prefer said library over IDA. We have to make +# sure to only link one of the two library variants: +# +IF(NOT SUNDIALS_LIB_IDAS MATCHES "-NOTFOUND") + SET(_sundials_lib_ida "SUNDIALS_LIB_IDAS") + SET(SUNDIALS_WITH_IDAS TRUE) ELSE() + SET(_sundials_lib_ida "SUNDIALS_LIB_IDA") + SET(SUNDIALS_WITH_IDAS FALSE) +ENDIF() + + DEAL_II_PACKAGE_HANDLE(SUNDIALS LIBRARIES REQUIRED - SUNDIALS_LIB_${SUNDIALS_IDA_TYPE} SUNDIALS_LIB_ARKODE SUNDIALS_LIB_KINSOL SUNDIALS_LIB_SER - ${_sundials_additional_libs} - INCLUDE_DIRS REQUIRED SUNDIALS_INCLUDE_DIR - USER_INCLUDE_DIRS REQUIRED SUNDIALS_INCLUDE_DIR + ${_sundials_lib_ida} SUNDIALS_LIB_ARKODE + SUNDIALS_LIB_KINSOL SUNDIALS_LIB_SER ${_sundials_lib_par} + INCLUDE_DIRS REQUIRED + SUNDIALS_INCLUDE_DIR + USER_INCLUDE_DIRS REQUIRED + SUNDIALS_INCLUDE_DIR CLEAR - SUNDIALS_LIB_${SUNDIALS_IDA_TYPE} SUNDIALS_LIB_ARKODE SUNDIALS_LIB_KINSOL - SUNDIALS_LIB_SER + SUNDIALS_LIB_IDA SUNDIALS_LIB_IDAS SUNDIALS_LIB_ARKODE + SUNDIALS_LIB_KINSOL SUNDIALS_LIB_SER ${_sundials_lib_par} ) - -ENDIF() -