Skip to content

Commit 4a96114

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 aaa4770 commit 4a96114

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

CMakeLists.txt

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

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

123128
if(UMF_BUILD_TESTS)

cmake/FindTBB.cmake

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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 'tbb' using find_library()")
6+
7+
find_library(TBB_LIBRARY NAMES tbbmalloc tbbmalloc)
8+
set(TBB_LIBRARIES ${TBB_LIBRARY})
9+
10+
get_filename_component(TBB_LIB_DIR ${TBB_LIBRARIES} DIRECTORY)
11+
set(TBB_LIBRARY_DIRS ${TBB_LIB_DIR})
12+
13+
find_file(TBB_HEADER NAMES "tbb/scalable_allocator.h")
14+
if(TBB_HEADER)
15+
get_filename_component(TBB_INCLUDE_DIR_TBB ${TBB_HEADER} DIRECTORY)
16+
get_filename_component(TBB_INCLUDE_DIR ${TBB_INCLUDE_DIR_TBB} DIRECTORY)
17+
set(TBB_INCLUDE_DIRS ${TBB_INCLUDE_DIR})
18+
else()
19+
set(MSG_NOT_FOUND "<tbb/scalable_allocator.h> header NOT found (set CMAKE_PREFIX_PATH to point the location)")
20+
if(TBB_FIND_REQUIRED)
21+
message(FATAL_ERROR ${MSG_NOT_FOUND})
22+
else()
23+
message(WARNING ${MSG_NOT_FOUND})
24+
endif()
25+
endif()
26+
27+
if(WINDOWS)
28+
find_file(TBB_DLL NAMES "bin/tbbmalloc.dll")
29+
get_filename_component(TBB_DLL_DIR ${TBB_DLL} DIRECTORY)
30+
set(TBB_DLL_DIRS ${TBB_DLL_DIR})
31+
endif()
32+
33+
if(TBB_LIBRARY)
34+
message(STATUS " Found tbb using find_library()")
35+
message(STATUS " TBB_LIBRARIES = ${TBB_LIBRARIES}")
36+
message(STATUS " TBB_INCLUDE_DIRS = ${TBB_INCLUDE_DIRS}")
37+
message(STATUS " TBB_LIBRARY_DIRS = ${TBB_LIBRARY_DIRS}")
38+
if(WINDOWS)
39+
message(STATUS " TBB_DLL_DIRS = ${TBB_DLL_DIRS}")
40+
endif()
41+
else()
42+
set(MSG_NOT_FOUND "tbb NOT found (set CMAKE_PREFIX_PATH to point the location)")
43+
if(TBB_FIND_REQUIRED)
44+
message(FATAL_ERROR ${MSG_NOT_FOUND})
45+
else()
46+
message(WARNING ${MSG_NOT_FOUND})
47+
endif()
48+
endif()

0 commit comments

Comments
 (0)