Skip to content

Commit c016c56

Browse files
committed
[SYCL][NFC] Move SYCL library CMake script to source directory.
No functional changes are intended. Signed-off-by: Alexey Bader <[email protected]>
1 parent d67210c commit c016c56

File tree

3 files changed

+87
-91
lines changed

3 files changed

+87
-91
lines changed

sycl/CMakeLists.txt

Lines changed: 8 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ else()
8282
add_custom_target(ocl-icd DEPENDS ${OpenCL_LIBRARIES} COMMENT "Copying OpenCL ICD Loader ...")
8383
endif()
8484

85-
set(SYCL_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/include/")
8685
set(OPENCL_INCLUDE "${OpenCL_INCLUDE_DIRS}")
8786

8887
# Configure SYCL version macro
@@ -96,89 +95,19 @@ add_custom_target(sycl-headers ALL
9695
COMMAND ${CMAKE_COMMAND} -E copy_directory ${sycl_inc_dir}/CL ${dst_dir}/CL
9796
COMMENT "Copying SYCL headers ...")
9897

99-
# Main library
98+
# Configure SYCL headers
99+
install(DIRECTORY "${sycl_inc_dir}/." DESTINATION "${LLVM_INST_INC_DIRECTORY}" COMPONENT sycl-headers)
100100

101-
set(sourceRootPath "${CMAKE_CURRENT_SOURCE_DIR}/source")
102-
set(includeRootPath "${CMAKE_CURRENT_SOURCE_DIR}/include")
103-
104-
include_directories(AFTER "${includeRootPath}" "${OpenCL_INCLUDE_DIRS}")
101+
# Configure OpenCL header and ICD loader
102+
include_directories(AFTER "${sycl_inc_dir}" "${OpenCL_INCLUDE_DIRS}")
105103
link_libraries(${OpenCL_LIBRARIES})
106104

107-
set(SYCLLibrary sycl)
108-
109-
#To-Do:
110-
#1. Figure out why CMP0057 has to be set. Should have been taken care of earlier in the build
111-
#2. Use AddLLVM to modify the build and access config options
112-
#cmake_policy(SET CMP0057 NEW)
113-
#include(AddLLVM)
114-
set(LLVM_BUILD_LIBRARY_DIRS "${LLVM_BINARY_DIR}/lib/")
115-
116-
set(SYCL_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
117-
set(SYCL_TESTS_BINARY_DIR ${SYCL_BINARY_DIR}/test)
118-
119-
set(CLANG_IN_BUILD "${LLVM_BINARY_DIR}/bin/clang")
120-
121-
set(LLVM_TOOLS_DIR "${LLVM_BINARY_DIR}/bin/")
122-
123-
add_library("${SYCLLibrary}" SHARED
124-
"${includeRootPath}/CL/sycl.hpp"
125-
"${sourceRootPath}/detail/builtins_common.cpp"
126-
"${sourceRootPath}/detail/builtins_geometric.cpp"
127-
"${sourceRootPath}/detail/builtins_integer.cpp"
128-
"${sourceRootPath}/detail/builtins_math.cpp"
129-
"${sourceRootPath}/detail/builtins_relational.cpp"
130-
"${sourceRootPath}/detail/pi.cpp"
131-
"${sourceRootPath}/detail/pi_opencl.cpp"
132-
"${sourceRootPath}/detail/common.cpp"
133-
"${sourceRootPath}/detail/context_impl.cpp"
134-
"${sourceRootPath}/detail/device_impl.cpp"
135-
"${sourceRootPath}/detail/device_info.cpp"
136-
"${sourceRootPath}/detail/event_impl.cpp"
137-
"${sourceRootPath}/detail/force_device.cpp"
138-
"${sourceRootPath}/detail/helpers.cpp"
139-
"${sourceRootPath}/detail/image_impl.cpp"
140-
"${sourceRootPath}/detail/kernel_impl.cpp"
141-
"${sourceRootPath}/detail/kernel_info.cpp"
142-
"${sourceRootPath}/detail/memory_manager.cpp"
143-
"${sourceRootPath}/detail/platform_impl.cpp"
144-
"${sourceRootPath}/detail/platform_info.cpp"
145-
"${sourceRootPath}/detail/program_impl.cpp"
146-
"${sourceRootPath}/detail/program_manager/program_manager.cpp"
147-
"${sourceRootPath}/detail/queue_impl.cpp"
148-
"${sourceRootPath}/detail/os_util.cpp"
149-
"${sourceRootPath}/detail/platform_util.cpp"
150-
"${sourceRootPath}/detail/sampler_impl.cpp"
151-
"${sourceRootPath}/detail/stream_impl.cpp"
152-
"${sourceRootPath}/detail/scheduler/commands.cpp"
153-
"${sourceRootPath}/detail/scheduler/scheduler.cpp"
154-
"${sourceRootPath}/detail/scheduler/graph_processor.cpp"
155-
"${sourceRootPath}/detail/scheduler/graph_builder.cpp"
156-
"${sourceRootPath}/detail/usm/clusm.cpp"
157-
"${sourceRootPath}/detail/usm/opencl_shim.cpp"
158-
"${sourceRootPath}/detail/usm/usm_impl.cpp"
159-
"${sourceRootPath}/detail/util.cpp"
160-
"${sourceRootPath}/context.cpp"
161-
"${sourceRootPath}/device.cpp"
162-
"${sourceRootPath}/device_selector.cpp"
163-
"${sourceRootPath}/event.cpp"
164-
"${sourceRootPath}/exception.cpp"
165-
"${sourceRootPath}/half_type.cpp"
166-
"${sourceRootPath}/kernel.cpp"
167-
"${sourceRootPath}/platform.cpp"
168-
"${sourceRootPath}/queue.cpp"
169-
"${sourceRootPath}/sampler.cpp"
170-
"${sourceRootPath}/stream.cpp"
171-
"${sourceRootPath}/spirv_ops.cpp"
172-
)
173-
174-
add_dependencies("${SYCLLibrary}"
175-
ocl-icd
176-
ocl-headers
177-
sycl-headers
178-
)
105+
# SYCL runtime library
106+
add_subdirectory(source)
179107

108+
# SYCL toolchain builds all components: compiler, libraries, headers, etc.
180109
add_custom_target( sycl-toolchain
181-
DEPENDS "${SYCLLibrary}"
110+
DEPENDS sycl
182111
clang
183112
clang-offload-wrapper
184113
clang-offload-bundler
@@ -191,17 +120,5 @@ add_custom_target( sycl-toolchain
191120
COMMENT "Building SYCL compiler toolchain..."
192121
)
193122

194-
set_target_properties("${SYCLLibrary}" PROPERTIES LINKER_LANGUAGE CXX)
195-
196-
# Workaround for bug in GCC version 5 and higher.
197-
# More information https://bugs.launchpad.net/ubuntu/+source/gcc-5/+bug/1568899
198-
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND
199-
CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 5.0)
200-
target_link_libraries("${SYCLLibrary}" gcc_s gcc)
201-
endif()
202-
203-
install(TARGETS "${SYCLLibrary}" DESTINATION "lib" COMPONENT ${SYCLLibrary})
204-
install(DIRECTORY "${includeRootPath}/." DESTINATION "${LLVM_INST_INC_DIRECTORY}" COMPONENT sycl-headers)
205-
206123
add_subdirectory( test )
207124
add_subdirectory( tools )

sycl/source/CMakeLists.txt

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#To-Do:
2+
#1. Figure out why CMP0057 has to be set. Should have been taken care of earlier in the build
3+
#2. Use AddLLVM to modify the build and access config options
4+
#cmake_policy(SET CMP0057 NEW)
5+
#include(AddLLVM)
6+
add_library(sycl SHARED
7+
"${sycl_inc_dir}/CL/sycl.hpp"
8+
"detail/builtins_common.cpp"
9+
"detail/builtins_geometric.cpp"
10+
"detail/builtins_integer.cpp"
11+
"detail/builtins_math.cpp"
12+
"detail/builtins_relational.cpp"
13+
"detail/pi.cpp"
14+
"detail/pi_opencl.cpp"
15+
"detail/common.cpp"
16+
"detail/context_impl.cpp"
17+
"detail/device_impl.cpp"
18+
"detail/device_info.cpp"
19+
"detail/event_impl.cpp"
20+
"detail/force_device.cpp"
21+
"detail/helpers.cpp"
22+
"detail/image_impl.cpp"
23+
"detail/kernel_impl.cpp"
24+
"detail/kernel_info.cpp"
25+
"detail/memory_manager.cpp"
26+
"detail/platform_impl.cpp"
27+
"detail/platform_info.cpp"
28+
"detail/program_impl.cpp"
29+
"detail/program_manager/program_manager.cpp"
30+
"detail/queue_impl.cpp"
31+
"detail/os_util.cpp"
32+
"detail/platform_util.cpp"
33+
"detail/sampler_impl.cpp"
34+
"detail/stream_impl.cpp"
35+
"detail/scheduler/commands.cpp"
36+
"detail/scheduler/scheduler.cpp"
37+
"detail/scheduler/graph_processor.cpp"
38+
"detail/scheduler/graph_builder.cpp"
39+
"detail/usm/clusm.cpp"
40+
"detail/usm/opencl_shim.cpp"
41+
"detail/usm/usm_impl.cpp"
42+
"detail/util.cpp"
43+
"context.cpp"
44+
"device.cpp"
45+
"device_selector.cpp"
46+
"event.cpp"
47+
"exception.cpp"
48+
"half_type.cpp"
49+
"kernel.cpp"
50+
"platform.cpp"
51+
"queue.cpp"
52+
"sampler.cpp"
53+
"stream.cpp"
54+
"spirv_ops.cpp"
55+
)
56+
57+
add_dependencies(sycl
58+
ocl-icd
59+
ocl-headers
60+
sycl-headers
61+
)
62+
63+
set_target_properties(sycl PROPERTIES LINKER_LANGUAGE CXX)
64+
65+
# Workaround for bug in GCC version 5 and higher.
66+
# More information https://bugs.launchpad.net/ubuntu/+source/gcc-5/+bug/1568899
67+
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND
68+
CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 5.0)
69+
target_link_libraries(sycl gcc_s gcc)
70+
endif()
71+
72+
install(TARGETS sycl DESTINATION "lib" COMPONENT sycl)

sycl/test/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1+
set(LLVM_BUILD_LIBRARY_DIRS "${LLVM_BINARY_DIR}/lib/")
2+
set(LLVM_TOOLS_DIR "${LLVM_BINARY_DIR}/bin/")
3+
set(CLANG_IN_BUILD "${LLVM_BINARY_DIR}/bin/clang")
4+
5+
set(SYCL_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
16
set(SYCL_TESTS_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
7+
set(SYCL_TESTS_BINARY_DIR ${SYCL_BINARY_DIR}/test)
8+
29
set(RT_TEST_ARGS ${RT_TEST_ARGS} "-v")
310

411
configure_lit_site_cfg(

0 commit comments

Comments
 (0)