Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Jeremy Ong edited this pageMar 15, 2020 ·2 revisions

FindTBB Module

FindTBB is aCMake find package module forIntel® Thread Building Blocks (TBB).

Usage

Project Script

To use FindTBB in your CMake project, the first step is to setup your CMake project script.

  1. Put a copy of theFindTBB.cmake file to your project. The typically location iscmake/modules/FindTBB.cmake.

  2. Add the module directory to the CMake modules path to yourCMakeLists.txt file.

    list(APPENDCMAKE_MODULE_PATH${PROJECT_SOURCE_DIR}/cmake/modules/)
  3. Callfind_package in yourCMakeLists.txt file to find TBB header files and libraries. For example, a simple code might be,

    find_package(TBB)
  4. Build your executable or library with TBB, again in your ```CMakeLists.txt file,

    # Add include dirctory and compile definitions for all targetsinclude_directories(${TBB_INCLUDE_DIRS})add_definitions(${TBB_DEFINITIONS})# Create your executable targetadd_executable(my_exec my_exec.cc)# Link your target with TBB librariestarget_link_libraries(my_exec${TBB_LIBRARIES})

The complete, exampleCMakeLists.txt file is,

cmake_minimum_required (VERSION 2.8.8)project (MyProject)# Add the project modules directory to the CMake modules search path.list(APPENDCMAKE_MODULE_PATH${PROJECT_SOURCE_DIR}/cmake/modules/)# Find TBB libraries and header filesfind_package(TBB)# Add include dirctory and compile definitions for all targetsinclude_directories(${TBB_INCLUDE_DIRS})add_definitions(${TBB_DEFINITIONS})# Create your executable targetadd_executable(my_exec my_exec.cc)# Link your target with TBB librariestarget_link_libraries(my_exec${TBB_LIBRARIES})

Generating Project Files

When runningcmake for your project you may need to specify the location of the TBB install directory, include directory, and/or library direcory. For example, if you have installed TBB in the/path/to/tbb directory,

$ cmake -DTBB_ROOT_DIR=/path/to/tbb .

FindTBB can also use theTBB_INSTALL_DIR orTBBROOT environment variables to specify the install directory of TBB.

$ export TBBROOT=/path/to/tbb$ cmake .

If TBB does not use standard install paths (e.g. the open source version of TBB), you will need to specify the include and library directory.

$ cmake -DTBB_INCLUDE_DIR=/path/to/tbb/include -DTBB_LIBRARY=/path/to/tbb/lib .
Clone this wiki locally

[8]ページ先頭

©2009-2025 Movatter.jp