Debian Codegraph @

cmake/FindSuiteSparse.cmake

raw
1 # find_package(SuiteSparse COMPONENTS CSparse)
2
3 # - Try to find SuiteSparse
4 # Once done this will define
5 # SuiteSparse_FOUND - System has SuiteSparse
6 # SuiteSparse_INCLUDE_DIRS - The SuiteSparse include directories
7 # SuiteSparse_LIBRARIES - The libraries needed to use SuiteSparse
8
9 # For each component (currently only "CXSparse"):
10 # SuiteSparse_(component)_FOUND
11 # SuiteSparse_(component)_LIBRARY
12 # SuiteSparse_(component)_INCLUDE_DIR
13 # SuiteSparse_(component)_DEFINITIONS
14
15
16 # Required :
17 # - header : cs.h
18 # - libs : colamd, cxsparse (for cxsparse)
19
20 include(FindPackageHandleStandardArgs)
21
22
23 # Provide SuiteSparse_<C> variables for each component.
24 foreach(component IN LISTS SuiteSparse_FIND_COMPONENTS)
25 set(SuiteSparse_USE_${component} 1 )
26 endforeach()
27
28 set(_SUITESPARSE_REQUIRED_VARS)
29
30 # -- cxsparse component --
31 if (SuiteSparse_USE_CXSparse)
32 find_path(SuiteSparse_CXSparse_INCLUDE_DIR cs.h
33 PATH_SUFFIXES SuiteSparse suitesparse
34 DOC "Directory containing CXSparse header")
35
36 find_library(SuiteSparse_CXSparse_LIBRARY NAMES cxsparse)
37 # if (CXSparse_INCLUDE_DIR AND CXSparse_LIBRARY)
38 # set(SuiteSparse_CXSparse_FOUND TRUE)
39 # endif()
40
41 # At least on some systems we need to link to libcolamd which is
42 # another output from suitesparse.
43 find_library(colamd_LIBRARY NAMES colamd)
44
45 list(APPEND _SUITESPARSE_REQUIRED_VARS
46 SuiteSparse_CXSparse_LIBRARY SuiteSparse_CXSparse_INCLUDE_DIR)
47 set(SuiteSparse_CXSparse_LIBRARIES ${SuiteSparse_CXSparse_LIBRARY} ${colamd_LIBRARY})
48 if(SuiteSparse_CXSparse_INCLUDE_DIR AND SuiteSparse_CXSparse_LIBRARY)
49 set(SuiteSparse_CXSparse_FOUND TRUE)
50 endif()
51 endif ()
52
53 if(_SUITESPARSE_REQUIRED_VARS)
54 find_package_handle_standard_args(SuiteSparse
55 REQUIRED_VARS ${_SUITESPARSE_REQUIRED_VARS}
56 HANDLE_COMPONENTS)
57 else()
58 set(SuiteSparse_FOUND)
59 endif()
60
61 foreach(_component IN LISTS SuiteSparse_FIND_COMPONENTS)
62 if(SuiteSparse_${_component}_FOUND AND NOT TARGET SuiteSparse::${_component})
63 add_library(SuiteSparse::${_component} UNKNOWN IMPORTED)
64 set_target_properties(SuiteSparse::${_component} PROPERTIES
65 IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
66 IMPORTED_LOCATION "${SuiteSparse_${_component}_LIBRARY}"
67 INTERFACE_INCLUDE_DIRECTORIES "${SuiteSparse_${_component}_INCLUDE_DIR}"
68 INTERFACE_LINK_LIBRARIES "${SuiteSparse_${_component}_LIBRARIES}")
69 mark_as_advanced(SuiteSparse_${_component}_LIBRARIES SuiteSparse_${_component}_INCLUDE_DIR)
70 endif()
71 endforeach()
72
73