mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-06-04 18:54:00 +08:00
Fix TriSycl CMake files.
This is to enable compiling with the latest trisycl. `FindTriSYCL.cmake` was broken by commit 00f32752, which modified `add_sycl_to_target` for ComputeCPP. This makes the corresponding modifications for trisycl to make them consistent. Also, trisycl now requires c++17.
This commit is contained in:
parent
3d98a6ef5c
commit
8cf6cb27ba
@ -57,12 +57,12 @@ mark_as_advanced(TRISYCL_DEBUG_STRUCTORS)
|
|||||||
mark_as_advanced(TRISYCL_TRACE_KERNEL)
|
mark_as_advanced(TRISYCL_TRACE_KERNEL)
|
||||||
|
|
||||||
#triSYCL definitions
|
#triSYCL definitions
|
||||||
set(CL_SYCL_LANGUAGE_VERSION 220 CACHE VERSION
|
set(CL_SYCL_LANGUAGE_VERSION 220 CACHE STRING
|
||||||
"Host language version to be used by trisYCL (default is: 220)")
|
"Host language version to be used by trisYCL (default is: 220)")
|
||||||
set(TRISYCL_CL_LANGUAGE_VERSION 220 CACHE VERSION
|
set(TRISYCL_CL_LANGUAGE_VERSION 220 CACHE STRING
|
||||||
"Device language version to be used by trisYCL (default is: 220)")
|
"Device language version to be used by trisYCL (default is: 220)")
|
||||||
#set(TRISYCL_COMPILE_OPTIONS "-std=c++1z -Wall -Wextra")
|
# triSYCL now requires c++17
|
||||||
set(CMAKE_CXX_STANDARD 14)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CXX_STANDARD_REQUIRED ON)
|
set(CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
|
|
||||||
@ -93,6 +93,20 @@ endif()
|
|||||||
find_package(Threads REQUIRED)
|
find_package(Threads REQUIRED)
|
||||||
|
|
||||||
# Find triSYCL directory
|
# Find triSYCL directory
|
||||||
|
if (TRISYCL_INCLUDES AND TRISYCL_LIBRARIES)
|
||||||
|
set(TRISYCL_FIND_QUIETLY TRUE)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
find_path(TRISYCL_INCLUDE_DIR
|
||||||
|
NAMES sycl.hpp
|
||||||
|
PATHS $ENV{TRISYCLDIR} $ENV{TRISYCLDIR}/include ${INCLUDE_INSTALL_DIR}
|
||||||
|
PATH_SUFFIXES triSYCL
|
||||||
|
)
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(TriSYCL DEFAULT_MSG
|
||||||
|
TRISYCL_INCLUDE_DIR)
|
||||||
|
|
||||||
if(NOT TRISYCL_INCLUDE_DIR)
|
if(NOT TRISYCL_INCLUDE_DIR)
|
||||||
message(FATAL_ERROR
|
message(FATAL_ERROR
|
||||||
"triSYCL include directory - Not found! (please set TRISYCL_INCLUDE_DIR")
|
"triSYCL include directory - Not found! (please set TRISYCL_INCLUDE_DIR")
|
||||||
@ -100,36 +114,42 @@ else()
|
|||||||
message(STATUS "triSYCL include directory - Found ${TRISYCL_INCLUDE_DIR}")
|
message(STATUS "triSYCL include directory - Found ${TRISYCL_INCLUDE_DIR}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
include(CMakeParseArguments)
|
||||||
#######################
|
#######################
|
||||||
# add_sycl_to_target
|
# add_sycl_to_target
|
||||||
#######################
|
#######################
|
||||||
#
|
function(add_sycl_to_target)
|
||||||
# Sets the proper flags and includes for the target compilation.
|
set(options)
|
||||||
#
|
set(one_value_args
|
||||||
# targetName : Name of the target to add a SYCL to.
|
TARGET
|
||||||
# sourceFile : Source file to be compiled for SYCL.
|
)
|
||||||
# binaryDir : Intermediate directory to output the integration header.
|
set(multi_value_args
|
||||||
#
|
SOURCES
|
||||||
function(add_sycl_to_target targetName sourceFile binaryDir)
|
)
|
||||||
|
cmake_parse_arguments(ADD_SYCL_ARGS
|
||||||
|
"${options}"
|
||||||
|
"${one_value_args}"
|
||||||
|
"${multi_value_args}"
|
||||||
|
${ARGN}
|
||||||
|
)
|
||||||
|
|
||||||
# Add include directories to the "#include <>" paths
|
# Add include directories to the "#include <>" paths
|
||||||
target_include_directories (${targetName} PUBLIC
|
target_include_directories (${ADD_SYCL_ARGS_TARGET} PUBLIC
|
||||||
${TRISYCL_INCLUDE_DIR}
|
${TRISYCL_INCLUDE_DIR}
|
||||||
${Boost_INCLUDE_DIRS}
|
${Boost_INCLUDE_DIRS}
|
||||||
$<$<BOOL:${TRISYCL_OPENCL}>:${OpenCL_INCLUDE_DIRS}>
|
$<$<BOOL:${TRISYCL_OPENCL}>:${OpenCL_INCLUDE_DIRS}>
|
||||||
$<$<BOOL:${TRISYCL_OPENCL}>:${BOOST_COMPUTE_INCPATH}>)
|
$<$<BOOL:${TRISYCL_OPENCL}>:${BOOST_COMPUTE_INCPATH}>)
|
||||||
|
|
||||||
|
|
||||||
# Link dependencies
|
# Link dependencies
|
||||||
target_link_libraries(${targetName} PUBLIC
|
target_link_libraries(${ADD_SYCL_ARGS_TARGET}
|
||||||
$<$<BOOL:${TRISYCL_OPENCL}>:${OpenCL_LIBRARIES}>
|
$<$<BOOL:${TRISYCL_OPENCL}>:${OpenCL_LIBRARIES}>
|
||||||
Threads::Threads
|
Threads::Threads
|
||||||
$<$<BOOL:${LOG_NEEDED}>:Boost::log>
|
$<$<BOOL:${LOG_NEEDED}>:Boost::log>
|
||||||
Boost::chrono)
|
Boost::chrono)
|
||||||
|
|
||||||
|
|
||||||
# Compile definitions
|
# Compile definitions
|
||||||
target_compile_definitions(${targetName} PUBLIC
|
target_compile_definitions(${ADD_SYCL_ARGS_TARGET} PUBLIC
|
||||||
|
EIGEN_SYCL_TRISYCL
|
||||||
$<$<BOOL:${TRISYCL_NO_ASYNC}>:TRISYCL_NO_ASYNC>
|
$<$<BOOL:${TRISYCL_NO_ASYNC}>:TRISYCL_NO_ASYNC>
|
||||||
$<$<BOOL:${TRISYCL_OPENCL}>:TRISYCL_OPENCL>
|
$<$<BOOL:${TRISYCL_OPENCL}>:TRISYCL_OPENCL>
|
||||||
$<$<BOOL:${TRISYCL_DEBUG}>:TRISYCL_DEBUG>
|
$<$<BOOL:${TRISYCL_DEBUG}>:TRISYCL_DEBUG>
|
||||||
@ -138,13 +158,13 @@ function(add_sycl_to_target targetName sourceFile binaryDir)
|
|||||||
$<$<BOOL:${LOG_NEEDED}>:BOOST_LOG_DYN_LINK>)
|
$<$<BOOL:${LOG_NEEDED}>:BOOST_LOG_DYN_LINK>)
|
||||||
|
|
||||||
# C++ and OpenMP requirements
|
# C++ and OpenMP requirements
|
||||||
target_compile_options(${targetName} PUBLIC
|
target_compile_options(${ADD_SYCL_ARGS_TARGET} PUBLIC
|
||||||
${TRISYCL_COMPILE_OPTIONS}
|
${TRISYCL_COMPILE_OPTIONS}
|
||||||
$<$<BOOL:${TRISYCL_OPENMP}>:${OpenMP_CXX_FLAGS}>)
|
$<$<BOOL:${TRISYCL_OPENMP}>:${OpenMP_CXX_FLAGS}>)
|
||||||
|
|
||||||
if(${TRISYCL_OPENMP} AND (NOT WIN32))
|
if(${TRISYCL_OPENMP} AND (NOT WIN32))
|
||||||
# Does not support generator expressions
|
# Does not support generator expressions
|
||||||
set_target_properties(${targetName}
|
set_target_properties(${ADD_SYCL_ARGS_TARGET}
|
||||||
PROPERTIES
|
PROPERTIES
|
||||||
LINK_FLAGS ${OpenMP_CXX_FLAGS})
|
LINK_FLAGS ${OpenMP_CXX_FLAGS})
|
||||||
endif()
|
endif()
|
||||||
|
@ -3,8 +3,7 @@ FILE(GLOB examples_SRCS "*.cpp")
|
|||||||
set(EIGEN_SYCL ON)
|
set(EIGEN_SYCL ON)
|
||||||
list(APPEND CMAKE_EXE_LINKER_FLAGS -pthread)
|
list(APPEND CMAKE_EXE_LINKER_FLAGS -pthread)
|
||||||
if(EIGEN_SYCL_TRISYCL)
|
if(EIGEN_SYCL_TRISYCL)
|
||||||
set(CMAKE_CXX_STANDARD 14)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(STD_CXX_FLAG "-std=c++1z")
|
|
||||||
else(EIGEN_SYCL_TRISYCL)
|
else(EIGEN_SYCL_TRISYCL)
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
# Set the host and device compilers C++ standard to C++14. On Windows setting this to C++11
|
# Set the host and device compilers C++ standard to C++14. On Windows setting this to C++11
|
||||||
|
@ -165,8 +165,8 @@ if(EIGEN_TEST_CXX11)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(EIGEN_SYCL_TRISYCL)
|
if(EIGEN_SYCL_TRISYCL)
|
||||||
set(CMAKE_CXX_STANDARD 14)
|
# triSYCL now requires c++17.
|
||||||
set(STD_CXX_FLAG "-std=c++1z")
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
else()
|
else()
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
# Set the host and device compilers C++ standard to C++14. On Windows setting this to C++11
|
# Set the host and device compilers C++ standard to C++14. On Windows setting this to C++11
|
||||||
|
Loading…
x
Reference in New Issue
Block a user