[SYCL] Fix detection of CL/sycl.hpp for C++14 versions
This commit is contained in:
parent
7cd14f480d
commit
3ebad06bd4
@ -7,6 +7,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
project(gpu-stream)
|
||||
|
||||
include(CheckIncludeFileCXX)
|
||||
include(CheckCXXCompilerFlag)
|
||||
|
||||
set(gpu-stream_VERSION_MAJOR 2)
|
||||
set(gpu-stream_VERSION_MINOR 0)
|
||||
@ -110,22 +111,31 @@ endif ()
|
||||
#-------------------------------------------------------------------------------
|
||||
# SYCL
|
||||
#-------------------------------------------------------------------------------
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" OR
|
||||
"${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
|
||||
# Use C++14 if available, otherwise drop back to C++11
|
||||
check_cxx_compiler_flag("-std=c++14" CXX14)
|
||||
if (CXX14)
|
||||
set(CMAKE_REQUIRED_FLAGS "-std=c++14")
|
||||
else()
|
||||
set(CMAKE_REQUIRED_FLAGS "-std=c++11")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
check_include_file_cxx("CL/sycl.hpp" HAS_SYCL)
|
||||
if (HAS_SYCL)
|
||||
add_executable(gpu-stream-sycl main.cpp SYCLStream.cpp)
|
||||
target_compile_definitions(gpu-stream-sycl PUBLIC SYCL)
|
||||
|
||||
find_program(COMPUTECPP "compute++")
|
||||
if (COMPUTECPP)
|
||||
message(STATUS "Using ComputeCpp for SYCL compilation")
|
||||
add_custom_target(SYCLStream.sycl COMMAND ${COMPUTECPP} ${CMAKE_CURRENT_SOURCE_DIR}/SYCLStream.cpp -sycl -no-serial-memop -O2 -emit-llvm -c)
|
||||
add_executable(gpu-stream-sycl main.cpp SYCLStream.cpp)
|
||||
add_dependencies(gpu-stream-sycl SYCLStream.sycl)
|
||||
target_compile_definitions(gpu-stream-sycl PUBLIC SYCL)
|
||||
target_compile_options(gpu-stream-sycl PUBLIC -include SYCLStream.sycl)
|
||||
target_link_libraries(gpu-stream-sycl SYCL OpenCL)
|
||||
else()
|
||||
message(STATUS "Using header-only SYCL implementation")
|
||||
add_executable(gpu-stream-sycl main.cpp SYCLStream.cpp)
|
||||
target_compile_definitions(gpu-stream-sycl PUBLIC SYCL)
|
||||
set_property(TARGET gpu-stream-sycl PROPERTY CXX_STANDARD 14)
|
||||
endif(COMPUTECPP)
|
||||
else ()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user