From 25737d064e7649f5177c48c60086042983012bd0 Mon Sep 17 00:00:00 2001
From: Florent Pruvost <florent.pruvost@inria.fr>
Date: Fri, 5 May 2023 10:31:54 +0200
Subject: [PATCH] Threads target may be required and thus exported

---
 CMakeLists.txt                         | 6 ++++++
 cmake_modules/CHAMELEONConfig.cmake.in | 3 +++
 2 files changed, 9 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3e2dbdeef..32134886d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -778,6 +778,12 @@ endif()
 # Export targets #
 ##################
 
+# Threads::Threads may be a dependency of BLAS/LAPACK and CUDA
+# the target may be required for cmake users linking with CHAMELEONconfig.cmake
+if (TARGET Threads::Threads)
+    morse_export_imported_target(Threads Threads threads chameleon)
+endif()
+
 # see https://cmake.org/cmake/help/latest/module/CMakePackageConfigHelpers.html
 include(CMakePackageConfigHelpers)
 
diff --git a/cmake_modules/CHAMELEONConfig.cmake.in b/cmake_modules/CHAMELEONConfig.cmake.in
index 9bc029786..744cdd723 100644
--- a/cmake_modules/CHAMELEONConfig.cmake.in
+++ b/cmake_modules/CHAMELEONConfig.cmake.in
@@ -11,6 +11,9 @@ check_required_components(CHAMELEON)
 
 # dependencies of CHAMELEON
 include("${CMAKE_CURRENT_LIST_DIR}/mTargets.cmake")
+if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/threadsTargets.cmake")
+  include("${CMAKE_CURRENT_LIST_DIR}/threadsTargets.cmake")
+endif()
 if (NOT @CHAMELEON_SIMULATION@)
   include("${CMAKE_CURRENT_LIST_DIR}/cblasTargets.cmake")
   include("${CMAKE_CURRENT_LIST_DIR}/lapackeTargets.cmake")
-- 
GitLab