]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: Simplify and streamline FindSUNDIALS.cmake
authorMatthias Maier <tamiko@43-1.org>
Mon, 11 Dec 2017 16:14:25 +0000 (10:14 -0600)
committerMatthias Maier <tamiko@43-1.org>
Mon, 11 Dec 2017 16:20:53 +0000 (10:20 -0600)
cmake/modules/FindSUNDIALS.cmake

index 30fe2f8eca92b9a99639abab83415f71c1aa07dc..c75e6e1d61c055484cffc32ce35860380a7ce07c 100644 (file)
 #
 # 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()
-

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.