File: FindSuiteSparse.cmake

package info (click to toggle)
fclib 3.1.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 10,680 kB
  • sloc: ansic: 1,640; makefile: 71; sh: 36
file content (73 lines) | stat: -rw-r--r-- 2,481 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#  find_package(SuiteSparse COMPONENTS CSparse)

# - Try to find SuiteSparse
# Once done this will define
#  SuiteSparse_FOUND - System has SuiteSparse
#  SuiteSparse_INCLUDE_DIRS - The SuiteSparse include directories
#  SuiteSparse_LIBRARIES - The libraries needed to use SuiteSparse

# For each component (currently only "CXSparse"):
#  SuiteSparse_(component)_FOUND
#  SuiteSparse_(component)_LIBRARY
#  SuiteSparse_(component)_INCLUDE_DIR
#  SuiteSparse_(component)_DEFINITIONS


# Required :
# - header : cs.h
# - libs : colamd, cxsparse (for cxsparse)

include(FindPackageHandleStandardArgs)


# Provide SuiteSparse_<C> variables for each component.
foreach(component IN LISTS SuiteSparse_FIND_COMPONENTS)
  set(SuiteSparse_USE_${component} 1 )
endforeach()

set(_SUITESPARSE_REQUIRED_VARS)

# -- cxsparse component --
if (SuiteSparse_USE_CXSparse)
  find_path(SuiteSparse_CXSparse_INCLUDE_DIR cs.h
    PATH_SUFFIXES SuiteSparse suitesparse
    DOC "Directory containing CXSparse header")

  find_library(SuiteSparse_CXSparse_LIBRARY NAMES cxsparse)
  # if (CXSparse_INCLUDE_DIR AND CXSparse_LIBRARY)
  #     set(SuiteSparse_CXSparse_FOUND TRUE)
  # endif()

  # At least on some systems we need to link to libcolamd which is
  # another output from suitesparse.
  find_library(colamd_LIBRARY NAMES colamd)

  list(APPEND _SUITESPARSE_REQUIRED_VARS
    SuiteSparse_CXSparse_LIBRARY SuiteSparse_CXSparse_INCLUDE_DIR)  
  set(SuiteSparse_CXSparse_LIBRARIES ${SuiteSparse_CXSparse_LIBRARY} ${colamd_LIBRARY})
  if(SuiteSparse_CXSparse_INCLUDE_DIR AND  SuiteSparse_CXSparse_LIBRARY)
    set(SuiteSparse_CXSparse_FOUND TRUE)
  endif()
endif ()

if(_SUITESPARSE_REQUIRED_VARS)
  find_package_handle_standard_args(SuiteSparse
    REQUIRED_VARS ${_SUITESPARSE_REQUIRED_VARS}
    HANDLE_COMPONENTS)
else()
  set(SuiteSparse_FOUND)
endif()

foreach(_component IN LISTS SuiteSparse_FIND_COMPONENTS)
  if(SuiteSparse_${_component}_FOUND AND NOT TARGET SuiteSparse::${_component})
    add_library(SuiteSparse::${_component} UNKNOWN IMPORTED)
    set_target_properties(SuiteSparse::${_component} PROPERTIES
      IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
      IMPORTED_LOCATION "${SuiteSparse_${_component}_LIBRARY}"
      INTERFACE_INCLUDE_DIRECTORIES "${SuiteSparse_${_component}_INCLUDE_DIR}"
      INTERFACE_LINK_LIBRARIES "${SuiteSparse_${_component}_LIBRARIES}")
    mark_as_advanced(SuiteSparse_${_component}_LIBRARIES SuiteSparse_${_component}_INCLUDE_DIR)
  endif()
endforeach()