Skip to content

Commit 88f8e38

Browse files
authored
[SYCL][NFC] Avoid rebuilding sycl library every time (#4710)
SYCL/XPTI headers were copyied every time the build has triggered. That invalidates all compilation that depend on them. As result, SYCL library and some other targets were rebuilt on every build. This change makes CMake copy header only they have changed. Also version.hpp file is generated directly in build directory to avoid copy step. Remove redundant include of header as source file.
1 parent f54029d commit 88f8e38

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

sycl/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

sycl/CMakeLists.txt

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,23 @@ set(sycl_inc_dir ${CMAKE_CURRENT_SOURCE_DIR}/include)
9898
set(sycl_src_dir ${CMAKE_CURRENT_SOURCE_DIR}/source)
9999
set(sycl_plugin_dir ${CMAKE_CURRENT_SOURCE_DIR}/plugins)
100100
string(TIMESTAMP __SYCL_COMPILER_VERSION "%Y%m%d")
101-
set(version_header "${sycl_inc_dir}/CL/sycl/version.hpp")
102-
configure_file("${version_header}.in" "${version_header}")
103101

104102
# Copy SYCL headers from sources to build directory
105-
add_custom_target(sycl-headers ALL
106-
COMMAND ${CMAKE_COMMAND} -E copy_directory ${sycl_inc_dir}/sycl ${SYCL_INCLUDE_BUILD_DIR}/sycl
107-
COMMAND ${CMAKE_COMMAND} -E copy_directory ${sycl_inc_dir}/CL ${SYCL_INCLUDE_BUILD_DIR}/sycl/CL
108-
COMMENT "Copying SYCL headers ...")
103+
add_custom_target(sycl-headers
104+
DEPENDS ${SYCL_INCLUDE_BUILD_DIR}/sycl
105+
${SYCL_INCLUDE_BUILD_DIR}/sycl/CL)
106+
107+
add_custom_command(
108+
OUTPUT ${SYCL_INCLUDE_BUILD_DIR}/sycl
109+
${SYCL_INCLUDE_BUILD_DIR}/sycl/CL
110+
DEPENDS ${sycl_inc_dir}/sycl
111+
${sycl_inc_dir}/CL
112+
COMMAND ${CMAKE_COMMAND} -E copy_directory ${sycl_inc_dir}/sycl ${SYCL_INCLUDE_BUILD_DIR}/sycl
113+
COMMAND ${CMAKE_COMMAND} -E copy_directory ${sycl_inc_dir}/CL ${SYCL_INCLUDE_BUILD_DIR}/sycl/CL
114+
COMMENT "Copying SYCL headers ...")
115+
116+
configure_file("${sycl_inc_dir}/CL/sycl/version.hpp.in" "${SYCL_INCLUDE_BUILD_DIR}/CL/sycl/version.hpp")
117+
109118

110119
# Copy SYCL headers from sources to install directory
111120
install(DIRECTORY "${sycl_inc_dir}/sycl" DESTINATION ${SYCL_INCLUDE_DIR} COMPONENT sycl-headers)

sycl/source/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ function(add_sycl_rt_library LIB_NAME)
103103
endfunction(add_sycl_rt_library)
104104

105105
set(SYCL_SOURCES
106-
"${sycl_inc_dir}/CL/sycl.hpp"
107106
"backend/opencl.cpp"
108107
"backend/level_zero.cpp"
109108
"backend.cpp"

xpti/CMakeLists.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,16 @@ set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR})
7777
add_subdirectory(src)
7878

7979
if (LLVM_BINARY_DIR)
80-
add_custom_target(xpti-headers ALL
80+
add_custom_target(xpti-headers
81+
DEPENDS ${LLVM_BINARY_DIR}/include/xpti)
82+
83+
add_custom_command(
84+
OUTPUT ${LLVM_BINARY_DIR}/include/xpti
85+
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/include/xpti
8186
COMMAND ${CMAKE_COMMAND} -E copy_directory
8287
${CMAKE_CURRENT_SOURCE_DIR}/include/xpti
8388
${LLVM_BINARY_DIR}/include/xpti
84-
COMMENT "Copying XPTI headers..."
89+
COMMENT "Copying XPTI headers ..."
8590
)
8691
add_dependencies(xpti xpti-headers)
8792
endif()

0 commit comments

Comments
 (0)