forked from codeplaysoftware/syclacademy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
94 lines (73 loc) · 3.04 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#[[
SYCL Academy (c)
SYCL Academy is licensed under a Creative Commons Attribution-ShareAlike 4.0
International License.
You should have received a copy of the license along with this work. If not,
see <http://creativecommons.org/licenses/by-sa/4.0/>.
Invoking CMake from the command line example usage:
cmake .. "-GUnix Makefiles" -DSYCL_ACADEMY_USE_DPCPP=ON
-DSYCL_ACADEMY_ENABLE_SOLUTIONS=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx
]]
# Minimum version required by
# /opt/intel/oneapi/compiler/latest/linux/IntelSYCL/ReadNeSYCL.txt
if(WIN32)
cmake_minimum_required(VERSION 3.23...3.27)
else()
cmake_minimum_required(VERSION 3.20...3.27)
endif()
project (SYCLAcademy)
# CMake input options
option(SYCL_ACADEMY_USE_DPCPP "Configure to compile with Intel DPC++" OFF)
option(SYCL_ACADEMY_USE_ADAPTIVECPP "Configure to compile with AdaptiveCpp" OFF)
option(SYCL_ACADEMY_ENABLE_SOLUTIONS "Include solution source files in the project" OFF)
# Variables
set(SYCL_ACADEMY_INSTALL_ROOT CACHE STRING "NOT-FOUND")
set(SYCL_IMPLEMENTATIONS_USED 0)
if(SYCL_ACADEMY_USE_DPCPP)
math(EXPR SYCL_IMPLEMENTATIONS_USED ${SYCL_IMPLEMENTATIONS_USED}+1)
endif()
if(SYCL_ACADEMY_USE_ADAPTIVECPP)
math(EXPR SYCL_IMPLEMENTATIONS_USED ${SYCL_IMPLEMENTATIONS_USED}+1)
endif()
if (${SYCL_IMPLEMENTATIONS_USED} EQUAL 0)
message(FATAL_ERROR "No SYCL implementation specified, please set one of the following "
"SYCL_ACADEMY_USE_ADAPTIVECPP or SYCL_ACADEMY_USE_DPCPP to ON.")
endif()
if (${SYCL_IMPLEMENTATIONS_USED} GREATER 1)
message(FATAL_ERROR "Multiple SYCL implementations specified, please set only one of the following "
"set one of SYCL_ACADEMY_USE_ADAPTIVECPP or SYCL_ACADEMY_USE_DPCPP to ON. ")
endif()
# Common setup
if(NOT DEFINED ${CMAKE_BUILD_TYPE})
set(CMAKE_BUILD_TYPE "Debug")
endif()
find_package(Threads REQUIRED)
add_subdirectory(Utilities)
# DPC++ setup
if (SYCL_ACADEMY_USE_DPCPP)
# For DPCPP module to work, find_package to work, use the options
# -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx on the command line.
# See /opt/intel/oneapi/compiler/latest/linux/IntelSYCL/ReadMeSYCL.txt
set(IntelSYCL_DIR /opt/intel/oneapi/compiler/latest/linux/IntelSYCL)
find_package(IntelSYCL REQUIRED)
endif()
# AdaptiveCpp setup
if (SYCL_ACADEMY_USE_ADAPTIVECPP)
if (NOT SYCL_ACADEMY_INSTALL_ROOT)
message(FATAL_ERROR "SYCL implementation root not provided, please specify "
"the path to the root of the chosen SYCL implementation using "
"SYCL_ACADEMY_INSTALL_ROOT=<path/to/install/root>.")
endif()
set(AdaptiveCpp_DIR ${SYCL_ACADEMY_INSTALL_ROOT}/lib/cmake/AdaptiveCpp)
find_package(AdaptiveCpp CONFIG REQUIRED PATHS)
endif()
# Exercises
enable_testing()
add_subdirectory(External/Catch2)
add_subdirectory(Code_Exercises)
# Create the Image directory
# Set source and destination paths
set(SOURCE_DIR "${CMAKE_SOURCE_DIR}/Code_Exercises/Images/")
set(DESTINATION_DIR "${CMAKE_BINARY_DIR}/Code_Exercises/Images/")
# Copy all files from source to destination using file(COPY ...)
file(COPY ${SOURCE_DIR} DESTINATION ${DESTINATION_DIR})