|
| 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