From d3272e51ebffc81ca37496a923c9de2918df95ca Mon Sep 17 00:00:00 2001 From: "H. Vetinari" Date: Mon, 1 Jul 2024 09:05:00 +1100 Subject: [PATCH] explicitly link to OpenMP --- CMakeLists.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index c6421cecc3..ddff73c2cd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,6 +102,10 @@ endif() message(WARNING "CMake support is experimental. It does not yet support all build options and may not produce the same Makefiles that OpenBLAS ships with.") +if (USE_OPENMP) + find_package(OpenMP REQUIRED) +endif () + include("${PROJECT_SOURCE_DIR}/cmake/utils.cmake") include("${PROJECT_SOURCE_DIR}/cmake/system.cmake") @@ -258,6 +262,15 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "AIX|Android|Linux|FreeBSD|OpenBSD|NetBSD|Drago endif() endif() +if (USE_OPENMP) + if(BUILD_STATIC_LIBS) + target_link_libraries(${OpenBLAS_LIBNAME}_static OpenMP::OpenMP_C) + endif() + if(BUILD_SHARED_LIBS) + target_link_libraries(${OpenBLAS_LIBNAME}_shared OpenMP::OpenMP_C) + endif() +endif() + # Seems that this hack doesn't required since macOS 11 Big Sur if (APPLE AND BUILD_SHARED_LIBS AND CMAKE_HOST_SYSTEM_VERSION VERSION_LESS 20) set (CMAKE_C_USE_RESPONSE_FILE_FOR_OBJECTS 1)