@@ -14,8 +14,25 @@ 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 (STRINGS "${LIBHWLOC_INCLUDE_DIR} /hwloc/autogen/config.h"
20
+ LIBHWLOC_VERSION
21
+ REGEX "#define[ \t ]HWLOC_VERSION[ \t ]\" [0-9]+.[0-9]+.[0-9]+\" " )
22
+ string (
23
+ REGEX
24
+ REPLACE "#define[ \t ]HWLOC_VERSION[ \t ]\" ([0-9]+.[0-9]+.[0-9]+)\" "
25
+ "\\ 1" LIBHWLOC_VERSION "${LIBHWLOC_VERSION} " )
26
+ else ()
27
+ message (
28
+ WARNING
29
+ "LIBHWLOC_INCLUDE_DIR found, but header with version info is missing"
30
+ )
31
+ endif ()
32
+ endif ()
33
+
17
34
if (WINDOWS )
18
- find_file (LIBHWLOC_DLL NAMES "bin/hwloc-15 .dll" "bin/libhwloc-15 .dll" )
35
+ find_file (LIBHWLOC_DLL NAMES "bin/hwloc-* .dll" "bin/libhwloc-* .dll" )
19
36
get_filename_component (LIBHWLOC_DLL_DIR ${LIBHWLOC_DLL} DIRECTORY )
20
37
set (LIBHWLOC_DLL_DIRS ${LIBHWLOC_DLL_DIR} )
21
38
endif ()
@@ -25,9 +42,21 @@ if(LIBHWLOC_LIBRARY)
25
42
message (STATUS " LIBHWLOC_LIBRARIES = ${LIBHWLOC_LIBRARIES} " )
26
43
message (STATUS " LIBHWLOC_INCLUDE_DIRS = ${LIBHWLOC_INCLUDE_DIRS} " )
27
44
message (STATUS " LIBHWLOC_LIBRARY_DIRS = ${LIBHWLOC_LIBRARY_DIRS} " )
45
+ message (STATUS " LIBHWLOC_VERSION = ${LIBHWLOC_VERSION} " )
28
46
if (WINDOWS )
29
47
message (STATUS " LIBHWLOC_DLL_DIRS = ${LIBHWLOC_DLL_DIRS} " )
30
48
endif ()
49
+
50
+ if (LIBHWLOC_FIND_VERSION )
51
+ if (NOT LIBHWLOC_VERSION )
52
+ message (WARNING "Failed to retrieve libhwloc version" )
53
+ elseif (NOT LIBHWLOC_VERSION VERSION_GREATER_EQUAL LIBHWLOC_FIND_VERSION )
54
+ message (
55
+ FATAL_ERROR
56
+ " Required version: ${LIBHWLOC_FIND_VERSION} , found ${LIBHWLOC_VERSION} "
57
+ )
58
+ endif ()
59
+ endif ()
31
60
else ()
32
61
set (MSG_NOT_FOUND
33
62
"libhwloc NOT found (set CMAKE_PREFIX_PATH to point the location)" )
0 commit comments