@@ -14,6 +14,29 @@ find_file(LIBHWLOC_HEADER NAMES hwloc.h)
14
14
get_filename_component (LIBHWLOC_INCLUDE_DIR ${LIBHWLOC_HEADER} DIRECTORY )
15
15
set (LIBHWLOC_INCLUDE_DIRS ${LIBHWLOC_INCLUDE_DIR} )
16
16
17
+ if (LIBHWLOC_INCLUDE_DIR )
18
+ if (EXISTS "${LIBHWLOC_INCLUDE_DIR} /hwloc/autogen/config.h" )
19
+ file (
20
+ STRINGS "${LIBHWLOC_INCLUDE_DIR} /hwloc/autogen/config.h"
21
+ LIBHWLOC_VERSION
22
+ REGEX
23
+ "#define[ \t ]HWLOC_VERSION[ \t ]\" ([0-9]+.[0-9]+.[0-9]+(rc[0-9])?)(-git)?\" "
24
+ )
25
+ string (
26
+ REGEX
27
+ REPLACE
28
+ "#define[ \t ]HWLOC_VERSION[ \t ]\" ([0-9]+.[0-9]+.[0-9]+(rc[0-9])?)(-git)?\" "
29
+ "\\ 1"
30
+ LIBHWLOC_VERSION
31
+ "${LIBHWLOC_VERSION} " )
32
+ else ()
33
+ message (
34
+ WARNING
35
+ "LIBHWLOC_INCLUDE_DIR found, but header with version info is missing"
36
+ )
37
+ endif ()
38
+ endif ()
39
+
17
40
if (WINDOWS )
18
41
find_file (LIBHWLOC_DLL NAMES "bin/hwloc-15.dll" "bin/libhwloc-15.dll" )
19
42
get_filename_component (LIBHWLOC_DLL_DIR ${LIBHWLOC_DLL} DIRECTORY )
@@ -25,9 +48,21 @@ if(LIBHWLOC_LIBRARY)
25
48
message (STATUS " LIBHWLOC_LIBRARIES = ${LIBHWLOC_LIBRARIES} " )
26
49
message (STATUS " LIBHWLOC_INCLUDE_DIRS = ${LIBHWLOC_INCLUDE_DIRS} " )
27
50
message (STATUS " LIBHWLOC_LIBRARY_DIRS = ${LIBHWLOC_LIBRARY_DIRS} " )
51
+ message (STATUS " LIBHWLOC_VERSION = ${LIBHWLOC_VERSION} " )
28
52
if (WINDOWS )
29
53
message (STATUS " LIBHWLOC_DLL_DIRS = ${LIBHWLOC_DLL_DIRS} " )
30
54
endif ()
55
+
56
+ if (LIBHWLOC_FIND_VERSION )
57
+ if (NOT LIBHWLOC_VERSION )
58
+ message (WARNING "Failed to retrieve libhwloc version" )
59
+ elseif (NOT LIBHWLOC_VERSION VERSION_GREATER_EQUAL LIBHWLOC_FIND_VERSION )
60
+ message (
61
+ FATAL_ERROR
62
+ " Required version: ${LIBHWLOC_FIND_VERSION} , found ${LIBHWLOC_VERSION} "
63
+ )
64
+ endif ()
65
+ endif ()
31
66
else ()
32
67
set (MSG_NOT_FOUND
33
68
"libhwloc NOT found (set CMAKE_PREFIX_PATH to point the location)" )
0 commit comments