@@ -14,6 +14,23 @@ 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
35
find_file (LIBHWLOC_DLL NAMES "bin/hwloc-15.dll" "bin/libhwloc-15.dll" )
19
36
get_filename_component (LIBHWLOC_DLL_DIR ${LIBHWLOC_DLL} DIRECTORY )
@@ -25,9 +42,20 @@ 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 OR NOT LIBHWLOC_VERSION VERSION_GREATER_EQUAL
52
+ LIBHWLOC_FIND_VERSION )
53
+ message (
54
+ FATAL_ERROR
55
+ " Required version: ${LIBHWLOC_FIND_VERSION} , found ${LIBHWLOC_VERSION} "
56
+ )
57
+ endif ()
58
+ endif ()
31
59
else ()
32
60
set (MSG_NOT_FOUND
33
61
"libhwloc NOT found (set CMAKE_PREFIX_PATH to point the location)" )
0 commit comments