From 220ae5a5d20ffab371091cbe39e7d435f2c34823 Mon Sep 17 00:00:00 2001
From: Guilherme Amadio <amadio@cern.ch>
Date: Mon, 7 May 2018 10:43:07 +0200
Subject: [PATCH] Revert "Disable imt option rather than enabling builtin_tbb
 by default"

This partially reverts commit aad5a3bb7ab8ea3df1dc27205c3cae26aacf631b.
---
 cmake/modules/SearchInstalledSoftware.cmake | 29 ++++++++++++++-------
 1 file changed, 20 insertions(+), 9 deletions(-)

diff --git a/cmake/modules/SearchInstalledSoftware.cmake b/cmake/modules/SearchInstalledSoftware.cmake
index dc08a056755..7658d704d9b 100644
--- a/cmake/modules/SearchInstalledSoftware.cmake
+++ b/cmake/modules/SearchInstalledSoftware.cmake
@@ -1138,19 +1138,30 @@ if (jemalloc)
 endif()
 
 #---Check for TBB---------------------------------------------------------------------
-if(imt AND NOT builtin_tbb)
-  message(STATUS "Looking for TBB")
-  if(fail-on-missing)
-    find_package(TBB 4.3 REQUIRED)
-  else()
-    find_package(TBB 4.3)
+if(imt)
+  if(NOT builtin_tbb)
+    message(STATUS "Looking for TBB")
+    find_package(TBB)
+    if(TBB_FOUND)
+      if(${TBB_VERSION} VERSION_LESS 4.3)
+        if(fail-on-missing)
+          message(FATAL_ERROR "TBB version < 4.3. You can enable the option 'builtin_tbb' to build the library internally")
+        else()
+          message(STATUS "TBB version < 4.3. Switching on builtin_tbb option")
+          set(builtin_tbb ON CACHE BOOL "" FORCE)
+        endif()
+      endif()
+    endif()  
     if(NOT TBB_FOUND)
-      message(STATUS "TBB not found. Switching of imt option")
-      set(imt OFF CACHE BOOL "" FORCE)
+      if(fail-on-missing)
+        message(FATAL_ERROR "TBB not found. You can enable the option 'builtin_tbb' to build the library internally")
+      else()
+        message(STATUS "TBB not found. Switching on builtin_tbb option")
+        set(builtin_tbb ON CACHE BOOL "" FORCE)
+      endif()
     endif()
   endif()
 endif()  
-
 if(builtin_tbb)
   set(tbb_version 2017_U5)
   if(CMAKE_CXX_COMPILER_ID MATCHES Clang)
-- 
GitLab