diff --git a/CMakeLists.txt b/CMakeLists.txt index a3d9c129d90..259054b6e4a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -288,7 +288,20 @@ elseif(ONEDPL_BACKEND MATCHES "^(omp)$") find_package(OpenMP) if (OpenMP_CXX_FOUND) message(STATUS "Compilation for the host due to OpenMP backend.") - target_link_libraries(oneDPL INTERFACE OpenMP::OpenMP_CXX) + # Due to minor correctness issues with -fiopenmp / -Qiopenmp, we are using -fopenmp / -Qopenmp until they are corrected. + # Once correctness issues are resolved, we will limit this workaround to affected versions of specific compilers. + if (OpenMP_CXX_FLAGS MATCHES ".*-fiopenmp.*") + set(_openmp_flag -fopenmp) + elseif (OpenMP_CXX_FLAGS MATCHES ".*[-/]Qiopenmp.*") + set(_openmp_flag /Qopenmp) + endif() + if (_openmp_flag) + message(STATUS "Using ${_openmp_flag} for openMP") + target_compile_options(oneDPL INTERFACE ${_openmp_flag}) + target_link_libraries(oneDPL INTERFACE ${_openmp_flag}) + else() + target_link_libraries(oneDPL INTERFACE OpenMP::OpenMP_CXX) + endif() target_compile_definitions(oneDPL INTERFACE ONEDPL_USE_TBB_BACKEND=0 ONEDPL_USE_DPCPP_BACKEND=0 diff --git a/cmake/templates/oneDPLConfig.cmake.in b/cmake/templates/oneDPLConfig.cmake.in index f4ea36679b1..d83b4cae8f2 100644 --- a/cmake/templates/oneDPLConfig.cmake.in +++ b/cmake/templates/oneDPLConfig.cmake.in @@ -82,7 +82,20 @@ if (EXISTS "${_onedpl_headers}") elseif (OpenMP_CXX_FOUND) set(ONEDPL_PAR_BACKEND openmp) message(STATUS "oneDPL: ONEDPL_PAR_BACKEND=${ONEDPL_PAR_BACKEND}, disable oneTBB backend") - set_target_properties(oneDPL PROPERTIES INTERFACE_LINK_LIBRARIES OpenMP::OpenMP_CXX) + # Due to minor correctness issues with -fiopenmp / -Qiopenmp, we are using -fopenmp / -Qopenmp until they are corrected. + # Once correctness issues are resolved, we will limit this workaround to affected versions of specific compilers. + if (OpenMP_CXX_FLAGS MATCHES ".*-fiopenmp.*") + set(_openmp_flag -fopenmp) + elseif (OpenMP_CXX_FLAGS MATCHES ".*[-/]Qiopenmp.*") + set(_openmp_flag /Qopenmp) + endif() + if (_openmp_flag) + message(STATUS "oneDPL: Using ${_openmp_flag} for openMP") + set_target_properties(oneDPL PROPERTIES INTERFACE_COMPILE_OPTIONS ${_openmp_flag}) + set_target_properties(oneDPL PROPERTIES INTERFACE_LINK_LIBRARIES ${_openmp_flag}) + else() + set_target_properties(oneDPL PROPERTIES INTERFACE_LINK_LIBRARIES OpenMP::OpenMP_CXX) + endif() set_property(TARGET oneDPL APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS ONEDPL_USE_TBB_BACKEND=0 ONEDPL_USE_OPENMP_BACKEND=1) endif() endif()