Skip to content

Commit d80e829

Browse files
committed
Add searching for hwloc in CMake
Fixes: #252 Signed-off-by: Lukasz Dorau <[email protected]>
1 parent d53938f commit d80e829

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed

.github/workflows/pr_push.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ jobs:
7878
cmake
7979
-B ${{github.workspace}}/build
8080
-DUMF_FORMAT_CODE_STYLE=ON
81+
-DUMF_BUILD_OS_MEMORY_PROVIDER=OFF
8182
8283
- name: Build
8384
run: >

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ endforeach()
4242
include(CTest)
4343
include(CMakePackageConfigHelpers)
4444
include(GNUInstallDirs)
45+
find_package(PkgConfig)
4546

4647
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
4748
include(helpers)

cmake/FindLIBHWLOC.cmake

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright (C) 2024 Intel Corporation
2+
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
3+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
5+
message(STATUS "Checking for module 'libhwloc' using find_library()")
6+
7+
find_library(LIBHWLOC_LIBRARY NAMES libhwloc hwloc)
8+
set(LIBHWLOC_LIBRARIES ${LIBHWLOC_LIBRARY})
9+
10+
if(LIBHWLOC_LIBRARY)
11+
message(STATUS " Found libhwloc using find_library()")
12+
else()
13+
set(MSG_NOT_FOUND "libhwloc NOT found (set CMAKE_PREFIX_PATH to point the location)")
14+
if(LIBHWLOC_FIND_REQUIRED)
15+
message(FATAL_ERROR ${MSG_NOT_FOUND})
16+
else()
17+
message(WARNING ${MSG_NOT_FOUND})
18+
endif()
19+
endif()

src/CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,15 @@ if(UMF_BUILD_OS_MEMORY_PROVIDER)
5858
provider/provider_os_memory_linux.c
5959
memory_targets/memory_target_numa.c
6060
memspaces/memspace_numa.c)
61+
6162
if(LINUX)
62-
set(UMF_LIBS ${UMF_LIBS} hwloc)
63+
if(PkgConfig_FOUND)
64+
pkg_check_modules(LIBHWLOC hwloc)
65+
endif()
66+
if(NOT LIBHWLOC_FOUND)
67+
find_package(LIBHWLOC REQUIRED hwloc)
68+
endif()
69+
set(UMF_LIBS ${UMF_LIBS} ${LIBHWLOC_LIBRARIES})
6370
endif()
6471
endif()
6572

0 commit comments

Comments
 (0)