diff --git a/cmake/templates/oneDPLConfig.cmake.in b/cmake/templates/oneDPLConfig.cmake.in index 29c3c3ea9c2..1dabf7add8c 100644 --- a/cmake/templates/oneDPLConfig.cmake.in +++ b/cmake/templates/oneDPLConfig.cmake.in @@ -117,26 +117,29 @@ 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) - endif() + 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) + 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) + if (_fsycl_option AND NOT CMAKE_CXX_COMPILER MATCHES ".*(dpcpp-cl|dpcpp)(.exe)?$") + message(STATUS "Adding ${FSYCL_OPTION} compiler option") + target_compile_options(oneDPL INTERFACE ${FSYCL_OPTION}) + target_link_libraries(oneDPL INTERFACE ${FSYCL_OPTION}) endif() else() - message(STATUS "oneDPL: -fsycl compiler option is not supported or sycl.hpp is not available, set ONEDPL_USE_DPCPP_BACKEND=0") + message(STATUS "oneDPL: SYCL is not supported. Set ONEDPL_USE_DPCPP_BACKEND=0") set_property(TARGET oneDPL APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS ONEDPL_USE_DPCPP_BACKEND=0) endif() endif()