From 10ce4c862a0c0bf96b134d6e92751c38530bbdec Mon Sep 17 00:00:00 2001 From: loqs Date: Wed, 26 May 2021 04:18:21 +0100 Subject: [PATCH] Fix FindTBB version detection with TBB >= 2021.1.1 Copied from https://github.com/ceres-solver/ceres-solver/commit/941ea13475913ef8322584f7401633de9967ccc8 --- cmake/modules/FindTBB.cmake | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/cmake/modules/FindTBB.cmake b/cmake/modules/FindTBB.cmake index 424c2039ec..14667b928d 100644 --- a/cmake/modules/FindTBB.cmake +++ b/cmake/modules/FindTBB.cmake @@ -455,10 +455,23 @@ findpkg_finish(TBB_MALLOC_PROXY tbbmalloc_proxy) #============================================================================= #parse all the version numbers from tbb if(NOT TBB_VERSION) + set(TBB_VERSION_FILE_PRIOR_TO_TBB_2021_1 + "${TBB_INCLUDE_DIR}/tbb/tbb_stddef.h") + set(TBB_VERSION_FILE_AFTER_TBB_2021_1 + "${TBB_INCLUDE_DIR}/oneapi/tbb/version.h") + + if (EXISTS "${TBB_VERSION_FILE_PRIOR_TO_TBB_2021_1}") + set(TBB_VERSION_FILE "${TBB_VERSION_FILE_PRIOR_TO_TBB_2021_1}") + elseif (EXISTS "${TBB_VERSION_FILE_AFTER_TBB_2021_1}") + set(TBB_VERSION_FILE "${TBB_VERSION_FILE_AFTER_TBB_2021_1}") + else() + message(FATAL_ERROR "Found TBB installation: ${TBB_INCLUDE_DIR} " + "missing version header.") + endif() #only read the start of the file file(STRINGS - "${TBB_INCLUDE_DIR}/tbb/tbb_stddef.h" + "${TBB_VERSION_FILE}" TBB_VERSION_CONTENTS REGEX "VERSION")