FindHWLOC.cmake: Missing library path in hwloc_bitmap_free detection
Hi,
I got an issue where "check_library_exists([...] hwloc_bitmap_free [...]) fails as the result of '-lhwloc' not found. Examining CMakeError.log shows that the "-L..." flag is missing on the command line of the compiler call performing the check.
The error was encountered while attempting to build PaStiX (commit: 628bc7b2a205789aa7d09e65805de4f4cf96ba2e), using libhwloc version 1.11.7.
The error causes a failed build of PaStiX, since the wrong set of hwloc routines is selected in PASTIX/common/isched_hwloc.c
The hack below seems to fix the issue.
Best regards,
Olivier Aumage
diff --git a/modules/find/FindHWLOC.cmake b/modules/find/FindHWLOC.cmake
index 8a0eb7d..e537500 100644
--- a/modules/find/FindHWLOC.cmake
+++ b/modules/find/FindHWLOC.cmake
@@ -321,6 +321,11 @@ endif()
if (HWLOC_FOUND)
set(HWLOC_SAVE_CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES})
list(APPEND CMAKE_REQUIRED_INCLUDES ${HWLOC_INCLUDE_DIRS})
+ set(CMAKE_REQUIRED_LIBRARIES)
+ foreach(lib_dir ${HWLOC_LIBDIR})
+ list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}")
+ endforeach()
+ string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
# test headers to guess the version
check_struct_has_member( "struct hwloc_obj" parent hwloc.h HAVE_HWLOC_PARENT_MEMBER )