Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CMake SYCL changes to oneDPLConfig.cmake.in #1964

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions cmake/templates/oneDPLConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading