From: David Wells <drwells@email.unc.edu>
Date: Tue, 31 Dec 2019 22:00:15 +0000 (-0500)
Subject: Fix our TBB version check.
X-Git-Tag: v9.2.0-rc1~754^2
X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=80b13fe5a2eaefc77fa8c9266566fa8a2de91edf;p=dealii.git

Fix our TBB version check.

Since the regular expression we used was eager it matched the 202 in 2020,
yielding a version number of 0.0. Note that this worked with older versions of
TBB since we would get, e.g., version 8.0 instead of version 2018.0.
---

diff --git a/cmake/configure/configure_1_threads.cmake b/cmake/configure/configure_1_threads.cmake
index b039497a13..dea761738a 100644
--- a/cmake/configure/configure_1_threads.cmake
+++ b/cmake/configure/configure_1_threads.cmake
@@ -149,6 +149,18 @@ MACRO(FEATURE_THREADS_FIND_EXTERNAL var)
     SET(${var} TRUE)
   ENDIF()
 
+  #
+  # TBB currently uses the version numbering scheme
+  #
+  #     YYYY.X
+  #
+  # (e.g., 2018.0) where YYYY is the year of the release and X is the yearly
+  # release number. Older versions use
+  #
+  #     X.Y.Z
+  #
+  # (e.g., 4.2.1). Since we are compatible with all versions that use the new
+  # numbering scheme we only check for very old versions here.
   #
   # TBB versions before 4.2 are missing some explicit calls to std::atomic::load
   # in ternary expressions; these cause compilation errors in some compilers
diff --git a/cmake/modules/FindTBB.cmake b/cmake/modules/FindTBB.cmake
index 68001253b2..33c9b83d1d 100644
--- a/cmake/modules/FindTBB.cmake
+++ b/cmake/modules/FindTBB.cmake
@@ -65,12 +65,12 @@ DEAL_II_FIND_PATH(TBB_INCLUDE_DIR tbb/tbb_stddef.h
 IF(EXISTS ${TBB_INCLUDE_DIR}/tbb/tbb_stddef.h)
   FILE(STRINGS "${TBB_INCLUDE_DIR}/tbb/tbb_stddef.h" TBB_VERSION_MAJOR_STRING
     REGEX "#define.*TBB_VERSION_MAJOR")
-  STRING(REGEX REPLACE "^.*TBB_VERSION_MAJOR.*([0-9]+).*" "\\1"
+  STRING(REGEX REPLACE "^.*TBB_VERSION_MAJOR +([0-9]+).*" "\\1"
     TBB_VERSION_MAJOR "${TBB_VERSION_MAJOR_STRING}"
     )
   FILE(STRINGS "${TBB_INCLUDE_DIR}/tbb/tbb_stddef.h" TBB_VERSION_MINOR_STRING
     REGEX "#define.*TBB_VERSION_MINOR")
-  STRING(REGEX REPLACE "^.*TBB_VERSION_MINOR.*([0-9]+).*" "\\1"
+  STRING(REGEX REPLACE "^.*TBB_VERSION_MINOR +([0-9]+).*" "\\1"
     TBB_VERSION_MINOR "${TBB_VERSION_MINOR_STRING}"
     )
   SET(TBB_VERSION