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