CMake find module for Intel Threading Building Blocks

Overview

FindTBB Module

FindTBB is a CMake find package module for Intel® Threading Building Blocks (TBB).

Usage

The signature of the TBB find module in CMake is:

find_package(TBB [major[.minor]] [EXACT] [QUIET] [REQUIRED]
             [COMPONENTS [tbbmalloc] [tbbmalloc_proxy] [tbb_preview]]
             [OPTIONAL_COMPONENTS [tbbmalloc] [tbbmalloc_proxy] [tbb_preview]]) 

where the allowed components are tbbmalloc and tbb_preview.

Example Project

With CMake 3.0 and later

") find_package(TBB COMPONENTS tbbmalloc tbbmalloc_proxy tbb_preview) add_executable(myapp myapp.cc) target_link_libraries(myapp tbb)">
cmake_minimum_required(VERSION 3.0)
project(MyProject)

list(APPEND CMAKE_MODULE_PATH "
    
     "
    )

find_package(TBB COMPONENTS tbbmalloc tbbmalloc_proxy tbb_preview)

add_executable(myapp myapp.cc)
target_link_libraries(myapp tbb)

With CMake 2.8 and earlier

") find_package(TBB COMPONENTS tbbmalloc tbbmalloc_proxy tbb_preview) add_executable(myapp myapp) target_include_directories(myapp PRIVATE ${TBB_INCLUDE_DIRS}) target_compile_definitions(myapp PRIVATE ${TBB_DEFINITIONS}) target_link_libraries(myapp ${TBB_LIBRARIES})">
cmake_minimum_required(VERSION 2.8)
project(MyProject)

list(APPEND CMAKE_MODULE_PATH "
    
     "
    )

find_package(TBB COMPONENTS tbbmalloc tbbmalloc_proxy tbb_preview)

add_executable(myapp myapp)
target_include_directories(myapp PRIVATE ${TBB_INCLUDE_DIRS})
target_compile_definitions(myapp PRIVATE ${TBB_DEFINITIONS})
target_link_libraries(myapp ${TBB_LIBRARIES})

User Variables

The following varibiles may be used by the user to specify the install, include, and/or library directories of TBB.

  • TBB_ROOT_DIR - The base directory the of TBB installation.
  • TBB_INCLUDE_DIR - The directory that contains the TBB headers files.
  • TBB_LIBRARY - The directory that contains the TBB library files.
  • TBB_ _LIBRARY - The path of the corresponding TBB library. These libraries, if specified, override the corresponding library search results, where may be tbb, tbb_debug, tbbmalloc, tbbmalloc_debug, tbb_preview, or tbb_preview_debug.
  • TBB_USE_DEBUG_BUILD - The debug version of tbb libraries, if present, will be used instead of the release version.

In addition, FindTBB uses the following environment variables to find the TBB install directory.

  • TBB_INSTALL_DIR
  • TBBROOT
  • LIBRARY_PATH

FindTBB Results

This module will set the following variables:

  • TBB_FOUND - Set to false, or undefined, if we haven’t found, or don’t want to use TBB.
  • TBB_ _FOUND - If False, optional part of TBB sytem is not available.
  • TBB_VERSION - The full version string
  • TBB_VERSION_MAJOR - The major version
  • TBB_VERSION_MINOR - The minor version
  • TBB_INTERFACE_VERSION - The interface version number defined in tbb/tbb_stddef.h.
  • TBB_ _LIBRARY_RELEASE - The path of the TBB release version of , where may be tbb, tbb_debug, tbbmalloc, tbbmalloc_proxy, or tbb_preview.
  • TBB_ _LIBRARY_DEGUG - The path of the TBB release version of , where may be tbb_debug, tbbmalloc_debug, tbbmalloc_proxy_debug, or tbb_preview_debug.

Output Variables

The following varibles should be used to link executables and libraries with TBB:

  • TBB_INCLUDE_DIRS - The include directory for TBB.
  • TBB_LIBRARIES - The libraries to link against to use TBB.
  • TBB_LIBRARIES_RELEASE - The release libraries to link against to use TBB.
  • TBB_LIBRARIES_DEBUG - The debug libraries to link against to use TBB.
  • TBB_DEFINITIONS - Definitions to use when compiling code that uses TBB.
  • TBB_DEFINITIONS_RELEASE - Definitions to use when compiling release code that uses TBB.
  • TBB_DEFINITIONS_DEBUG - Definitions to use when compiling debug code that uses TBB.
Comments
  • for cmake3 make tbb an imported target

    for cmake3 make tbb an imported target

    addresses an error when exporting a target that depends on tbb

    I described this error with more detail in #5. I am by no means a cmake expert, but I needed this change for my work, and I wanted to contribute back since I have found findTBB.cmake helpful.

    opened by pwm1234 7
  • TBB_LIBRARIES only contains debug libs

    TBB_LIBRARIES only contains debug libs

    Thanks for this great module to find TBB...

    TBB_LIBRARIES seems to only contain the debug libs?

    TBB FOUND: TRUE
    TBB VERSION: 4.4
    TBB LIBRARIES: E:/library/development/tbb/tbb44_20160526oss/lib/intel64/vc14/tbb_preview_debug.libE:/library/development/tbb/tbb44_20160526oss/lib/intel64/vc14/tbbmalloc_debug.libE:/library/development/tbb/tbb44_20160526oss/lib/intel64/vc14/tbb_debug.lib
    

    I haven't set to use TBB_USE_DEBUG_BUILD but CMake is configuring a Debug build option (along with Release) and that seems to trigger this conditional to never get to the release built components.

    # Set the library to be used for the component
    if(NOT TBB_${_comp}_LIBRARY)
       if(TBB_USE_DEBUG_BUILD AND TBB_${_comp}_LIBRARY_DEBUG)
         set(TBB_${_comp}_LIBRARY "${TBB_${_comp}_LIBRARY_DEBUG}")
       elseif(TBB_${_comp}_LIBRARY_RELEASE)
         set(TBB_${_comp}_LIBRARY "${TBB_${_comp}_LIBRARY_RELEASE}")
       elseif(TBB_${_comp}_LIBRARY_DEBUG)
         set(TBB_${_comp}_LIBRARY "${TBB_${_comp}_LIBRARY_DEBUG}")
       endif()
    endif()
    
    opened by caron 7
  • Import CMake target as an INTERFACE instead of a SHARED library

    Import CMake target as an INTERFACE instead of a SHARED library

    Under Windows, importing TBB as a CMake target with target_link_libraries(executable tbb) does not work (See also #8 ). The problem, if I understand it correctly, is that an imported shared target can refer to only one file, which poses a problem with IMPORTED_LOCATION when there are several dll files, as is the case for the debug version or when one has several components.

    With this PR, tbb is imported as an INTERFACE library instead, with all dependencies set correctly. This PR solves #8.

    opened by avaucher 4
  • Not finding TBB correctly on Ubuntu 16.04 LTS

    Not finding TBB correctly on Ubuntu 16.04 LTS

    After upgrading my Ubuntu 14 to 16.04 LTS, FindTBB started to output the following error. The libtbb-dev package is installed (apt-get was used for that). Also, I'm using an updated version of FindTBB.cmake.

    Could NOT find TBB (missing: TBB_LIBRARIES) (found version "4.4") Call Stack (most recent call first): /usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE) cmake/FindTBB.cmake:256 (find_package_handle_standard_args) CMakeLists.txt:11 (find_package)

    opened by dsilvavinicius 3
  • cmake error when installing/exporting target that uses tbb

    cmake error when installing/exporting target that uses tbb

    I just ran into a problem using the FindTBB tbb target. When I put tbb into the target link libraries of my project, I was getting a cmake error (well it was printed out as an error, but the cmake configure step seemed to generate everything) when calling install export. The error said that I was "exporting a target that had a dependency on the tbb target which was not also exported." I think this is because the tbb target is made with an add_library call for a real library rather than an imported library. I made a pull request with changes that made this error/warning go away.

    opened by pwm1234 1
  • Fix Windows library search

    Fix Windows library search

    As the TBB_LIB_PATH_SUFFIX is a semicolon seperated list on Windows, the double quotes have to be removed when expanding the variable. Else, the call to find_library will search for the single concatenated PATH_SUFFIXES and will not find anything at all. PS: For me it works on Windows with this change (see your issue #1).

    opened by BenjaminW3 1
  • can you  support oneTBB

    can you support oneTBB

    • it always complains that
      CMake Error at C:/Users/user/Documents/github/FindTBB-master/FindTBB.cmake:187 (file):
      file failed to open for reading (No such file or directory):
      
       C:/Users/user/Documents/github/oneapi-tbb-2021.1.1/include/tbb/tbb_stddef.h
      Call Stack (most recent call first):
      CMakeLists.txt:39 (find_package)
      
    • For https://github.com/oneapi-src/oneTBB There is no such header file
    opened by ychding11 0
  • Imported target totally ignores TBB_USE_DEBUG_BUILD

    Imported target totally ignores TBB_USE_DEBUG_BUILD

    When using TBB_LIBRARIES one could simply set TBB_USE_DEBUG_BUILD=off to prevent linking against TBB debug libraries no matter what CMake configuration is set. No luck if you want to use the imported target tbb.

    opened by emptyVoid 0
  • Could NOT find TBB (missing:  TBB_LIBRARIES tbbmalloc tbbmalloc_proxy tbb_preview) (found version

    Could NOT find TBB (missing: TBB_LIBRARIES tbbmalloc tbbmalloc_proxy tbb_preview) (found version "4.4")

    i got this while run

    `cmake_minimum_required(VERSION 2.8)
    project(MyProject)
    
    list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/")
    
    find_package(TBB COMPONENTS tbbmalloc tbbmalloc_proxy tbb_preview)
    
    add_executable(myapp myapp)
    target_include_directories(myapp PRIVATE ${TBB_INCLUDE_DIRS})
    target_compile_definitions(myapp PRIVATE ${TBB_DEFINITIONS})
    target_link_libraries(myapp ${TBB_LIBRARIES})`
    

    this killing my i searched all google no solution

    using ubuntu

    opened by medozeus 0
  • Updated to handle TBB installed from Brew

    Updated to handle TBB installed from Brew

    When TBB is installed by brew it goes to a different location than you specified, so I added it as a second option to the default search path.

    Signed-Off-By: James Till Matta

    opened by jmatta1 0
  • treatment of TBBROOT

    treatment of TBBROOT

    Hello,

    What is the expected layout of TBBROOT. Suppose I installed in

    /opt/tbb_install
        include/
        lib/
    

    then $TBBROOT=/opt/tbb_install is what should be used. Is this correct?

    I'm trying to debug this locally, but the brew installed TBB is always getting found over the custom one regardless of what TBBROOT actually is.

    opened by svenevs 2
Owner
Justus Calvin
Justus Calvin
CMake module for building IDL files with MIDL and generating CLR DLL using Tlbimp

FindIDL CMake module for building IDL files with MIDL and generating CLR DLL using Tlbimp. Introduction Requirements Usage find_package() add_idl() ad

Apriorit Inc. 17 Nov 6, 2022
CMake module for building Windows Installer packages with WiX toolset

FindWiX CMake module for building Windows Installer packages with WiX toolset Introduction Requirements Usage find_package() wix_add_project() WiX com

Apriorit Inc. 11 Aug 5, 2022
CMake module to enable code coverage easily and generate coverage reports with CMake targets.

CMake-codecov CMake module to enable code coverage easily and generate coverage reports with CMake targets. Include into your project To use Findcodec

HPC 82 Oct 25, 2022
unmaintained - CMake module to activate certain C++ standard, feature checks and appropriate automated workarounds - basically an improved version of cmake-compile-features

Compatibility This library provides an advanced target_compile_features() and write_compiler_detection_header(). The problem with those is that they a

Jonathan Müller 72 Apr 14, 2022
CMake scripts for building OpenSceneGraph third party libraries.

osg-3rdparty-cmake CMake scripts for building OpenSceneGraph third party libraries. These scripts can be used to build third party libraries from sour

Björn Blissing 156 Nov 18, 2022
A simple CMake utility for building and deploying Qt based applications on Android without QtCreator

Qt Android CMake utility What it is When using Qt for Android development, QMake & QtCreator is the only sane option for compiling and deploying. But

Laurent Gomila 227 Nov 18, 2022
A set of cmake modules to assist in building code

CMake 3 Tools Warning: These tools are being replaced by the Modern CMake. Some of the tools are still being maintained for now, but new projects shou

null 199 Nov 24, 2022
📦 CMake's missing package manager. A small CMake script for setup-free, cross-platform, reproducible dependency management.

Setup-free CMake dependency management CPM.cmake is a CMake script that adds dependency management capabilities to CMake. It's built as a thin wrapper

CPM.cmake 1.5k Nov 25, 2022
CMake checks cache helper modules – for fast CI CMake builds!

cmake-checks-cache Cross platform CMake projects do platform introspection by the means of "Check" macros. Have a look at CMake's How To Write Platfor

Cristian Adam 64 Nov 18, 2022
CMake scripts for painless usage of SuiteSparse+METIS from Visual Studio and the rest of Windows/Linux/OSX IDEs supported by CMake

CMake scripts for painless usage of Tim Davis' SuiteSparse (CHOLMOD,UMFPACK,AMD,LDL,SPQR,...) and METIS from Visual Studio and the rest of Windows/Lin

Jose Luis Blanco-Claraco 393 Nov 18, 2022
cmake-font-lock - Advanced, type aware, highlight support for CMake

cmake-font-lock - Advanced, type aware, highlight support for CMake

Anders Lindgren 39 Oct 2, 2022
cmake-avr - a cmake toolchain for AVR projects

cmake-avr - a cmake toolchain for AVR projects Testing the example provided The toolchain was created and tested within the following environment: Lin

Matthias Kleemann 162 Oct 24, 2022
Make CMake less painful when trying to write Modern Flexible CMake

Izzy's eXtension Modules IXM is a CMake library for writing Modern flexible CMake. This means: Reducing the amount of CMake written Selecting reasonab

IXM 107 Sep 1, 2022
curl cmake module libcurl build with msvc x86

curl-msvc Infomation curl cmake module libcurl build with MSVC10.0 arch (x86 | i386) source from https://github.com/curl/curl tags: curl-7_79_1 Usage

Jason Payne 0 May 16, 2022
CMake module for downloading an external project's source at configure time

DownloadProject Platform Build status Linux Mac OSX Windows (VS2015) This repository contains a generalized implementation for downloading an external

Crascit Pty Ltd 431 Nov 13, 2022
CMake module to speed up builds.

cotire Cotire (compile time reducer) is a CMake module that speeds up the build process of CMake based build systems by fully automating techniques as

Sascha Kratky 1.3k Nov 27, 2022
CMake module for Mathematica.

FindMathematica FindMathematica is a CMake module that tries to find a Wolfram Language installation and provides CMake functions for its C/C++ interf

Sascha Kratky 50 Jul 31, 2022
CMake project for BL602 RISC-V processor

bl602_cmake_base CMake project for BL602 RISC-V processor How to build NOTE : This project uses a pre-compiled version of the Buffalo SDK (bl_iot_sdk)

null 9 Jan 6, 2022
A CMake toolchain file for iOS, macOS, watchOS & tvOS C/C++/Obj-C++ development

A CMake toolchain file for iOS, macOS, watchOS & tvOS C/C++/Obj-C++ development

Alexander Widerberg 1.4k Nov 17, 2022