Skip to content

Commit e1472a8

Browse files
committed
Add looking for the tbbmalloc library and the header
Add looking for the tbbmalloc library and the <tbb/scalable_allocator.h> header. Signed-off-by: Lukasz Dorau <[email protected]>
1 parent 1ffccf8 commit e1472a8

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ if(UMF_BUILD_OS_MEMORY_PROVIDER AND (LINUX OR WINDOWS))
117117
find_package(LIBHWLOC REQUIRED hwloc)
118118
endif()
119119

120+
if(UMF_BUILD_LIBUMF_POOL_SCALABLE AND (LINUX OR WINDOWS))
121+
# Do not use pkgconfig, because it sets wrong paths on Windows
122+
find_package(LIBTBB REQUIRED tbb)
123+
endif()
124+
120125
add_subdirectory(src)
121126

122127
if(UMF_BUILD_TESTS)

cmake/FindLIBTBB.cmake

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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 'libtbb' using find_library()")
6+
7+
find_library(LIBTBB_LIBRARY NAMES libtbbmalloc tbbmalloc)
8+
set(LIBTBB_LIBRARIES ${LIBTBB_LIBRARY})
9+
10+
find_file(LIBTBB_HEADER NAMES scalable_allocator.h HINTS /usr/include/tbb ${CMAKE_PREFIX_PATH}/include/tbb)
11+
if(LIBTBB_HEADER)
12+
get_filename_component(LIBTBB_INCLUDE_DIR_TBB ${LIBTBB_HEADER} DIRECTORY)
13+
get_filename_component(LIBTBB_INCLUDE_DIR ${LIBTBB_INCLUDE_DIR_TBB} DIRECTORY)
14+
set(LIBTBB_INCLUDE_DIRS ${LIBTBB_INCLUDE_DIR})
15+
else()
16+
set(MSG_NOT_FOUND "<tbb/scalable_allocator.h> header NOT found (set CMAKE_PREFIX_PATH to point the location)")
17+
if(LIBTBB_FIND_REQUIRED)
18+
message(FATAL_ERROR ${MSG_NOT_FOUND})
19+
else()
20+
message(WARNING ${MSG_NOT_FOUND})
21+
endif()
22+
endif()
23+
24+
if(WINDOWS)
25+
find_file(LIBTBB_DLL NAMES tbbmalloc.dll HINTS ${CMAKE_PREFIX_PATH}/bin)
26+
get_filename_component(LIBTBB_DLL_DIR ${LIBTBB_DLL} DIRECTORY)
27+
set(LIBTBB_DLL_DIRS ${LIBTBB_DLL_DIR})
28+
endif()
29+
30+
if(LIBTBB_LIBRARY)
31+
message(STATUS " Found libtbb using find_library()")
32+
message(STATUS " LIBTBB_LIBRARIES = ${LIBTBB_LIBRARIES}")
33+
message(STATUS " LIBTBB_INCLUDE_DIRS = ${LIBTBB_INCLUDE_DIRS}")
34+
if(WINDOWS)
35+
message(STATUS " LIBTBB_DLL_DIRS = ${LIBTBB_DLL_DIRS}")
36+
endif()
37+
else()
38+
set(MSG_NOT_FOUND "libtbb NOT found (set CMAKE_PREFIX_PATH to point the location)")
39+
if(LIBTBB_FIND_REQUIRED)
40+
message(FATAL_ERROR ${MSG_NOT_FOUND})
41+
else()
42+
message(WARNING ${MSG_NOT_FOUND})
43+
endif()
44+
endif()

0 commit comments

Comments
 (0)