Newer
Older
# .. cmake_module::
#
# Module that checks whether SuperLU is available and usable.
#
# Variables used by this module which you may want to set:
#
# :ref:`SUPERLU_ROOT`
# Path list to search for SuperLU
#
# Sets the follwing variables:
#
# :code:`SUPERLU_FOUND`
# True if SuperLU available and usable.
#
# :code:`SUPERLU_WITH_VERSION`
# Human readable string containing version information.

Christoph Grüninger
committed
#
# :code:`SUPERLU_INCLUDE_DIRS`
# Path to the SuperLU include dirs.

Christoph Grüninger
committed
#
# :code:`SUPERLU_LIBRARIES`
# Name to the SuperLU library.
# .. cmake_variable:: SUPERLU_ROOT

Christoph Grüninger
committed
#
# You may set this variable to have :ref:`FindSuperLU` look
# for the SuperLU package in the given path before inspecting
# system paths.

Christoph Grüninger
committed
#

Christoph Grüninger
committed
# look for header files, only at positions given by the user
find_path(SUPERLU_INCLUDE_DIR
NAMES supermatrix.h
PATHS ${SUPERLU_PREFIX} ${SUPERLU_ROOT}
PATH_SUFFIXES "superlu" "SuperLU" "include/superlu" "include" "SRC"
NO_DEFAULT_PATH
)
# look for header files, including default paths

Christoph Grüninger
committed
find_path(SUPERLU_INCLUDE_DIR
NAMES supermatrix.h
PATH_SUFFIXES "superlu" "SuperLU" "include/superlu" "include" "SRC"

Christoph Grüninger
committed
)
# look for library, only at positions given by the user
find_library(SUPERLU_LIBRARY
NAMES "superlu"
"superlu_5.2.1" "superlu_5.2" "superlu_5.1.1" "superlu_5.1" "superlu_5.0"
PATHS ${SUPERLU_PREFIX} ${SUPERLU_ROOT}
PATH_SUFFIXES "lib" "lib32" "lib64"
NO_DEFAULT_PATH
)
# look for library files, including default paths

Christoph Grüninger
committed
find_library(SUPERLU_LIBRARY
NAMES "superlu"
"superlu_5.2.1" "superlu_5.2" "superlu_5.1.1" "superlu_5.1" "superlu_5.0"

Christoph Grüninger
committed
)

Christoph Grüninger
committed
include(CheckCSourceCompiles)
# we need if clauses here because variable is set variable-NOTFOUND
# if the searches above were not successful
# Without them CMake print errors like:
# "CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
# Please set them or make sure they are set and tested correctly in the CMake files:"
#
if(SUPERLU_INCLUDE_DIR)
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${SUPERLU_INCLUDE_DIR})
endif(SUPERLU_INCLUDE_DIR)
if(SUPERLU_LIBRARY)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${SUPERLU_LIBRARY})
endif(SUPERLU_LIBRARY)
if(BLAS_LIBRARIES)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${BLAS_LIBRARIES})
endif(BLAS_LIBRARIES)
# check whether version is at least 5.0
check_c_source_compiles("
typedef int int_t;
#include <supermatrix.h>
#include <slu_util.h>
include(CheckIncludeFiles)
set(HAVE_SLU_DDEFS_H 1)
check_include_files(slu_sdefs.h HAVE_SLU_SDEFS_H)
check_include_files(slu_cdefs.h HAVE_SLU_CDEFS_H)
check_include_files(slu_zdefs.h HAVE_SLU_ZDEFS_H)

Christoph Grüninger
committed
set(SUPERLU_INT_TYPE "int" CACHE STRING
"The integer version that SuperLU was compiled for (Default is int.
Should be the same as int_t define in e.g. slu_sdefs.h")

Christoph Grüninger
committed
# behave like a CMake module is supposed to behave
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
"SuperLU"
DEFAULT_MSG
SUPERLU_INCLUDE_DIR
SUPERLU_LIBRARY

Christoph Grüninger
committed
)
mark_as_advanced(SUPERLU_INCLUDE_DIR SUPERLU_LIBRARY SUPERLU_MIN_VERSION_5)

Christoph Grüninger
committed
# if both headers and library are found, store results
if(SUPERLU_FOUND)
set(SUPERLU_INCLUDE_DIRS ${SUPERLU_INCLUDE_DIR})
set(SUPERLU_LIBRARIES ${SUPERLU_LIBRARY})
# log result
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining location of ${SUPERLU_WITH_VERSION} succeeded:\n"
"Include directory: ${SUPERLU_INCLUDE_DIRS}\n"
"Library directory: ${SUPERLU_LIBRARIES}\n\n")
set(SUPERLU_DUNE_COMPILE_FLAGS "-I${SUPERLU_INCLUDE_DIRS}"
CACHE STRING "Compile flags used by DUNE when compiling SuperLU programs")
set(SUPERLU_DUNE_LIBRARIES ${SUPERLU_LIBRARIES} ${BLAS_LIBRARIES}
CACHE STRING "Libraries used by DUNE when linking SuperLU programs")

Christoph Grüninger
committed
else(SUPERLU_FOUND)
# log errornous result
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Library directory: ${SUPERLU_LIBRARIES}\n"
"Found unsupported version: ${SUPERLU_WITH_VERSION}\n\n")

Christoph Grüninger
committed
endif(SUPERLU_FOUND)
set(HAVE_SUPERLU ${SUPERLU_FOUND})
# register all superlu related flags
if(SUPERLU_FOUND)
dune_register_package_flags(COMPILE_DEFINITIONS "ENABLE_SUPERLU=1"
LIBRARIES "${SUPERLU_DUNE_LIBRARIES}"
INCLUDE_DIRS "${SUPERLU_INCLUDE_DIRS}")
# text for feature summary
set_package_properties("SuperLU" PROPERTIES
DESCRIPTION "Supernodal LU"
PURPOSE "Direct solver for linear system, based on LU decomposition")