From f49e24f1506a95ef46401e838094924f5083ab76 Mon Sep 17 00:00:00 2001 From: Ye Luo Date: Fri, 4 Sep 2026 14:58:36 -0500 Subject: [PATCH] FindBLAS: Select MKL threading layer based on the OpenMP runtime library Fixes: #28072 --- Modules/FindBLAS.cmake | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index ac8d5f2221..7e7867526d 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -507,11 +507,13 @@ if(BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") else() set(BLAS_mkl_INTFACE "intel") endif() - # Switch to GNU libgomp ABI regarding the OpenMP runtime (but not on Apple, where MKL does not provide it). - if(CMAKE_Fortran_COMPILER_LOADED AND (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" OR CMAKE_Fortran_COMPILER_ID STREQUAL "LCC") AND NOT APPLE) + # Switch to GNU libgomp ABI regarding the OpenMP runtime. + if(OpenMP_FOUND AND NOT OpenMP_iomp5_LIBRARY) + # Most OpenMP runtime libraries claim to support drop-in replacement of libgomp. set(BLAS_mkl_THREADING "gnu") set(BLAS_mkl_OMP "gomp") else() + # Safe to select Intel OpenMP runtime when compiler doesn't directly enable OpenMP or the runtime found was already iomp5. set(BLAS_mkl_THREADING "intel") set(BLAS_mkl_OMP "iomp5") endif()