Skip to content

Commit 0292283

Browse files
authored
Merge pull request TESSEorg#332 from TESSEorg/331-missing-imported-target-openmpopenmp_c-when-rerunning-cmake
load OpenMP targets if present in `{BLAS,LAPACK}_LIBRARIES`
2 parents 7e28435 + ec4f812 commit 0292283

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@ endif()
198198
if (TARGET vrg-build-external-projects)
199199
add_dependencies(ttg-imported-packages-build vrg-build-external-projects)
200200
endif()
201+
# {PaRSEC,MADNESS} rely on usability of {BLAS,LAPACK}_LIBRARIES
202+
include(SanitizeLinalgLibraries)
203+
SanitizeLinalgLibraries()
201204
# PaRSEC
202205
include(FindOrFetchPARSEC)
203206
if (TARGET PaRSEC::parsec)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
3+
# {BLAS,LAPACK}_LIBRARIES may include IMPORTED targets such as OpenMP::OpenMP_C
4+
# these targets are usually exist when these variables are "discovered", but they may not if they are already in CACHE
5+
6+
include(CMakeFindDependencyMacro)
7+
include(CheckLanguage)
8+
9+
function(SanitizeLinalgLibraries)
10+
if (BLAS_LIBRARIES OR LAPACK_LIBRARIES)
11+
# look for OpenMP
12+
foreach (lang IN ITEMS C CXX Fortran)
13+
if (BLAS_LIBRARIES MATCHES OpenMP::OpenMP_${lang} OR LAPACK_LIBRARIES MATCHES OpenMP::OpenMP_${lang})
14+
check_language(${lang})
15+
if(CMAKE_${lang}_COMPILER)
16+
enable_language(${lang})
17+
find_dependency(OpenMP)
18+
else()
19+
message(FATAL_ERROR "No support for LANGUAGE ${lang} but {BLAS,LAPACK}_LIBRARIES contains IMPORTED target OpenMP::OpenMP_${lang} that requires it")
20+
endif()
21+
endif()
22+
endforeach()
23+
endif()
24+
endfunction()

0 commit comments

Comments
 (0)