2013-10-04 16:17:06 +01:00
|
|
|
# Ceres Solver - A fast non-linear least squares minimizer
|
2023-09-10 17:46:26 +02:00
|
|
|
# Copyright 2026 Google Inc. All rights reserved.
|
2015-03-17 22:30:16 -07:00
|
|
|
# http://ceres-solver.org/
|
2013-10-04 16:17:06 +01:00
|
|
|
#
|
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
|
# modification, are permitted provided that the following conditions are met:
|
|
|
|
|
#
|
|
|
|
|
# * Redistributions of source code must retain the above copyright notice,
|
|
|
|
|
# this list of conditions and the following disclaimer.
|
|
|
|
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
|
# this list of conditions and the following disclaimer in the documentation
|
|
|
|
|
# and/or other materials provided with the distribution.
|
|
|
|
|
# * Neither the name of Google Inc. nor the names of its contributors may be
|
|
|
|
|
# used to endorse or promote products derived from this software without
|
|
|
|
|
# specific prior written permission.
|
|
|
|
|
#
|
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
|
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
|
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
|
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
|
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
|
# POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
#
|
|
|
|
|
# Author: alexs.mac@gmail.com (Alex Stewart)
|
|
|
|
|
#
|
|
|
|
|
|
2022-02-06 19:13:39 +01:00
|
|
|
#[=======================================================================[.rst:
|
|
|
|
|
FindSuiteSparse
|
|
|
|
|
===============
|
|
|
|
|
|
|
|
|
|
Module for locating SuiteSparse libraries and its dependencies.
|
|
|
|
|
|
2023-09-10 17:46:26 +02:00
|
|
|
SuiteSparse 7 and later provide a unified CMake package configuration. This
|
|
|
|
|
module retains a component-based fallback for older supported releases such as
|
|
|
|
|
SuiteSparse 5.10.1 in Ubuntu 22.04.
|
|
|
|
|
|
2022-02-06 19:13:39 +01:00
|
|
|
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)
|
|
|
|
|
|
2022-05-15 22:26:18 +02:00
|
|
|
``SuiteSparse::Partition``
|
|
|
|
|
CHOLMOD with METIS support
|
|
|
|
|
|
2022-02-06 19:13:39 +01:00
|
|
|
``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)
|
|
|
|
|
]=======================================================================]
|
|
|
|
|
|
2023-09-10 17:46:26 +02:00
|
|
|
# Keep native package-config diagnostics deterministic.
|
|
|
|
|
if (SuiteSparse_FIND_COMPONENTS)
|
|
|
|
|
list(SORT SuiteSparse_FIND_COMPONENTS COMPARE STRING CASE INSENSITIVE)
|
|
|
|
|
endif ()
|
|
|
|
|
|
2022-02-06 19:13:39 +01:00
|
|
|
if (NOT SuiteSparse_NO_CMAKE)
|
|
|
|
|
find_package (SuiteSparse NO_MODULE QUIET)
|
2023-09-10 17:46:26 +02:00
|
|
|
if (SuiteSparse_FOUND)
|
|
|
|
|
# Report the main include directory instead of the package configuration
|
|
|
|
|
# file path in FindPackageHandleStandardArgs' standard success message.
|
|
|
|
|
get_target_property(SuiteSparse_INCLUDE_DIR SuiteSparse::Config
|
|
|
|
|
INTERFACE_INCLUDE_DIRECTORIES)
|
|
|
|
|
if (SuiteSparse_INCLUDE_DIR)
|
|
|
|
|
list(GET SuiteSparse_INCLUDE_DIR -1 SuiteSparse_INCLUDE_DIR)
|
|
|
|
|
endif ()
|
|
|
|
|
include(FindPackageHandleStandardArgs)
|
|
|
|
|
find_package_handle_standard_args(SuiteSparse
|
|
|
|
|
REQUIRED_VARS SuiteSparse_INCLUDE_DIR
|
|
|
|
|
VERSION_VAR SuiteSparse_VERSION
|
|
|
|
|
HANDLE_COMPONENTS)
|
|
|
|
|
return ()
|
|
|
|
|
endif (SuiteSparse_FOUND)
|
2022-02-06 19:13:39 +01:00
|
|
|
endif (NOT SuiteSparse_NO_CMAKE)
|
|
|
|
|
|
2022-03-08 13:12:24 -08:00
|
|
|
# Push CMP0057 to enable support for IN_LIST, when cmake_minimum_required is
|
|
|
|
|
# set to <3.3.
|
|
|
|
|
cmake_policy (PUSH)
|
|
|
|
|
cmake_policy (SET CMP0057 NEW)
|
|
|
|
|
|
2022-02-06 19:13:39 +01:00
|
|
|
if (NOT SuiteSparse_FIND_COMPONENTS)
|
|
|
|
|
set (SuiteSparse_FIND_COMPONENTS
|
|
|
|
|
AMD
|
|
|
|
|
CAMD
|
|
|
|
|
CCOLAMD
|
|
|
|
|
CHOLMOD
|
|
|
|
|
COLAMD
|
|
|
|
|
SPQR
|
|
|
|
|
)
|
2022-03-06 14:20:36 +01:00
|
|
|
|
|
|
|
|
foreach (component IN LISTS SuiteSparse_FIND_COMPONENTS)
|
|
|
|
|
set (SuiteSparse_FIND_REQUIRED_${component} TRUE)
|
|
|
|
|
endforeach (component IN LISTS SuiteSparse_FIND_COMPONENTS)
|
2022-02-06 19:13:39 +01:00
|
|
|
endif (NOT SuiteSparse_FIND_COMPONENTS)
|
|
|
|
|
|
2023-09-10 17:46:26 +02:00
|
|
|
# Assume SuiteSparse was found and set it to false when a component or a
|
|
|
|
|
# third-party dependency could not be located. SuiteSparse component failures
|
|
|
|
|
# are reported by FindPackageHandleStandardArgs HANDLE_COMPONENTS.
|
2022-03-06 14:20:36 +01:00
|
|
|
set (SuiteSparse_FOUND TRUE)
|
2023-09-10 17:46:26 +02:00
|
|
|
set (CMAKE_FIND_PACKAGE_REASON)
|
|
|
|
|
|
|
|
|
|
# Keep nested dependency failures available for SuiteSparse's final reason.
|
|
|
|
|
macro (suitesparse_find_dependency DEPENDENCY)
|
|
|
|
|
find_package(${DEPENDENCY} ${ARGN} QUIET)
|
|
|
|
|
if (NOT ${DEPENDENCY}_FOUND)
|
|
|
|
|
set (SuiteSparse_${DEPENDENCY}_REASON
|
|
|
|
|
"${DEPENDENCY}: Could not find ${DEPENDENCY}.")
|
|
|
|
|
if (${DEPENDENCY}_NOT_FOUND_MESSAGE)
|
|
|
|
|
set (SuiteSparse_${DEPENDENCY}_REASON
|
|
|
|
|
"${DEPENDENCY}: ${${DEPENDENCY}_NOT_FOUND_MESSAGE}")
|
|
|
|
|
endif ()
|
|
|
|
|
endif ()
|
|
|
|
|
endmacro (suitesparse_find_dependency)
|
|
|
|
|
|
|
|
|
|
# SuiteSparseQR optionally depends on TBB. Find it here so that it is treated
|
|
|
|
|
# as a SuiteSparse dependency rather than as a Ceres dependency.
|
|
|
|
|
suitesparse_find_dependency(TBB NO_MODULE)
|
2022-03-06 14:20:36 +01:00
|
|
|
|
2022-02-06 19:13:39 +01:00
|
|
|
include (CheckLibraryExists)
|
2022-05-15 22:26:18 +02:00
|
|
|
include (CheckSymbolExists)
|
|
|
|
|
include (CMakePushCheckState)
|
2022-02-06 19:13:39 +01:00
|
|
|
|
2022-03-06 14:20:36 +01:00
|
|
|
# Config is a base component and thus always required
|
|
|
|
|
set (SuiteSparse_IMPLICIT_COMPONENTS Config)
|
|
|
|
|
|
2022-03-08 13:12:24 -08:00
|
|
|
# CHOLMOD depends on AMD, CAMD, CCOLAMD, and COLAMD.
|
2022-02-06 19:13:39 +01:00
|
|
|
if (CHOLMOD IN_LIST SuiteSparse_FIND_COMPONENTS)
|
2022-03-06 14:20:36 +01:00
|
|
|
list (APPEND SuiteSparse_IMPLICIT_COMPONENTS AMD CAMD CCOLAMD COLAMD)
|
2022-02-06 19:13:39 +01:00
|
|
|
endif (CHOLMOD IN_LIST SuiteSparse_FIND_COMPONENTS)
|
|
|
|
|
|
2022-03-08 13:12:24 -08:00
|
|
|
# SPQR depends on CHOLMOD.
|
2022-02-06 19:13:39 +01:00
|
|
|
if (SPQR IN_LIST SuiteSparse_FIND_COMPONENTS)
|
2022-03-06 14:20:36 +01:00
|
|
|
list (APPEND SuiteSparse_IMPLICIT_COMPONENTS CHOLMOD)
|
2022-02-06 19:13:39 +01:00
|
|
|
endif (SPQR IN_LIST SuiteSparse_FIND_COMPONENTS)
|
|
|
|
|
|
2022-03-06 14:20:36 +01:00
|
|
|
# Implicit components are always required
|
|
|
|
|
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})
|
|
|
|
|
|
2022-03-08 13:12:24 -08:00
|
|
|
# Do not list components multiple times.
|
2022-02-06 19:13:39 +01:00
|
|
|
list (REMOVE_DUPLICATES SuiteSparse_FIND_COMPONENTS)
|
2023-09-10 17:46:26 +02:00
|
|
|
list (SORT SuiteSparse_FIND_COMPONENTS COMPARE STRING CASE INSENSITIVE)
|
2013-10-04 16:17:06 +01:00
|
|
|
|
2015-03-28 16:45:50 +00:00
|
|
|
# Reset CALLERS_CMAKE_FIND_LIBRARY_PREFIXES to its value when
|
|
|
|
|
# FindSuiteSparse was invoked.
|
2022-02-06 19:13:39 +01:00
|
|
|
macro(SuiteSparse_RESET_FIND_LIBRARY_PREFIX)
|
2015-08-09 15:18:42 +01:00
|
|
|
if (MSVC)
|
|
|
|
|
set(CMAKE_FIND_LIBRARY_PREFIXES "${CALLERS_CMAKE_FIND_LIBRARY_PREFIXES}")
|
|
|
|
|
endif (MSVC)
|
2022-02-06 19:13:39 +01:00
|
|
|
endmacro(SuiteSparse_RESET_FIND_LIBRARY_PREFIX)
|
2015-03-28 16:45:50 +00:00
|
|
|
|
2023-09-10 17:46:26 +02:00
|
|
|
# Called if we failed to find SuiteSparse or any of its required dependencies.
|
|
|
|
|
# The standard package helper reports the failure after all components have
|
|
|
|
|
# been checked.
|
2022-02-06 19:13:39 +01:00
|
|
|
macro(SuiteSparse_REPORT_NOT_FOUND REASON_MSG)
|
2023-09-10 17:46:26 +02:00
|
|
|
set (SuiteSparse_FOUND FALSE)
|
|
|
|
|
list (APPEND CMAKE_FIND_PACKAGE_REASON "${REASON_MSG}")
|
2022-03-06 14:20:36 +01:00
|
|
|
|
|
|
|
|
# Do NOT unset SuiteSparse_REQUIRED_VARS here, as it is used by
|
2013-11-05 13:10:27 +00:00
|
|
|
# FindPackageHandleStandardArgs() to generate the automatic error message on
|
|
|
|
|
# failure which highlights which components are missing.
|
|
|
|
|
|
2015-08-09 15:18:42 +01:00
|
|
|
suitesparse_reset_find_library_prefix()
|
2015-03-28 16:45:50 +00:00
|
|
|
|
2023-09-10 17:46:26 +02:00
|
|
|
# Do not return so all components can be checked before standard reporting.
|
2022-02-06 19:13:39 +01:00
|
|
|
endmacro(SuiteSparse_REPORT_NOT_FOUND)
|
2016-12-01 18:20:11 +00:00
|
|
|
|
2015-03-28 16:45:50 +00:00
|
|
|
# Handle possible presence of lib prefix for libraries on MSVC, see
|
2022-02-06 19:13:39 +01:00
|
|
|
# also SuiteSparse_RESET_FIND_LIBRARY_PREFIX().
|
2015-08-09 15:18:42 +01:00
|
|
|
if (MSVC)
|
2015-03-28 16:45:50 +00:00
|
|
|
# Preserve the caller's original values for CMAKE_FIND_LIBRARY_PREFIXES
|
|
|
|
|
# s/t we can set it back before returning.
|
2015-08-09 15:18:42 +01:00
|
|
|
set(CALLERS_CMAKE_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}")
|
2015-03-28 16:45:50 +00:00
|
|
|
# The empty string in this list is important, it represents the case when
|
|
|
|
|
# the libraries have no prefix (shared libraries / DLLs).
|
2015-08-09 15:18:42 +01:00
|
|
|
set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "" "${CMAKE_FIND_LIBRARY_PREFIXES}")
|
|
|
|
|
endif (MSVC)
|
2015-03-28 16:45:50 +00:00
|
|
|
|
2017-07-07 01:23:44 +03:00
|
|
|
# Additional suffixes to try appending to each search path.
|
2022-02-06 19:13:39 +01:00
|
|
|
list(APPEND SuiteSparse_CHECK_PATH_SUFFIXES
|
2017-07-07 01:23:44 +03:00
|
|
|
suitesparse) # Windows/Ubuntu
|
2013-10-04 16:17:06 +01:00
|
|
|
|
2017-05-18 13:06:52 +01:00
|
|
|
# Wrappers to find_path/library that pass the SuiteSparse search hints/paths.
|
|
|
|
|
#
|
|
|
|
|
# suitesparse_find_component(<component> [FILES name1 [name2 ...]]
|
2022-03-06 14:20:36 +01:00
|
|
|
# [LIBRARIES name1 [name2 ...]])
|
2017-05-18 13:06:52 +01:00
|
|
|
macro(suitesparse_find_component COMPONENT)
|
|
|
|
|
include(CMakeParseArguments)
|
|
|
|
|
set(MULTI_VALUE_ARGS FILES LIBRARIES)
|
2022-03-06 14:20:36 +01:00
|
|
|
cmake_parse_arguments(SuiteSparse_FIND_COMPONENT_${COMPONENT}
|
|
|
|
|
"" "" "${MULTI_VALUE_ARGS}" ${ARGN})
|
2017-05-18 13:06:52 +01:00
|
|
|
|
2022-02-06 19:13:39 +01:00
|
|
|
set(SuiteSparse_${COMPONENT}_FOUND TRUE)
|
2022-03-06 14:20:36 +01:00
|
|
|
if (SuiteSparse_FIND_COMPONENT_${COMPONENT}_FILES)
|
2022-02-06 19:13:39 +01:00
|
|
|
find_path(SuiteSparse_${COMPONENT}_INCLUDE_DIR
|
2022-03-06 14:20:36 +01:00
|
|
|
NAMES ${SuiteSparse_FIND_COMPONENT_${COMPONENT}_FILES}
|
2022-02-06 19:13:39 +01:00
|
|
|
PATH_SUFFIXES ${SuiteSparse_CHECK_PATH_SUFFIXES})
|
|
|
|
|
if (SuiteSparse_${COMPONENT}_INCLUDE_DIR)
|
|
|
|
|
mark_as_advanced(SuiteSparse_${COMPONENT}_INCLUDE_DIR)
|
2017-05-18 13:06:52 +01:00
|
|
|
else()
|
|
|
|
|
# Specified headers not found.
|
2022-02-06 19:13:39 +01:00
|
|
|
set(SuiteSparse_${COMPONENT}_FOUND FALSE)
|
2022-03-06 14:20:36 +01:00
|
|
|
if (SuiteSparse_FIND_REQUIRED_${COMPONENT})
|
2023-09-10 17:46:26 +02:00
|
|
|
set(SuiteSparse_FOUND FALSE)
|
2017-05-18 13:06:52 +01:00
|
|
|
else()
|
2017-08-13 19:16:46 +01:00
|
|
|
# Hide optional vars from CMake GUI even if not found.
|
2022-02-06 19:13:39 +01:00
|
|
|
mark_as_advanced(SuiteSparse_${COMPONENT}_INCLUDE_DIR)
|
2017-05-18 13:06:52 +01:00
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
|
2022-03-06 14:20:36 +01:00
|
|
|
if (SuiteSparse_FIND_COMPONENT_${COMPONENT}_LIBRARIES)
|
2022-02-06 19:13:39 +01:00
|
|
|
find_library(SuiteSparse_${COMPONENT}_LIBRARY
|
2022-03-06 14:20:36 +01:00
|
|
|
NAMES ${SuiteSparse_FIND_COMPONENT_${COMPONENT}_LIBRARIES}
|
2022-02-06 19:13:39 +01:00
|
|
|
PATH_SUFFIXES ${SuiteSparse_CHECK_PATH_SUFFIXES})
|
|
|
|
|
if (SuiteSparse_${COMPONENT}_LIBRARY)
|
|
|
|
|
mark_as_advanced(SuiteSparse_${COMPONENT}_LIBRARY)
|
2017-05-18 13:06:52 +01:00
|
|
|
else ()
|
|
|
|
|
# Specified libraries not found.
|
2022-02-06 19:13:39 +01:00
|
|
|
set(SuiteSparse_${COMPONENT}_FOUND FALSE)
|
2022-03-06 14:20:36 +01:00
|
|
|
if (SuiteSparse_FIND_REQUIRED_${COMPONENT})
|
2023-09-10 17:46:26 +02:00
|
|
|
set(SuiteSparse_FOUND FALSE)
|
2017-05-18 13:06:52 +01:00
|
|
|
else()
|
2017-08-13 19:16:46 +01:00
|
|
|
# Hide optional vars from CMake GUI even if not found.
|
2022-02-06 19:13:39 +01:00
|
|
|
mark_as_advanced(SuiteSparse_${COMPONENT}_LIBRARY)
|
2017-05-18 13:06:52 +01:00
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
2022-03-06 14:15:25 +01:00
|
|
|
|
2022-03-06 14:20:36 +01:00
|
|
|
# A component can be optional (given to OPTIONAL_COMPONENTS). However, if the
|
|
|
|
|
# component is implicit (must be always present, such as the Config component)
|
|
|
|
|
# assume it be required as well.
|
|
|
|
|
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})
|
|
|
|
|
|
2022-03-06 14:15:25 +01:00
|
|
|
# Define the target only if the include directory and the library were found
|
|
|
|
|
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)
|
2017-05-18 13:06:52 +01:00
|
|
|
endmacro()
|
|
|
|
|
|
2013-11-05 13:10:27 +00:00
|
|
|
# Given the number of components of SuiteSparse, and to ensure that the
|
|
|
|
|
# automatic failure message generated by FindPackageHandleStandardArgs()
|
|
|
|
|
# when not all required components are found is helpful, we maintain a list
|
|
|
|
|
# of all variables that must be defined for SuiteSparse to be considered found.
|
2022-03-06 14:20:36 +01:00
|
|
|
unset(SuiteSparse_REQUIRED_VARS)
|
2013-11-05 13:10:27 +00:00
|
|
|
|
2013-10-04 16:17:06 +01:00
|
|
|
# BLAS.
|
2023-09-10 17:46:26 +02:00
|
|
|
if (NOT DEFINED BLAS_FOUND)
|
|
|
|
|
suitesparse_find_dependency(BLAS)
|
|
|
|
|
endif()
|
2013-10-04 16:17:06 +01:00
|
|
|
|
|
|
|
|
# LAPACK.
|
2023-09-10 17:46:26 +02:00
|
|
|
if (NOT DEFINED LAPACK_FOUND)
|
|
|
|
|
suitesparse_find_dependency(LAPACK)
|
|
|
|
|
endif()
|
2013-10-04 16:17:06 +01:00
|
|
|
|
2022-02-06 19:13:39 +01:00
|
|
|
foreach (component IN LISTS SuiteSparse_FIND_COMPONENTS)
|
2022-05-15 22:26:18 +02:00
|
|
|
if (component STREQUAL Partition)
|
|
|
|
|
# Partition is a meta component that neither provides additional headers nor
|
|
|
|
|
# a separate library. It is strictly part of CHOLMOD.
|
|
|
|
|
continue ()
|
|
|
|
|
endif (component STREQUAL Partition)
|
2022-03-06 14:20:36 +01:00
|
|
|
string (TOLOWER ${component} component_library)
|
2022-02-06 19:13:39 +01:00
|
|
|
|
2022-03-06 14:20:36 +01:00
|
|
|
if (component STREQUAL "Config")
|
|
|
|
|
set (component_header SuiteSparse_config.h)
|
|
|
|
|
set (component_library suitesparseconfig)
|
|
|
|
|
elseif (component STREQUAL "SPQR")
|
2022-02-06 19:13:39 +01:00
|
|
|
set (component_header SuiteSparseQR.hpp)
|
|
|
|
|
else (component STREQUAL "SPQR")
|
2022-03-06 14:20:36 +01:00
|
|
|
set (component_header ${component_library}.h)
|
|
|
|
|
endif (component STREQUAL "Config")
|
2022-02-06 19:13:39 +01:00
|
|
|
|
2022-03-06 14:20:36 +01:00
|
|
|
suitesparse_find_component(${component}
|
|
|
|
|
FILES ${component_header}
|
|
|
|
|
LIBRARIES ${component_library})
|
2022-02-06 19:13:39 +01:00
|
|
|
endforeach (component IN LISTS SuiteSparse_FIND_COMPONENTS)
|
|
|
|
|
|
|
|
|
|
check_library_exists(rt shm_open "" HAVE_LIBRT)
|
2017-05-18 13:06:52 +01:00
|
|
|
|
2022-02-06 19:13:39 +01:00
|
|
|
if (TARGET SuiteSparse::Config)
|
2013-10-04 16:17:06 +01:00
|
|
|
# SuiteSparse version >= 4.
|
2022-02-06 19:13:39 +01:00
|
|
|
set(SuiteSparse_VERSION_FILE
|
|
|
|
|
${SuiteSparse_Config_INCLUDE_DIR}/SuiteSparse_config.h)
|
|
|
|
|
if (NOT EXISTS ${SuiteSparse_VERSION_FILE})
|
2023-09-10 17:46:26 +02:00
|
|
|
list(APPEND SuiteSparse_REQUIRED_VARS SuiteSparse_VERSION)
|
2015-08-09 15:18:42 +01:00
|
|
|
suitesparse_report_not_found(
|
2022-02-06 19:13:39 +01:00
|
|
|
"Could not find file: ${SuiteSparse_VERSION_FILE} containing version "
|
2013-10-11 15:50:10 +01:00
|
|
|
"information for >= v4 SuiteSparse installs, but SuiteSparse_config was "
|
|
|
|
|
"found (only present in >= v4 installs).")
|
2022-02-06 19:13:39 +01:00
|
|
|
else (NOT EXISTS ${SuiteSparse_VERSION_FILE})
|
|
|
|
|
file(READ ${SuiteSparse_VERSION_FILE} Config_CONTENTS)
|
2013-10-11 15:50:10 +01:00
|
|
|
|
2022-11-13 21:13:12 +01:00
|
|
|
string(REGEX MATCH "#define SUITESPARSE_MAIN_VERSION[ \t]+([0-9]+)"
|
|
|
|
|
SuiteSparse_VERSION_LINE "${Config_CONTENTS}")
|
|
|
|
|
set (SuiteSparse_VERSION_MAJOR ${CMAKE_MATCH_1})
|
2013-10-11 15:50:10 +01:00
|
|
|
|
2022-11-13 21:13:12 +01:00
|
|
|
string(REGEX MATCH "#define SUITESPARSE_SUB_VERSION[ \t]+([0-9]+)"
|
|
|
|
|
SuiteSparse_VERSION_LINE "${Config_CONTENTS}")
|
|
|
|
|
set (SuiteSparse_VERSION_MINOR ${CMAKE_MATCH_1})
|
2013-10-11 15:50:10 +01:00
|
|
|
|
2022-11-13 21:13:12 +01:00
|
|
|
string(REGEX MATCH "#define SUITESPARSE_SUBSUB_VERSION[ \t]+([0-9]+)"
|
|
|
|
|
SuiteSparse_VERSION_LINE "${Config_CONTENTS}")
|
|
|
|
|
set (SuiteSparse_VERSION_PATCH ${CMAKE_MATCH_1})
|
|
|
|
|
|
|
|
|
|
unset (SuiteSparse_VERSION_LINE)
|
2013-10-11 15:50:10 +01:00
|
|
|
|
|
|
|
|
# This is on a single line s/t CMake does not interpret it as a list of
|
|
|
|
|
# elements and insert ';' separators which would result in 4.;2.;1 nonsense.
|
2022-02-06 19:13:39 +01:00
|
|
|
set(SuiteSparse_VERSION
|
|
|
|
|
"${SuiteSparse_VERSION_MAJOR}.${SuiteSparse_VERSION_MINOR}.${SuiteSparse_VERSION_PATCH}")
|
2022-11-13 21:13:12 +01:00
|
|
|
|
|
|
|
|
if (SuiteSparse_VERSION MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+")
|
|
|
|
|
set(SuiteSparse_VERSION_COMPONENTS 3)
|
|
|
|
|
else (SuiteSparse_VERSION MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+")
|
|
|
|
|
message (WARNING "Could not parse SuiteSparse_config.h: SuiteSparse "
|
|
|
|
|
"version will not be available")
|
|
|
|
|
|
|
|
|
|
unset (SuiteSparse_VERSION)
|
|
|
|
|
unset (SuiteSparse_VERSION_MAJOR)
|
|
|
|
|
unset (SuiteSparse_VERSION_MINOR)
|
|
|
|
|
unset (SuiteSparse_VERSION_PATCH)
|
2023-09-10 17:46:26 +02:00
|
|
|
list(APPEND SuiteSparse_REQUIRED_VARS SuiteSparse_VERSION)
|
2022-11-13 21:13:12 +01:00
|
|
|
endif (SuiteSparse_VERSION MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+")
|
2022-02-06 19:13:39 +01:00
|
|
|
endif (NOT EXISTS ${SuiteSparse_VERSION_FILE})
|
|
|
|
|
endif (TARGET SuiteSparse::Config)
|
2013-10-04 16:17:06 +01:00
|
|
|
|
2022-02-06 19:13:39 +01:00
|
|
|
# CHOLMOD requires AMD CAMD CCOLAMD COLAMD
|
|
|
|
|
if (TARGET SuiteSparse::CHOLMOD)
|
|
|
|
|
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})
|
|
|
|
|
# Consider CHOLMOD not found if COLAMD cannot be found
|
|
|
|
|
set (SuiteSparse_CHOLMOD_FOUND FALSE)
|
2023-09-10 17:46:26 +02:00
|
|
|
set (SuiteSparse_FOUND FALSE)
|
2022-02-06 19:13:39 +01:00
|
|
|
endif (TARGET SuiteSparse::${component})
|
|
|
|
|
endforeach (component IN ITEMS AMD CAMD CCOLAMD COLAMD)
|
|
|
|
|
endif (TARGET SuiteSparse::CHOLMOD)
|
|
|
|
|
|
|
|
|
|
# SPQR requires 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)
|
|
|
|
|
# Consider SPQR not found if CHOLMOD cannot be found
|
2023-09-10 17:46:26 +02:00
|
|
|
set (SuiteSparse_SPQR_FOUND FALSE)
|
|
|
|
|
set (SuiteSparse_FOUND FALSE)
|
2022-02-06 19:13:39 +01:00
|
|
|
endif (TARGET SuiteSparse::CHOLMOD)
|
|
|
|
|
endif (TARGET SuiteSparse::SPQR)
|
|
|
|
|
|
|
|
|
|
# Add SuiteSparse::Config as dependency to all components
|
|
|
|
|
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)
|
2013-10-04 16:17:06 +01:00
|
|
|
|
2023-09-10 17:46:26 +02:00
|
|
|
# Check whether the SuiteSparse libraries need their optional dependencies.
|
|
|
|
|
# This avoids adding libraries that are available but are not required by the
|
|
|
|
|
# installed SuiteSparse build.
|
|
|
|
|
function (suitesparse_check_link RESULT SYMBOL)
|
|
|
|
|
set (SuiteSparse_LINK_CHECK_SOURCE
|
|
|
|
|
"${CMAKE_BINARY_DIR}/CMakeFiles/SuiteSparseLinkCheck.cxx")
|
|
|
|
|
file (WRITE "${SuiteSparse_LINK_CHECK_SOURCE}"
|
|
|
|
|
"extern \"C\" void ${SYMBOL}(void);\n"
|
|
|
|
|
"int main(void) { ${SYMBOL}(); return 0; }\n")
|
|
|
|
|
|
|
|
|
|
unset (SuiteSparse_LINK_CHECK_RESULT CACHE)
|
|
|
|
|
unset (SuiteSparse_LINK_CHECK_RESULT)
|
|
|
|
|
try_compile (SuiteSparse_LINK_CHECK_RESULT
|
|
|
|
|
"${CMAKE_BINARY_DIR}/CMakeFiles/SuiteSparseLinkCheck"
|
|
|
|
|
"${SuiteSparse_LINK_CHECK_SOURCE}"
|
|
|
|
|
LINK_LIBRARIES ${ARGN}
|
|
|
|
|
OUTPUT_VARIABLE SuiteSparse_LINK_CHECK_OUTPUT)
|
|
|
|
|
set (${RESULT} ${SuiteSparse_LINK_CHECK_RESULT} PARENT_SCOPE)
|
|
|
|
|
unset (SuiteSparse_LINK_CHECK_RESULT CACHE)
|
|
|
|
|
unset (SuiteSparse_LINK_CHECK_RESULT)
|
|
|
|
|
endfunction (suitesparse_check_link)
|
|
|
|
|
|
|
|
|
|
set (SuiteSparse_LINK_TARGET)
|
|
|
|
|
set (SuiteSparse_LINK_SYMBOL)
|
|
|
|
|
if (TARGET SuiteSparse::SPQR)
|
|
|
|
|
set (SuiteSparse_LINK_TARGET SuiteSparse::SPQR)
|
|
|
|
|
set (SuiteSparse_LINK_SYMBOL SuiteSparseQR_C_symbolic)
|
|
|
|
|
elseif (TARGET SuiteSparse::CHOLMOD)
|
|
|
|
|
set (SuiteSparse_LINK_TARGET SuiteSparse::CHOLMOD)
|
|
|
|
|
set (SuiteSparse_LINK_SYMBOL cholmod_start)
|
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
|
|
set (SuiteSparse_BLAS_LINK)
|
|
|
|
|
if (TARGET BLAS::BLAS)
|
|
|
|
|
set (SuiteSparse_BLAS_LINK BLAS::BLAS)
|
|
|
|
|
elseif (BLAS_LIBRARIES)
|
|
|
|
|
set (SuiteSparse_BLAS_LINK ${BLAS_LIBRARIES})
|
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
|
|
set (SuiteSparse_LAPACK_LINK)
|
|
|
|
|
if (TARGET LAPACK::LAPACK)
|
|
|
|
|
set (SuiteSparse_LAPACK_LINK LAPACK::LAPACK)
|
|
|
|
|
elseif (LAPACK_LIBRARIES)
|
|
|
|
|
set (SuiteSparse_LAPACK_LINK ${LAPACK_LIBRARIES})
|
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
|
|
set (SuiteSparse_TBB_LINK)
|
|
|
|
|
if (TARGET TBB::tbb)
|
|
|
|
|
set (SuiteSparse_TBB_LINK TBB::tbb)
|
|
|
|
|
elseif (TBB_LIBRARIES)
|
|
|
|
|
set (SuiteSparse_TBB_LINK ${TBB_LIBRARIES})
|
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
|
|
set (SuiteSparse_RT_LINK)
|
|
|
|
|
if (HAVE_LIBRT)
|
|
|
|
|
set (SuiteSparse_RT_LINK rt)
|
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
|
|
set (SuiteSparse_OPTIONAL_DEPENDENCIES)
|
|
|
|
|
if (SuiteSparse_BLAS_LINK)
|
|
|
|
|
list (APPEND SuiteSparse_OPTIONAL_DEPENDENCIES BLAS)
|
|
|
|
|
endif ()
|
|
|
|
|
if (SuiteSparse_LAPACK_LINK)
|
|
|
|
|
list (APPEND SuiteSparse_OPTIONAL_DEPENDENCIES LAPACK)
|
|
|
|
|
endif ()
|
|
|
|
|
if (TARGET SuiteSparse::SPQR AND SuiteSparse_TBB_LINK)
|
|
|
|
|
list (APPEND SuiteSparse_OPTIONAL_DEPENDENCIES TBB)
|
|
|
|
|
endif ()
|
|
|
|
|
if (SuiteSparse_RT_LINK)
|
|
|
|
|
list (APPEND SuiteSparse_OPTIONAL_DEPENDENCIES RT)
|
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
|
|
if (SuiteSparse_FOUND AND SuiteSparse_LINK_TARGET)
|
|
|
|
|
get_target_property(SuiteSparse_ORIGINAL_CONFIG_LINK
|
|
|
|
|
SuiteSparse::Config INTERFACE_LINK_LIBRARIES)
|
|
|
|
|
if (SuiteSparse_ORIGINAL_CONFIG_LINK MATCHES "-NOTFOUND$")
|
|
|
|
|
set (SuiteSparse_ORIGINAL_CONFIG_LINK)
|
|
|
|
|
endif ()
|
|
|
|
|
if (TARGET SuiteSparse::SPQR)
|
|
|
|
|
get_target_property(SuiteSparse_ORIGINAL_SPQR_LINK
|
|
|
|
|
SuiteSparse::SPQR INTERFACE_LINK_LIBRARIES)
|
|
|
|
|
if (SuiteSparse_ORIGINAL_SPQR_LINK MATCHES "-NOTFOUND$")
|
|
|
|
|
set (SuiteSparse_ORIGINAL_SPQR_LINK)
|
|
|
|
|
endif ()
|
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
|
|
function (suitesparse_set_link_dependencies)
|
|
|
|
|
set (SuiteSparse_CONFIG_LINK ${SuiteSparse_ORIGINAL_CONFIG_LINK})
|
|
|
|
|
if (BLAS IN_LIST ARGN)
|
|
|
|
|
list (APPEND SuiteSparse_CONFIG_LINK ${SuiteSparse_BLAS_LINK})
|
|
|
|
|
endif ()
|
|
|
|
|
if (LAPACK IN_LIST ARGN)
|
|
|
|
|
list (APPEND SuiteSparse_CONFIG_LINK ${SuiteSparse_LAPACK_LINK})
|
|
|
|
|
endif ()
|
|
|
|
|
if (RT IN_LIST ARGN)
|
|
|
|
|
list (APPEND SuiteSparse_CONFIG_LINK ${SuiteSparse_RT_LINK})
|
|
|
|
|
endif ()
|
|
|
|
|
set_property (TARGET SuiteSparse::Config PROPERTY
|
|
|
|
|
INTERFACE_LINK_LIBRARIES "${SuiteSparse_CONFIG_LINK}")
|
|
|
|
|
|
|
|
|
|
if (TARGET SuiteSparse::SPQR)
|
|
|
|
|
set (SuiteSparse_SPQR_LINK ${SuiteSparse_ORIGINAL_SPQR_LINK})
|
|
|
|
|
if (TBB IN_LIST ARGN)
|
|
|
|
|
list (APPEND SuiteSparse_SPQR_LINK ${SuiteSparse_TBB_LINK})
|
|
|
|
|
endif ()
|
|
|
|
|
set_property (TARGET SuiteSparse::SPQR PROPERTY
|
|
|
|
|
INTERFACE_LINK_LIBRARIES "${SuiteSparse_SPQR_LINK}")
|
|
|
|
|
endif ()
|
|
|
|
|
endfunction (suitesparse_set_link_dependencies)
|
|
|
|
|
|
|
|
|
|
suitesparse_set_link_dependencies(${SuiteSparse_OPTIONAL_DEPENDENCIES})
|
|
|
|
|
suitesparse_check_link(SuiteSparse_LINKS
|
|
|
|
|
${SuiteSparse_LINK_SYMBOL} ${SuiteSparse_LINK_TARGET})
|
|
|
|
|
if (SuiteSparse_LINKS)
|
|
|
|
|
set (SuiteSparse_REQUIRED_DEPENDENCIES)
|
|
|
|
|
foreach (dependency IN LISTS SuiteSparse_OPTIONAL_DEPENDENCIES)
|
|
|
|
|
set (SuiteSparse_DEPENDENCIES_WITHOUT
|
|
|
|
|
${SuiteSparse_OPTIONAL_DEPENDENCIES})
|
|
|
|
|
list (REMOVE_ITEM SuiteSparse_DEPENDENCIES_WITHOUT ${dependency})
|
|
|
|
|
suitesparse_set_link_dependencies(${SuiteSparse_DEPENDENCIES_WITHOUT})
|
|
|
|
|
suitesparse_check_link(SuiteSparse_LINKS_WITHOUT_DEPENDENCY
|
|
|
|
|
${SuiteSparse_LINK_SYMBOL} ${SuiteSparse_LINK_TARGET})
|
|
|
|
|
if (NOT SuiteSparse_LINKS_WITHOUT_DEPENDENCY)
|
|
|
|
|
list (APPEND SuiteSparse_REQUIRED_DEPENDENCIES ${dependency})
|
|
|
|
|
endif ()
|
|
|
|
|
endforeach ()
|
|
|
|
|
|
|
|
|
|
suitesparse_set_link_dependencies(${SuiteSparse_REQUIRED_DEPENDENCIES})
|
|
|
|
|
else ()
|
|
|
|
|
suitesparse_set_link_dependencies()
|
|
|
|
|
list (APPEND SuiteSparse_REQUIRED_VARS SuiteSparse_LINKS)
|
|
|
|
|
set (SuiteSparse_MISSING_DEPENDENCIES)
|
|
|
|
|
if (NOT SuiteSparse_BLAS_LINK)
|
|
|
|
|
list (APPEND SuiteSparse_MISSING_DEPENDENCIES BLAS)
|
|
|
|
|
endif ()
|
|
|
|
|
if (NOT SuiteSparse_LAPACK_LINK)
|
|
|
|
|
list (APPEND SuiteSparse_MISSING_DEPENDENCIES LAPACK)
|
|
|
|
|
endif ()
|
|
|
|
|
if (TARGET SuiteSparse::SPQR AND NOT SuiteSparse_TBB_LINK)
|
|
|
|
|
list (APPEND SuiteSparse_MISSING_DEPENDENCIES TBB)
|
|
|
|
|
endif ()
|
|
|
|
|
if (NOT SuiteSparse_RT_LINK)
|
|
|
|
|
list (APPEND SuiteSparse_MISSING_DEPENDENCIES RT)
|
|
|
|
|
endif ()
|
|
|
|
|
if (SuiteSparse_MISSING_DEPENDENCIES)
|
|
|
|
|
foreach (dependency IN LISTS SuiteSparse_MISSING_DEPENDENCIES)
|
|
|
|
|
if (SuiteSparse_${dependency}_REASON)
|
|
|
|
|
list (APPEND CMAKE_FIND_PACKAGE_REASON
|
|
|
|
|
"${SuiteSparse_${dependency}_REASON}")
|
|
|
|
|
endif ()
|
|
|
|
|
endforeach ()
|
|
|
|
|
set (SuiteSparse_LINK_FAILURE_REASON
|
|
|
|
|
"SuiteSparse libraries could not be linked with the detected "
|
|
|
|
|
"dependencies. The following dependencies were not found, so their "
|
|
|
|
|
"necessity could not be determined: ${SuiteSparse_MISSING_DEPENDENCIES}.")
|
|
|
|
|
suitesparse_report_not_found("${SuiteSparse_LINK_FAILURE_REASON}")
|
|
|
|
|
else ()
|
|
|
|
|
set (SuiteSparse_LINK_FAILURE_REASON
|
|
|
|
|
"SuiteSparse libraries could not be linked with the detected "
|
|
|
|
|
"dependencies.")
|
|
|
|
|
suitesparse_report_not_found("${SuiteSparse_LINK_FAILURE_REASON}")
|
|
|
|
|
endif ()
|
|
|
|
|
endif ()
|
|
|
|
|
endif ()
|
|
|
|
|
|
2022-05-15 22:26:18 +02:00
|
|
|
# Check whether CHOLMOD was compiled with METIS support. The check can be
|
|
|
|
|
# performed only after the main components have been set up.
|
|
|
|
|
if (TARGET SuiteSparse::CHOLMOD)
|
|
|
|
|
# NOTE If SuiteSparse was compiled as a static library we'll need to link
|
|
|
|
|
# against METIS already during the check. Otherwise, the check can fail due to
|
|
|
|
|
# undefined references even though SuiteSparse was compiled with METIS.
|
2023-09-10 17:46:26 +02:00
|
|
|
if (NOT DEFINED METIS_FOUND)
|
|
|
|
|
find_package (METIS)
|
|
|
|
|
endif()
|
2022-05-15 22:26:18 +02:00
|
|
|
|
|
|
|
|
if (TARGET METIS::METIS)
|
|
|
|
|
cmake_push_check_state (RESET)
|
|
|
|
|
set (CMAKE_REQUIRED_LIBRARIES SuiteSparse::CHOLMOD METIS::METIS)
|
|
|
|
|
check_symbol_exists (cholmod_metis cholmod.h SuiteSparse_CHOLMOD_USES_METIS)
|
|
|
|
|
cmake_pop_check_state ()
|
|
|
|
|
|
|
|
|
|
if (SuiteSparse_CHOLMOD_USES_METIS)
|
|
|
|
|
set_property (TARGET SuiteSparse::CHOLMOD APPEND PROPERTY
|
|
|
|
|
INTERFACE_LINK_LIBRARIES $<LINK_ONLY:METIS::METIS>)
|
|
|
|
|
|
|
|
|
|
# Provide the SuiteSparse::Partition component whose availability indicates
|
|
|
|
|
# that CHOLMOD was compiled with the Partition module.
|
|
|
|
|
if (NOT TARGET SuiteSparse::Partition)
|
|
|
|
|
add_library (SuiteSparse::Partition IMPORTED INTERFACE)
|
|
|
|
|
endif (NOT TARGET SuiteSparse::Partition)
|
|
|
|
|
|
|
|
|
|
set_property (TARGET SuiteSparse::Partition APPEND PROPERTY
|
|
|
|
|
INTERFACE_LINK_LIBRARIES SuiteSparse::CHOLMOD)
|
|
|
|
|
endif (SuiteSparse_CHOLMOD_USES_METIS)
|
|
|
|
|
endif (TARGET METIS::METIS)
|
|
|
|
|
endif (TARGET SuiteSparse::CHOLMOD)
|
|
|
|
|
|
|
|
|
|
# We do not use suitesparse_find_component to find Partition and therefore must
|
|
|
|
|
# handle the availability in an extra step.
|
|
|
|
|
if (TARGET SuiteSparse::Partition)
|
|
|
|
|
set (SuiteSparse_Partition_FOUND TRUE)
|
|
|
|
|
else (TARGET SuiteSparse::Partition)
|
|
|
|
|
set (SuiteSparse_Partition_FOUND FALSE)
|
|
|
|
|
endif (TARGET SuiteSparse::Partition)
|
|
|
|
|
|
2015-08-09 15:18:42 +01:00
|
|
|
suitesparse_reset_find_library_prefix()
|
2015-03-28 16:45:50 +00:00
|
|
|
|
2023-09-10 17:46:26 +02:00
|
|
|
list(REMOVE_DUPLICATES SuiteSparse_REQUIRED_VARS)
|
|
|
|
|
|
|
|
|
|
# Handle REQUIRED and QUIET arguments to FIND_PACKAGE.
|
2015-08-09 15:18:42 +01:00
|
|
|
include(FindPackageHandleStandardArgs)
|
2023-09-10 17:46:26 +02:00
|
|
|
list(REMOVE_DUPLICATES CMAKE_FIND_PACKAGE_REASON)
|
|
|
|
|
string(JOIN "\n " CMAKE_FIND_PACKAGE_REASON
|
|
|
|
|
${CMAKE_FIND_PACKAGE_REASON})
|
|
|
|
|
find_package_handle_standard_args(SuiteSparse
|
|
|
|
|
REQUIRED_VARS ${SuiteSparse_REQUIRED_VARS}
|
|
|
|
|
VERSION_VAR SuiteSparse_VERSION
|
|
|
|
|
REASON_FAILURE_MESSAGE "${CMAKE_FIND_PACKAGE_REASON}"
|
|
|
|
|
HANDLE_COMPONENTS)
|
2022-03-08 13:12:24 -08:00
|
|
|
|
|
|
|
|
# Pop CMP0057.
|
|
|
|
|
cmake_policy (POP)
|