blob: 76ce6ed1537e9cf401f6beaa0c957c1242276c49 (
plain)
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
|
diff --git a/cmake/FindSuiteSparse.cmake b/cmake/FindSuiteSparse.cmake
index 4e05930..0e3a10b 100644
--- a/cmake/FindSuiteSparse.cmake
+++ b/cmake/FindSuiteSparse.cmake
@@ -404,26 +404,36 @@
else (NOT EXISTS ${SuiteSparse_VERSION_FILE})
file(READ ${SuiteSparse_VERSION_FILE} Config_CONTENTS)
- string(REGEX MATCH "#define SUITESPARSE_MAIN_VERSION [0-9]+"
- SuiteSparse_VERSION_MAJOR "${Config_CONTENTS}")
- string(REGEX REPLACE "#define SUITESPARSE_MAIN_VERSION ([0-9]+)" "\\1"
- SuiteSparse_VERSION_MAJOR "${SuiteSparse_VERSION_MAJOR}")
+ string(REGEX MATCH "#define SUITESPARSE_MAIN_VERSION[ \t]+([0-9]+)"
+ SuiteSparse_VERSION_LINE "${Config_CONTENTS}")
+ set (SuiteSparse_VERSION_MAJOR ${CMAKE_MATCH_1})
- string(REGEX MATCH "#define SUITESPARSE_SUB_VERSION [0-9]+"
- SuiteSparse_VERSION_MINOR "${Config_CONTENTS}")
- string(REGEX REPLACE "#define SUITESPARSE_SUB_VERSION ([0-9]+)" "\\1"
- SuiteSparse_VERSION_MINOR "${SuiteSparse_VERSION_MINOR}")
+ string(REGEX MATCH "#define SUITESPARSE_SUB_VERSION[ \t]+([0-9]+)"
+ SuiteSparse_VERSION_LINE "${Config_CONTENTS}")
+ set (SuiteSparse_VERSION_MINOR ${CMAKE_MATCH_1})
- string(REGEX MATCH "#define SUITESPARSE_SUBSUB_VERSION [0-9]+"
- SuiteSparse_VERSION_PATCH "${Config_CONTENTS}")
- string(REGEX REPLACE "#define SUITESPARSE_SUBSUB_VERSION ([0-9]+)" "\\1"
- SuiteSparse_VERSION_PATCH "${SuiteSparse_VERSION_PATCH}")
+ 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)
# 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.
set(SuiteSparse_VERSION
"${SuiteSparse_VERSION_MAJOR}.${SuiteSparse_VERSION_MINOR}.${SuiteSparse_VERSION_PATCH}")
- set(SuiteSparse_VERSION_COMPONENTS 3)
+
+ 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)
+ endif (SuiteSparse_VERSION MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+")
endif (NOT EXISTS ${SuiteSparse_VERSION_FILE})
endif (TARGET SuiteSparse::Config)
|