Skip to content

Commit

Permalink
Add CMake SYCL changes to oneDPLConfig.cmake.in
Browse files Browse the repository at this point in the history
This was copied over directly from CMakeLists.txt and is required
for AdaptiveCPP to be recognized as a SYCL compiler.
  • Loading branch information
carbotaniuman committed Dec 12, 2024
1 parent 8d2717c commit da711c1
Showing 1 changed file with 17 additions and 14 deletions.
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

0 comments on commit da711c1

Please sign in to comment.