From 6c10780716b0a3957050a0309a601f1fb8de1652 Mon Sep 17 00:00:00 2001
From: Timo Koch <timokoch@uio.no>
Date: Tue, 18 Mar 2025 09:59:49 +0100
Subject: [PATCH] [cmake] Only print TBB found msg when first found

The package is found with QUIET but when found a msg is printed.
However this message was always printed when find_package(TBB) is
called, even when it was already found before leading to multiple
duplicate outputs in the log.
---
 cmake/modules/FindTBB.cmake | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/cmake/modules/FindTBB.cmake b/cmake/modules/FindTBB.cmake
index 242f850ac..519ab249d 100644
--- a/cmake/modules/FindTBB.cmake
+++ b/cmake/modules/FindTBB.cmake
@@ -54,6 +54,11 @@ set_package_properties("TBB" PROPERTIES
   URL "https://github.com/oneapi-src/oneTBB"
 )
 
+# check if TBB was already found
+if(TBB_FOUND AND TARGET TBB::tbb)
+  return()
+endif()
+
 # first, try to find TBBs cmake configuration
 find_package(TBB ${TBB_FIND_VERSION} QUIET CONFIG)
 if(TBB_FOUND AND TARGET TBB::tbb)
-- 
GitLab