FindBLAS: Fix detection of OpenMP as dependency of BLA_STATIC
Update the change from commit f7f3d8987a
(FindBLAS: Add dependency of
OpenBLAS on OpenMP for BLA_STATIC, 2020-11-10, v3.20.0-rc1~492^2):
* If C is not enabled, find CXX OpenMP libraries instead.
* Do not use BLA_STATIC's custom CMAKE_FIND_LIBRARY_SUFFIXES for OpenMP.
It can break projects that already call `find_package(OpenMP)` and
expect a shared library. Whether OpenMP is static is orthogonal to
whether BLAS is static.
Fixes: #22039
Issue: #16221
This commit is contained in:
parent
f8af94a212
commit
9ef82d95d8
@ -619,8 +619,17 @@ if(BLA_VENDOR STREQUAL "OpenBLAS" OR BLA_VENDOR STREQUAL "All")
|
||||
endif()
|
||||
set(_threadlibs "${CMAKE_THREAD_LIBS_INIT}")
|
||||
if(BLA_STATIC)
|
||||
find_package(OpenMP COMPONENTS C)
|
||||
list(PREPEND _threadlibs "${OpenMP_C_LIBRARIES}")
|
||||
set(_blas_STATIC_CMAKE_FIND_LIBRARY_SUFFIXES "${CMAKE_FIND_LIBRARY_SUFFIXES}")
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES "${_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}")
|
||||
if (CMAKE_C_COMPILER_LOADED)
|
||||
find_package(OpenMP COMPONENTS C)
|
||||
list(PREPEND _threadlibs "${OpenMP_C_LIBRARIES}")
|
||||
elseif(CMAKE_CXX_COMPILER_LOADED)
|
||||
find_package(OpenMP COMPONENTS CXX)
|
||||
list(PREPEND _threadlibs "${OpenMP_CXX_LIBRARIES}")
|
||||
endif()
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES "${_blas_STATIC_CMAKE_FIND_LIBRARY_SUFFIXES}")
|
||||
unset(_blas_STATIC_CMAKE_FIND_LIBRARY_SUFFIXES)
|
||||
endif()
|
||||
check_blas_libraries(
|
||||
BLAS_LIBRARIES
|
||||
|
Loading…
Reference in New Issue
Block a user