From a625060a58ce20fc54f5441fbc8e2e95e90a7877 Mon Sep 17 00:00:00 2001 From: "k.koide" Date: Wed, 6 Nov 2024 11:51:57 +0900 Subject: [PATCH] make TBB optional --- CMakeLists.txt | 2 +- cmake/FindGTSAM.cmake | 25 +++++++++++++++++-------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9fb42a8b..8fabfbec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ endif() option(BUILD_TESTS "Build test" OFF) option(BUILD_DEMO "Build demo programs" OFF) option(BUILD_EXAMPLE "Build example programs" OFF) -option(BUILD_WITH_TBB "Build with TBB support" ON) +option(BUILD_WITH_TBB "Build with TBB support" OFF) option(BUILD_WITH_OPENMP "Build with OpenMP support" ON) option(BUILD_WITH_CUDA "Build with GPU support" OFF) option(BUILD_WITH_CUDA_MULTIARCH "Build with CUDA multi-architecture support" OFF) diff --git a/cmake/FindGTSAM.cmake b/cmake/FindGTSAM.cmake index 692ac5f1..4d868504 100644 --- a/cmake/FindGTSAM.cmake +++ b/cmake/FindGTSAM.cmake @@ -12,16 +12,25 @@ find_library(GTSAM_UNSTABLE_LIB NAMES gtsam_unstable HINTS /usr/local/lib /usr/lib DOC "GTSAM_UNSTABLE libraries") -find_library(TBB_LIB NAMES tbb - HINTS /usr/local/lib /usr/lib - DOC "TBB libraries") -find_library(TBB_MALLOC_LIB NAMES tbbmalloc - HINTS /usr/local/lib /usr/lib - DOC "TBB malloc libraries") +if(GTSAM_LIB AND GTSAM_UNSTABLE_LIB) + set(GTSAM_LIBRARIES ${GTSAM_LIB} ${GTSAM_UNSTABLE_LIB}) +endif() -if(GTSAM_LIB AND GTSAM_UNSTABLE_LIB AND TBB_LIB) - set(GTSAM_LIBRARIES ${GTSAM_LIB} ${GTSAM_UNSTABLE_LIB} ${TBB_LIB} ${TBB_MALLOC_LIB}) +if(GTSAM_POINTS_USE_TBB) + find_library(TBB_LIB NAMES tbb + HINTS /usr/local/lib /usr/lib + DOC "TBB libraries") + + find_library(TBB_MALLOC_LIB NAMES tbbmalloc + HINTS /usr/local/lib /usr/lib + DOC "TBB malloc libraries") + + if(TBB_LIB AND TBB_MALLOC_LIB) + set(GTSAM_LIBRARIES ${GTSAM_LIBRARIES} ${TBB_LIB} ${TBB_MALLOC_LIB}) + else() + message(FATAL_ERROR "TBB libraries not found") + endif() endif() add_library(GTSAM::GTSAM INTERFACE IMPORTED GLOBAL)