| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | |
| | FindSuiteSparse |
| | =============== |
| |
|
| | Module for locating SuiteSparse libraries and its dependencies. |
| |
|
| | This module defines the following variables: |
| |
|
| | ``SuiteSparse_FOUND`` |
| | ``TRUE`` iff SuiteSparse and all dependencies have been found. |
| |
|
| | ``SuiteSparse_VERSION`` |
| | Extracted from ``SuiteSparse_config.h`` (>= v4). |
| |
|
| | ``SuiteSparse_VERSION_MAJOR`` |
| | Equal to 4 if ``SuiteSparse_VERSION`` = 4.2.1 |
| |
|
| | ``SuiteSparse_VERSION_MINOR`` |
| | Equal to 2 if ``SuiteSparse_VERSION`` = 4.2.1 |
| |
|
| | ``SuiteSparse_VERSION_PATCH`` |
| | Equal to 1 if ``SuiteSparse_VERSION`` = 4.2.1 |
| |
|
| | The following variables control the behaviour of this module: |
| |
|
| | ``SuiteSparse_NO_CMAKE`` |
| | Do not attempt to use the native SuiteSparse CMake package configuration. |
| |
|
| |
|
| | Targets |
| | ------- |
| |
|
| | The following targets define the SuiteSparse components searched for. |
| |
|
| | ``SuiteSparse::AMD`` |
| | Symmetric Approximate Minimum Degree (AMD) |
| |
|
| | ``SuiteSparse::CAMD`` |
| | Constrained Approximate Minimum Degree (CAMD) |
| |
|
| | ``SuiteSparse::COLAMD`` |
| | Column Approximate Minimum Degree (COLAMD) |
| |
|
| | ``SuiteSparse::CCOLAMD`` |
| | Constrained Column Approximate Minimum Degree (CCOLAMD) |
| |
|
| | ``SuiteSparse::CHOLMOD`` |
| | Sparse Supernodal Cholesky Factorization and Update/Downdate (CHOLMOD) |
| |
|
| | ``SuiteSparse::SPQR`` |
| | Multifrontal Sparse QR (SuiteSparseQR) |
| |
|
| | ``SuiteSparse::Config`` |
| | Common configuration for all but CSparse (SuiteSparse version >= 4). |
| |
|
| | Optional SuiteSparse dependencies: |
| |
|
| | ``METIS::METIS`` |
| | Serial Graph Partitioning and Fill-reducing Matrix Ordering (METIS) |
| | ]=======================================================================] |
| |
|
| | if (NOT SuiteSparse_NO_CMAKE) |
| | find_package (SuiteSparse NO_MODULE QUIET) |
| | endif (NOT SuiteSparse_NO_CMAKE) |
| |
|
| | if (SuiteSparse_FOUND) |
| | return () |
| | endif (SuiteSparse_FOUND) |
| |
|
| | |
| | |
| | cmake_policy (PUSH) |
| | cmake_policy (SET CMP0057 NEW) |
| |
|
| | if (NOT SuiteSparse_FIND_COMPONENTS) |
| | set (SuiteSparse_FIND_COMPONENTS |
| | AMD |
| | CAMD |
| | CCOLAMD |
| | CHOLMOD |
| | COLAMD |
| | SPQR |
| | ) |
| |
|
| | foreach (component IN LISTS SuiteSparse_FIND_COMPONENTS) |
| | set (SuiteSparse_FIND_REQUIRED_${component} TRUE) |
| | endforeach (component IN LISTS SuiteSparse_FIND_COMPONENTS) |
| | endif (NOT SuiteSparse_FIND_COMPONENTS) |
| |
|
| | |
| | |
| | |
| | set (SuiteSparse_FOUND TRUE) |
| |
|
| | include (CheckLibraryExists) |
| |
|
| | |
| | set (SuiteSparse_IMPLICIT_COMPONENTS Config) |
| |
|
| | |
| | if (CHOLMOD IN_LIST SuiteSparse_FIND_COMPONENTS) |
| | list (APPEND SuiteSparse_IMPLICIT_COMPONENTS AMD CAMD CCOLAMD COLAMD) |
| | endif (CHOLMOD IN_LIST SuiteSparse_FIND_COMPONENTS) |
| |
|
| | |
| | if (SPQR IN_LIST SuiteSparse_FIND_COMPONENTS) |
| | list (APPEND SuiteSparse_IMPLICIT_COMPONENTS CHOLMOD) |
| | endif (SPQR IN_LIST SuiteSparse_FIND_COMPONENTS) |
| |
|
| | |
| | foreach (component IN LISTS SuiteSparse_IMPLICIT_COMPONENTS) |
| | set (SuiteSparse_FIND_REQUIRED_${component} TRUE) |
| | endforeach (component IN LISTS SuiteSparse_IMPLICIT_COMPONENTS) |
| |
|
| | list (APPEND SuiteSparse_FIND_COMPONENTS ${SuiteSparse_IMPLICIT_COMPONENTS}) |
| |
|
| | |
| | list (REMOVE_DUPLICATES SuiteSparse_FIND_COMPONENTS) |
| |
|
| | |
| | |
| | macro(SuiteSparse_RESET_FIND_LIBRARY_PREFIX) |
| | if (MSVC) |
| | set(CMAKE_FIND_LIBRARY_PREFIXES "${CALLERS_CMAKE_FIND_LIBRARY_PREFIXES}") |
| | endif (MSVC) |
| | endmacro(SuiteSparse_RESET_FIND_LIBRARY_PREFIX) |
| |
|
| | |
| | |
| | |
| | macro(SuiteSparse_REPORT_NOT_FOUND REASON_MSG) |
| | |
| | unset (SuiteSparse_FOUND) |
| |
|
| | |
| | |
| | |
| |
|
| | suitesparse_reset_find_library_prefix() |
| |
|
| | |
| | |
| | if (SuiteSparse_FIND_QUIETLY) |
| | message(STATUS "Failed to find SuiteSparse - " ${REASON_MSG} ${ARGN}) |
| | elseif (SuiteSparse_FIND_REQUIRED) |
| | message(FATAL_ERROR "Failed to find SuiteSparse - " ${REASON_MSG} ${ARGN}) |
| | else() |
| | |
| | |
| | message("-- Failed to find SuiteSparse - " ${REASON_MSG} ${ARGN}) |
| | endif (SuiteSparse_FIND_QUIETLY) |
| |
|
| | |
| | |
| | |
| | endmacro(SuiteSparse_REPORT_NOT_FOUND) |
| |
|
| | |
| | |
| | if (MSVC) |
| | |
| | |
| | set(CALLERS_CMAKE_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}") |
| | |
| | |
| | set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "" "${CMAKE_FIND_LIBRARY_PREFIXES}") |
| | endif (MSVC) |
| |
|
| | |
| | list(APPEND SuiteSparse_CHECK_PATH_SUFFIXES |
| | suitesparse) |
| |
|
| | |
| | |
| | |
| | |
| | macro(suitesparse_find_component COMPONENT) |
| | include(CMakeParseArguments) |
| | set(MULTI_VALUE_ARGS FILES LIBRARIES) |
| | cmake_parse_arguments(SuiteSparse_FIND_COMPONENT_${COMPONENT} |
| | "" "" "${MULTI_VALUE_ARGS}" ${ARGN}) |
| |
|
| | set(SuiteSparse_${COMPONENT}_FOUND TRUE) |
| | if (SuiteSparse_FIND_COMPONENT_${COMPONENT}_FILES) |
| | find_path(SuiteSparse_${COMPONENT}_INCLUDE_DIR |
| | NAMES ${SuiteSparse_FIND_COMPONENT_${COMPONENT}_FILES} |
| | PATH_SUFFIXES ${SuiteSparse_CHECK_PATH_SUFFIXES}) |
| | if (SuiteSparse_${COMPONENT}_INCLUDE_DIR) |
| | message(STATUS "Found ${COMPONENT} headers in: " |
| | "${SuiteSparse_${COMPONENT}_INCLUDE_DIR}") |
| | mark_as_advanced(SuiteSparse_${COMPONENT}_INCLUDE_DIR) |
| | else() |
| | |
| | set(SuiteSparse_${COMPONENT}_FOUND FALSE) |
| | if (SuiteSparse_FIND_REQUIRED_${COMPONENT}) |
| | suitesparse_report_not_found( |
| | "Did not find ${COMPONENT} header (required SuiteSparse component).") |
| | else() |
| | message(STATUS "Did not find ${COMPONENT} header (optional " |
| | "SuiteSparse component).") |
| | |
| | mark_as_advanced(SuiteSparse_${COMPONENT}_INCLUDE_DIR) |
| | endif() |
| | endif() |
| | endif() |
| |
|
| | if (SuiteSparse_FIND_COMPONENT_${COMPONENT}_LIBRARIES) |
| | find_library(SuiteSparse_${COMPONENT}_LIBRARY |
| | NAMES ${SuiteSparse_FIND_COMPONENT_${COMPONENT}_LIBRARIES} |
| | PATH_SUFFIXES ${SuiteSparse_CHECK_PATH_SUFFIXES}) |
| | if (SuiteSparse_${COMPONENT}_LIBRARY) |
| | message(STATUS "Found ${COMPONENT} library: ${SuiteSparse_${COMPONENT}_LIBRARY}") |
| | mark_as_advanced(SuiteSparse_${COMPONENT}_LIBRARY) |
| | else () |
| | |
| | set(SuiteSparse_${COMPONENT}_FOUND FALSE) |
| | if (SuiteSparse_FIND_REQUIRED_${COMPONENT}) |
| | suitesparse_report_not_found( |
| | "Did not find ${COMPONENT} library (required SuiteSparse component).") |
| | else() |
| | message(STATUS "Did not find ${COMPONENT} library (optional SuiteSparse " |
| | "dependency)") |
| | |
| | mark_as_advanced(SuiteSparse_${COMPONENT}_LIBRARY) |
| | endif() |
| | endif() |
| | endif() |
| |
|
| | |
| | |
| | |
| | if (SuiteSparse_FIND_REQUIRED_${COMPONENT}) |
| | list (APPEND SuiteSparse_REQUIRED_VARS SuiteSparse_${COMPONENT}_INCLUDE_DIR) |
| | list (APPEND SuiteSparse_REQUIRED_VARS SuiteSparse_${COMPONENT}_LIBRARY) |
| | endif (SuiteSparse_FIND_REQUIRED_${COMPONENT}) |
| |
|
| | |
| | if (SuiteSparse_${COMPONENT}_INCLUDE_DIR AND SuiteSparse_${COMPONENT}_LIBRARY) |
| | if (NOT TARGET SuiteSparse::${COMPONENT}) |
| | add_library(SuiteSparse::${COMPONENT} IMPORTED UNKNOWN) |
| | endif (NOT TARGET SuiteSparse::${COMPONENT}) |
| |
|
| | set_property(TARGET SuiteSparse::${COMPONENT} PROPERTY |
| | INTERFACE_INCLUDE_DIRECTORIES ${SuiteSparse_${COMPONENT}_INCLUDE_DIR}) |
| | set_property(TARGET SuiteSparse::${COMPONENT} PROPERTY |
| | IMPORTED_LOCATION ${SuiteSparse_${COMPONENT}_LIBRARY}) |
| | endif (SuiteSparse_${COMPONENT}_INCLUDE_DIR AND SuiteSparse_${COMPONENT}_LIBRARY) |
| | endmacro() |
| |
|
| | |
| | |
| | |
| | |
| | unset(SuiteSparse_REQUIRED_VARS) |
| |
|
| | |
| | find_package(BLAS QUIET) |
| | if (NOT BLAS_FOUND) |
| | suitesparse_report_not_found( |
| | "Did not find BLAS library (required for SuiteSparse).") |
| | endif (NOT BLAS_FOUND) |
| |
|
| | |
| | find_package(LAPACK QUIET) |
| | if (NOT LAPACK_FOUND) |
| | suitesparse_report_not_found( |
| | "Did not find LAPACK library (required for SuiteSparse).") |
| | endif (NOT LAPACK_FOUND) |
| |
|
| | foreach (component IN LISTS SuiteSparse_FIND_COMPONENTS) |
| | string (TOLOWER ${component} component_library) |
| |
|
| | if (component STREQUAL "Config") |
| | set (component_header SuiteSparse_config.h) |
| | set (component_library suitesparseconfig) |
| | elseif (component STREQUAL "SPQR") |
| | set (component_header SuiteSparseQR.hpp) |
| | else (component STREQUAL "SPQR") |
| | set (component_header ${component_library}.h) |
| | endif (component STREQUAL "Config") |
| |
|
| | suitesparse_find_component(${component} |
| | FILES ${component_header} |
| | LIBRARIES ${component_library}) |
| | endforeach (component IN LISTS SuiteSparse_FIND_COMPONENTS) |
| |
|
| | if (TARGET SuiteSparse::SPQR) |
| | |
| | |
| | |
| | find_package(TBB QUIET) |
| | if (TBB_FOUND) |
| | message(STATUS "Found Intel Thread Building Blocks (TBB) library " |
| | "(${TBB_VERSION_MAJOR}.${TBB_VERSION_MINOR} / ${TBB_INTERFACE_VERSION}) " |
| | "include location: ${TBB_INCLUDE_DIRS}. Assuming SuiteSparseQR was " |
| | "compiled with TBB.") |
| | |
| | |
| | if (TARGET TBB::tbb) |
| | |
| | |
| | set_property (TARGET SuiteSparse::SPQR APPEND PROPERTY |
| | INTERFACE_LINK_LIBRARIES TBB::tbb) |
| | else (TARGET TBB::tbb) |
| | set_property (TARGET SuiteSparse::SPQR APPEND PROPERTY |
| | INTERFACE_INCLUDE_DIRECTORIES ${TBB_INCLUDE_DIRS}) |
| | set_property (TARGET SuiteSparse::SPQR APPEND PROPERTY |
| | INTERFACE_LINK_LIBRARIES ${TBB_LIBRARIES}) |
| | endif (TARGET TBB::tbb) |
| | else (TBB_FOUND) |
| | message(STATUS "Did not find Intel TBB library, assuming SuiteSparseQR was " |
| | "not compiled with TBB.") |
| | endif (TBB_FOUND) |
| | endif (TARGET SuiteSparse::SPQR) |
| |
|
| | check_library_exists(rt shm_open "" HAVE_LIBRT) |
| |
|
| | if (TARGET SuiteSparse::Config) |
| | |
| | |
| | |
| | if (HAVE_LIBRT) |
| | message(STATUS "Adding librt to " |
| | "SuiteSparse_config libraries (required on Linux & Unix [not OSX] if " |
| | "SuiteSparse is compiled with timing).") |
| | set_property (TARGET SuiteSparse::Config APPEND PROPERTY |
| | INTERFACE_LINK_LIBRARIES $<LINK_ONLY:rt>) |
| | else (HAVE_LIBRT) |
| | message(STATUS "Could not find librt, but found SuiteSparse_config, " |
| | "assuming that SuiteSparse was compiled without timing.") |
| | endif (HAVE_LIBRT) |
| |
|
| | |
| | |
| | if (BLAS_FOUND) |
| | if (TARGET BLAS::BLAS) |
| | set_property (TARGET SuiteSparse::Config APPEND PROPERTY |
| | INTERFACE_LINK_LIBRARIES $<LINK_ONLY:BLAS::BLAS>) |
| | else (TARGET BLAS::BLAS) |
| | set_property (TARGET SuiteSparse::Config APPEND PROPERTY |
| | INTERFACE_LINK_LIBRARIES ${BLAS_LIBRARIES}) |
| | endif (TARGET BLAS::BLAS) |
| | endif (BLAS_FOUND) |
| |
|
| | if (LAPACK_FOUND) |
| | if (TARGET LAPACK::LAPACK) |
| | set_property (TARGET SuiteSparse::Config APPEND PROPERTY |
| | INTERFACE_LINK_LIBRARIES $<LINK_ONLY:LAPACK::LAPACK>) |
| | else (TARGET LAPACK::LAPACK) |
| | set_property (TARGET SuiteSparse::Config APPEND PROPERTY |
| | INTERFACE_LINK_LIBRARIES ${LAPACK_LIBRARIES}) |
| | endif (TARGET LAPACK::LAPACK) |
| | endif (LAPACK_FOUND) |
| |
|
| | |
| | set(SuiteSparse_VERSION_FILE |
| | ${SuiteSparse_Config_INCLUDE_DIR}/SuiteSparse_config.h) |
| | if (NOT EXISTS ${SuiteSparse_VERSION_FILE}) |
| | suitesparse_report_not_found( |
| | "Could not find file: ${SuiteSparse_VERSION_FILE} containing version " |
| | "information for >= v4 SuiteSparse installs, but SuiteSparse_config was " |
| | "found (only present in >= v4 installs).") |
| | else (NOT EXISTS ${SuiteSparse_VERSION_FILE}) |
| | file(READ ${SuiteSparse_VERSION_FILE} Config_CONTENTS) |
| |
|
| | string(REGEX MATCH "#define SUITESPARSE_MAIN_VERSION [0-9]+" |
| | SuiteSparse_VERSION_MAJOR "${Config_CONTENTS}") |
| | string(REGEX REPLACE "#define SUITESPARSE_MAIN_VERSION ([0-9]+)" "\\1" |
| | SuiteSparse_VERSION_MAJOR "${SuiteSparse_VERSION_MAJOR}") |
| |
|
| | string(REGEX MATCH "#define SUITESPARSE_SUB_VERSION [0-9]+" |
| | SuiteSparse_VERSION_MINOR "${Config_CONTENTS}") |
| | string(REGEX REPLACE "#define SUITESPARSE_SUB_VERSION ([0-9]+)" "\\1" |
| | SuiteSparse_VERSION_MINOR "${SuiteSparse_VERSION_MINOR}") |
| |
|
| | string(REGEX MATCH "#define SUITESPARSE_SUBSUB_VERSION [0-9]+" |
| | SuiteSparse_VERSION_PATCH "${Config_CONTENTS}") |
| | string(REGEX REPLACE "#define SUITESPARSE_SUBSUB_VERSION ([0-9]+)" "\\1" |
| | SuiteSparse_VERSION_PATCH "${SuiteSparse_VERSION_PATCH}") |
| |
|
| | |
| | |
| | set(SuiteSparse_VERSION |
| | "${SuiteSparse_VERSION_MAJOR}.${SuiteSparse_VERSION_MINOR}.${SuiteSparse_VERSION_PATCH}") |
| | set(SuiteSparse_VERSION_COMPONENTS 3) |
| | endif (NOT EXISTS ${SuiteSparse_VERSION_FILE}) |
| | endif (TARGET SuiteSparse::Config) |
| |
|
| | |
| | find_package (METIS) |
| |
|
| | |
| | if (TARGET SuiteSparse::CHOLMOD) |
| | |
| | if (TARGET METIS::METIS) |
| | set_property (TARGET SuiteSparse::CHOLMOD APPEND PROPERTY |
| | INTERFACE_LINK_LIBRARIES METIS::METIS) |
| | endif (TARGET METIS::METIS) |
| |
|
| | foreach (component IN ITEMS AMD CAMD CCOLAMD COLAMD) |
| | if (TARGET SuiteSparse::${component}) |
| | set_property (TARGET SuiteSparse::CHOLMOD APPEND PROPERTY |
| | INTERFACE_LINK_LIBRARIES SuiteSparse::${component}) |
| | else (TARGET SuiteSparse::${component}) |
| | |
| | set (SuiteSparse_CHOLMOD_FOUND FALSE) |
| | endif (TARGET SuiteSparse::${component}) |
| | endforeach (component IN ITEMS AMD CAMD CCOLAMD COLAMD) |
| | endif (TARGET SuiteSparse::CHOLMOD) |
| |
|
| | |
| | if (TARGET SuiteSparse::SPQR) |
| | if (TARGET SuiteSparse::CHOLMOD) |
| | set_property (TARGET SuiteSparse::SPQR APPEND PROPERTY |
| | INTERFACE_LINK_LIBRARIES SuiteSparse::CHOLMOD) |
| | else (TARGET SuiteSparse::CHOLMOD) |
| | |
| | set (SuiteSparse_SQPR_FOUND FALSE) |
| | endif (TARGET SuiteSparse::CHOLMOD) |
| | endif (TARGET SuiteSparse::SPQR) |
| |
|
| | |
| | if (TARGET SuiteSparse::Config) |
| | foreach (component IN LISTS SuiteSparse_FIND_COMPONENTS) |
| | if (component STREQUAL Config) |
| | continue () |
| | endif (component STREQUAL Config) |
| |
|
| | if (TARGET SuiteSparse::${component}) |
| | set_property (TARGET SuiteSparse::${component} APPEND PROPERTY |
| | INTERFACE_LINK_LIBRARIES SuiteSparse::Config) |
| | endif (TARGET SuiteSparse::${component}) |
| | endforeach (component IN LISTS SuiteSparse_FIND_COMPONENTS) |
| | endif (TARGET SuiteSparse::Config) |
| |
|
| | suitesparse_reset_find_library_prefix() |
| |
|
| | |
| | include(FindPackageHandleStandardArgs) |
| | if (SuiteSparse_FOUND) |
| | find_package_handle_standard_args(SuiteSparse |
| | REQUIRED_VARS ${SuiteSparse_REQUIRED_VARS} |
| | VERSION_VAR SuiteSparse_VERSION |
| | FAIL_MESSAGE "Failed to find some/all required components of SuiteSparse." |
| | HANDLE_COMPONENTS) |
| | else (SuiteSparse_FOUND) |
| | |
| | |
| | |
| | find_package_handle_standard_args(SuiteSparse |
| | REQUIRED_VARS ${SuiteSparse_REQUIRED_VARS} |
| | FAIL_MESSAGE "Failed to find some/all required components of SuiteSparse." |
| | HANDLE_COMPONENTS) |
| | endif (SuiteSparse_FOUND) |
| |
|
| | |
| | cmake_policy (POP) |
| |
|