diff --git a/cmake/templates/oneDPLConfig.cmake.in b/cmake/templates/oneDPLConfig.cmake.in index 29c3c3ea9c2..58822fde644 100644 --- a/cmake/templates/oneDPLConfig.cmake.in +++ b/cmake/templates/oneDPLConfig.cmake.in @@ -117,23 +117,36 @@ if (EXISTS "${_onedpl_headers}") endif() # Check SYCL support by the compiler - check_cxx_compiler_flag("-fsycl" _fsycl_option) + set(FSYCL_OPTION "-fsycl") + check_cxx_compiler_flag(${FSYCL_OPTION} _fsycl_option) if (_fsycl_option) - CHECK_INCLUDE_FILE_CXX("sycl/sycl.hpp" _sycl_header "-fsycl") - if (NOT _sycl_header) - CHECK_INCLUDE_FILE_CXX("CL/sycl.hpp" _sycl_header_old "-fsycl") - endif() - if (_sycl_header OR _sycl_header_old) - set(_sycl_support TRUE) + set(FSYCL_OPTION_IF_SUPPORTED ${FSYCL_OPTION}) + endif() + + CHECK_INCLUDE_FILE_CXX("sycl/sycl.hpp" SYCL_HEADER ${FSYCL_OPTION_IF_SUPPORTED}) + if (NOT SYCL_HEADER) + CHECK_INCLUDE_FILE_CXX("CL/sycl.hpp" SYCL_HEADER_OLD ${FSYCL_OPTION_IF_SUPPORTED}) + endif() + if (SYCL_HEADER OR SYCL_HEADER_OLD) + set(SYCL_SUPPORT TRUE) + endif() + + if (SYCL_SUPPORT) + message(STATUS "SYCL is supported") + else() + if (ONEDPL_BACKEND MATCHES "^(dpcpp|dpcpp_only)$") + message(FATAL_ERROR "SYCL is not supported. It is required for ONEDPL_BACKEND=${ONEDPL_BACKEND}") + else() + message(STATUS "SYCL is not supported") endif() endif() - if (_sycl_support) + if (SYCL_SUPPORT) # Enable SYCL* with compilers/compiler drivers not passing -fsycl by default if (NOT CMAKE_CXX_COMPILER MATCHES ".*(dpcpp-cl|dpcpp)(.exe)?$") message(STATUS "Adding -fsycl compiler option") - target_compile_options(oneDPL INTERFACE -fsycl) - target_link_libraries(oneDPL INTERFACE -fsycl) + target_compile_options(oneDPL INTERFACE ${FSYCL_OPTION_IF_SUPPORTED}) + target_link_libraries(oneDPL INTERFACE ${FSYCL_OPTION_IF_SUPPORTED}) endif() else() message(STATUS "oneDPL: -fsycl compiler option is not supported or sycl.hpp is not available, set ONEDPL_USE_DPCPP_BACKEND=0")