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 11, 2024
1 parent 8d2717c commit 2bcf40f
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions cmake/templates/oneDPLConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -117,23 +117,26 @@ 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)
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")
Expand Down

0 comments on commit 2bcf40f

Please sign in to comment.