| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | |
| | FindCXSparse |
| | ============ |
| |
|
| | Find CXSparse and its dependencies. |
| |
|
| | This module defines the following variables which should be referenced by the |
| | caller to use the library. |
| |
|
| | ``CXSparse_FOUND`` |
| | ``TRUE`` iff CXSparse and all dependencies have been found. |
| |
|
| | ``CXSparse_VERSION`` |
| | Extracted from ``cs.h``. |
| |
|
| | ``CXSparse_VERSION_MAJOR`` |
| | Equal to 3 if ``CXSparse_VERSION`` = 3.1.2 |
| |
|
| | ``CXSparse_VERSION_MINOR`` |
| | Equal to 1 if ``CXSparse_VERSION`` = 3.1.2 |
| |
|
| | ``CXSparse_VERSION_PATCH`` |
| | Equal to 2 if ``CXSparse_VERSION`` = 3.1.2 |
| |
|
| | The following variables control the behaviour of this module: |
| |
|
| | ``CXSparse_NO_CMAKE`` |
| | Do not attempt to use the native CXSparse CMake package configuration. |
| |
|
| | Targets |
| | ------- |
| |
|
| | The following target defines CXSparse. |
| |
|
| | ``CXSparse::CXSparse`` |
| | The main CXSparse to be linked against. |
| |
|
| | The following variables are also defined by this module, but in line with CMake |
| | recommended ``find_package`` module style should NOT be referenced directly by |
| | callers (use the plural variables detailed above instead). These variables do |
| | however affect the behaviour of the module via ``find_[path/library]()`` which |
| | are NOT re-called (i.e., search for library is not repeated) if these variables |
| | are set with valid values *in the CMake cache*. This means that if these |
| | variables are set directly in the cache, either by the user in the CMake GUI, or |
| | by the user passing ``-DVAR=VALUE`` directives to CMake when called (which |
| | explicitly defines a cache variable), then they will be used verbatim, bypassing |
| | the ``HINTS`` variables and other hard-coded search locations. |
| |
|
| | ``CXSparse_INCLUDE_DIR`` |
| | Include directory for CXSparse, not including the include directory of any |
| | dependencies. |
| |
|
| | ``CXSparse_LIBRARY`` |
| | CXSparse library, not including the libraries of any dependencies. |
| | ]=======================================================================] |
| |
|
| | if (NOT CXSparse_NO_CMAKE) |
| | find_package (CXSparse NO_MODULE QUIET) |
| | endif (NOT CXSparse_NO_CMAKE) |
| |
|
| | if (CXSparse_FOUND) |
| | return () |
| | endif (CXSparse_FOUND) |
| |
|
| | |
| | |
| | macro(CXSparse_RESET_FIND_LIBRARY_PREFIX) |
| | if (MSVC) |
| | set(CMAKE_FIND_LIBRARY_PREFIXES "${CALLERS_CMAKE_FIND_LIBRARY_PREFIXES}") |
| | endif (MSVC) |
| | endmacro(CXSparse_RESET_FIND_LIBRARY_PREFIX) |
| |
|
| | |
| | |
| | |
| | macro(CXSparse_REPORT_NOT_FOUND REASON_MSG) |
| | |
| | |
| | mark_as_advanced(CLEAR CXSparse_INCLUDE_DIR |
| | CXSparse_LIBRARY) |
| |
|
| | cxsparse_reset_find_library_prefix() |
| |
|
| | |
| | |
| | if (CXSparse_FIND_QUIETLY) |
| | message(STATUS "Failed to find CXSparse - " ${REASON_MSG} ${ARGN}) |
| | elseif (CXSparse_FIND_REQUIRED) |
| | message(FATAL_ERROR "Failed to find CXSparse - " ${REASON_MSG} ${ARGN}) |
| | else() |
| | |
| | |
| | message("-- Failed to find CXSparse - " ${REASON_MSG} ${ARGN}) |
| | endif () |
| | return() |
| | endmacro(CXSparse_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 CXSparse_CHECK_PATH_SUFFIXES |
| | suitesparse) |
| |
|
| | |
| | find_path(CXSparse_INCLUDE_DIR |
| | NAMES cs.h |
| | PATH_SUFFIXES ${CXSparse_CHECK_PATH_SUFFIXES}) |
| | if (NOT CXSparse_INCLUDE_DIR OR |
| | NOT EXISTS ${CXSparse_INCLUDE_DIR}) |
| | cxsparse_report_not_found( |
| | "Could not find CXSparse include directory, set CXSparse_INCLUDE_DIR " |
| | "to directory containing cs.h") |
| | endif (NOT CXSparse_INCLUDE_DIR OR |
| | NOT EXISTS ${CXSparse_INCLUDE_DIR}) |
| |
|
| | find_library(CXSparse_LIBRARY NAMES cxsparse |
| | PATH_SUFFIXES ${CXSparse_CHECK_PATH_SUFFIXES}) |
| |
|
| | if (NOT CXSparse_LIBRARY OR |
| | NOT EXISTS ${CXSparse_LIBRARY}) |
| | cxsparse_report_not_found( |
| | "Could not find CXSparse library, set CXSparse_LIBRARY " |
| | "to full path to libcxsparse.") |
| | endif (NOT CXSparse_LIBRARY OR |
| | NOT EXISTS ${CXSparse_LIBRARY}) |
| |
|
| | |
| | |
| | set(CXSparse_FOUND TRUE) |
| |
|
| | |
| | if (CXSparse_INCLUDE_DIR) |
| | set(CXSparse_VERSION_FILE ${CXSparse_INCLUDE_DIR}/cs.h) |
| | if (NOT EXISTS ${CXSparse_VERSION_FILE}) |
| | cxsparse_report_not_found( |
| | "Could not find file: ${CXSparse_VERSION_FILE} " |
| | "containing version information in CXSparse install located at: " |
| | "${CXSparse_INCLUDE_DIR}.") |
| | else (NOT EXISTS ${CXSparse_VERSION_FILE}) |
| | file(READ ${CXSparse_INCLUDE_DIR}/cs.h CXSparse_VERSION_FILE_CONTENTS) |
| |
|
| | string(REGEX MATCH "#define CS_VER [0-9]+" |
| | CXSparse_VERSION_MAJOR "${CXSparse_VERSION_FILE_CONTENTS}") |
| | string(REGEX REPLACE "#define CS_VER ([0-9]+)" "\\1" |
| | CXSparse_VERSION_MAJOR "${CXSparse_VERSION_MAJOR}") |
| |
|
| | string(REGEX MATCH "#define CS_SUBVER [0-9]+" |
| | CXSparse_VERSION_MINOR "${CXSparse_VERSION_FILE_CONTENTS}") |
| | string(REGEX REPLACE "#define CS_SUBVER ([0-9]+)" "\\1" |
| | CXSparse_VERSION_MINOR "${CXSparse_VERSION_MINOR}") |
| |
|
| | string(REGEX MATCH "#define CS_SUBSUB [0-9]+" |
| | CXSparse_VERSION_PATCH "${CXSparse_VERSION_FILE_CONTENTS}") |
| | string(REGEX REPLACE "#define CS_SUBSUB ([0-9]+)" "\\1" |
| | CXSparse_VERSION_PATCH "${CXSparse_VERSION_PATCH}") |
| |
|
| | |
| | |
| | set(CXSparse_VERSION "${CXSparse_VERSION_MAJOR}.${CXSparse_VERSION_MINOR}.${CXSparse_VERSION_PATCH}") |
| | set(CXSparse_VERSION_COMPONENTS 3) |
| | endif (NOT EXISTS ${CXSparse_VERSION_FILE}) |
| | endif (CXSparse_INCLUDE_DIR) |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | string(TOLOWER "${CXSparse_LIBRARY}" LOWERCASE_CXSparse_LIBRARY) |
| | if (CXSparse_LIBRARY AND |
| | EXISTS ${CXSparse_LIBRARY} AND |
| | NOT "${LOWERCASE_CXSparse_LIBRARY}" MATCHES ".*cxsparse[^/]*") |
| | cxsparse_report_not_found( |
| | "Caller defined CXSparse_LIBRARY: " |
| | "${CXSparse_LIBRARY} does not match CXSparse.") |
| | endif (CXSparse_LIBRARY AND |
| | EXISTS ${CXSparse_LIBRARY} AND |
| | NOT "${LOWERCASE_CXSparse_LIBRARY}" MATCHES ".*cxsparse[^/]*") |
| |
|
| | cxsparse_reset_find_library_prefix() |
| |
|
| | mark_as_advanced(CXSparse_INCLUDE_DIR CXSparse_LIBRARY) |
| |
|
| | |
| | include(FindPackageHandleStandardArgs) |
| | find_package_handle_standard_args(CXSparse |
| | REQUIRED_VARS CXSparse_INCLUDE_DIR CXSparse_LIBRARY |
| | VERSION_VAR CXSparse_VERSION) |
| |
|
| | if (CXSparse_INCLUDE_DIR AND CXSparse_LIBRARY) |
| | if (NOT TARGET CXSparse::CXSparse) |
| | add_library (CXSparse::CXSparse IMPORTED UNKNOWN) |
| | endif (NOT TARGET CXSparse::CXSparse) |
| |
|
| | set_property (TARGET CXSparse::CXSparse PROPERTY |
| | IMPORTED_LOCATION ${CXSparse_LIBRARY}) |
| | set_property (TARGET CXSparse::CXSparse PROPERTY |
| | INTERFACE_INCLUDE_DIRECTORIES ${CXSparse_INCLUDE_DIR}) |
| | endif (CXSparse_INCLUDE_DIR AND CXSparse_LIBRARY) |
| |
|