diff --git a/CMakeLists.txt b/CMakeLists.txt index 400528c73..6f8b24573 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -324,6 +324,7 @@ option(NO_PTEX "Disable Ptex example viewers" OFF) option(NO_DOC "Disable documentation build" OFF) option(NO_OMP "Disable OpenMP backend" OFF) option(NO_TBB "Disable TBB backend" OFF) +option(REQUIRE_TBB "Make TBB mandatory" OFF) option(NO_CUDA "Disable CUDA backend" OFF) option(NO_OPENCL "Disable OpenCL backend" OFF) option(NO_CLEW "Disable CLEW wrapper library" OFF) @@ -366,7 +367,16 @@ if(NOT NO_OMP) find_package(OpenMP) endif() if(NOT NO_TBB) - find_package(TBB 2018 COMPONENTS tbb) + # Prefer the TBB CMake config if available + find_package(TBB COMPONENTS tbb CONFIG) + if (NOT TBB_FOUND) + # Fallback to FindTBB.cmake + if (REQUIRE_TBB) + find_package(TBB 2018 COMPONENTS tbb REQUIRED) + else() + find_package(TBB 2018 COMPONENTS tbb) + endif() + endif() endif() if (NOT NO_OPENGL) find_package(OpenGL)