Debian Codegraph @

cmake_aux/Modules/ARMA_FindSuperLU.cmake

raw
1 # Try to find suitable version of SuperLU
2 # Once done, this will define
3 #
4 # SuperLU_FOUND - system has SuperLU
5 # SuperLU_LIBRARY - Link this to use SuperLU
6 # SuperLU_INCLUDE_DIR - directory of SuperLU headers
7
8 find_path(SuperLU_INCLUDE_DIR slu_ddefs.h
9 PATHS ${CMAKE_SYSTEM_INCLUDE_PATH} /usr/include /usr/local/include /opt/local/include
10 PATH_SUFFIXES superlu SuperLU ""
11 )
12
13 find_library(SuperLU_LIBRARY
14 NAMES superlu
15 PATHS ${CMAKE_SYSTEM_LIBRARY_PATH} /usr/lib64 /usr/lib /usr/local/lib64 /usr/local/lib /opt/local/lib64 /opt/local/lib
16 )
17
18 set(SuperLU_FOUND NO)
19
20 if(NOT SuperLU_FIND_QUIETLY)
21 message(STATUS "Looking for suitable version of SuperLU")
22 endif()
23
24 if(SuperLU_LIBRARY AND SuperLU_INCLUDE_DIR)
25
26 # determine if this is a suitable version of SuperLU
27
28 if(EXISTS "${SuperLU_INCLUDE_DIR}/slu_ddefs.h")
29
30 file(READ "${SuperLU_INCLUDE_DIR}/slu_ddefs.h" _slu_HEADER_CONTENTS)
31
32 string(REGEX REPLACE ".*version ([0-9]).*" "\\1" SLU_VERSION_MAJOR "${_slu_HEADER_CONTENTS}")
33
34 if("${SLU_VERSION_MAJOR}" EQUAL "7")
35 set(SuperLU_FOUND YES)
36 endif()
37
38 if("${SLU_VERSION_MAJOR}" EQUAL "6")
39 set(SuperLU_FOUND YES)
40 endif()
41
42 if("${SLU_VERSION_MAJOR}" EQUAL "5")
43 set(SuperLU_FOUND YES)
44 endif()
45
46 if("${SLU_VERSION_MAJOR}" EQUAL "4")
47
48 # NOTE: SLU_VERSION_MAJOR = 4 is not 100% reliable, as the version string in slu_ddefs.h wasn't updated in SuperLU 5.0, 5.1, 5.2
49 # NOTE: We need to explicitly check the prototype of dgssvx() to determine whether this is version 4 or 5.
50
51 string(FIND "${_slu_HEADER_CONTENTS}" "dgssvx" _slu_dgssvx_start)
52
53 if("${_slu_dgssvx_start}" GREATER 0)
54
55 string(SUBSTRING "${_slu_HEADER_CONTENTS}" ${_slu_dgssvx_start} -1 _slu_dgssvx_tmp)
56
57 string(FIND "${_slu_dgssvx_tmp}" ";" _slu_dgssvx_len)
58
59 string(SUBSTRING "${_slu_HEADER_CONTENTS}" ${_slu_dgssvx_start} ${_slu_dgssvx_len} _slu_dgssvx_proto)
60
61 string(FIND "${_slu_dgssvx_proto}" "GlobalLU_t" _slu_dgssvx_check)
62
63 if("${_slu_dgssvx_check}" EQUAL -1)
64 # in version 4, dgssvx() doesn't have a GlobalLU_t argument
65 if(NOT SuperLU_FIND_QUIETLY)
66 message(STATUS "Found SuperLU 4, which is insufficient")
67 endif()
68 else()
69 set(SuperLU_FOUND YES)
70 endif()
71
72 endif()
73
74 endif()
75
76 else()
77
78 message(STATUS "Could not read ${SuperLU_INCLUDE_DIR}/slu_ddefs.h to verify suitable version")
79
80 endif()
81
82 endif()
83
84 if(SuperLU_LIBRARY AND NOT SuperLU_INCLUDE_DIR)
85 if(NOT SuperLU_FIND_QUIETLY)
86 message(STATUS "Incomplete installation of SuperLU: no SuperLU headers found")
87 endif()
88 endif()
89
90 if(NOT SuperLU_FOUND)
91 if(NOT SuperLU_FIND_QUIETLY)
92 message(STATUS "Could not find suitable version of SuperLU")
93 endif()
94 else()
95 message(STATUS "Found SuperLU library: ${SuperLU_LIBRARY}")
96 endif()
97