Skip to content

Commit 8d979f0

Browse files
authored
[SYCL] Detect changes in sycl headers (#4723)
This is follow up for #4710 When a sub-directory of the DEPENDS directories is modified the change is not detected by CMake. The change adds a full list of files in the sub-directory to DEPENDS to detect the change. file(GLOBE_RECURSE) is used with CONFIGURE_DEPENDS option to rerun configure step if a new entry is added to the directory structure. Restore version.hpp in source directory as it is used to build SYCL library. Removing a header file is the only case when change is not propagated to the build and install directory. This problem existed before the change and TODO was left to fix it in the future.
1 parent 20d9346 commit 8d979f0

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

sycl/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include/CL/sycl/version.hpp

sycl/CMakeLists.txt

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,25 +98,32 @@ 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}")
103+
104+
# This is workaround to detect changes (add or modify) in subtree which
105+
# are not detected by copy_directory command.
106+
# TODO: detect and process remove header/directory case
107+
file(GLOB_RECURSE HEADERS_IN_SYCL_DIR CONFIGURE_DEPENDS "${sycl_inc_dir}/sycl/*")
108+
file(GLOB_RECURSE HEADERS_IN_CL_DIR CONFIGURE_DEPENDS "${sycl_inc_dir}/CL/*")
101109

102110
# Copy SYCL headers from sources to build directory
103111
add_custom_target(sycl-headers
104112
DEPENDS ${SYCL_INCLUDE_BUILD_DIR}/sycl
113+
${SYCL_INCLUDE_BUILD_DIR}/sycl/sycl.hpp
105114
${SYCL_INCLUDE_BUILD_DIR}/sycl/CL)
106115

107116
add_custom_command(
108117
OUTPUT ${SYCL_INCLUDE_BUILD_DIR}/sycl
118+
${SYCL_INCLUDE_BUILD_DIR}/sycl/sycl.hpp
109119
${SYCL_INCLUDE_BUILD_DIR}/sycl/CL
110-
DEPENDS ${sycl_inc_dir}/sycl
111-
${sycl_inc_dir}/CL
120+
DEPENDS ${HEADERS_IN_SYCL_DIR}
121+
${HEADERS_IN_CL_DIR}
112122
COMMAND ${CMAKE_COMMAND} -E copy_directory ${sycl_inc_dir}/sycl ${SYCL_INCLUDE_BUILD_DIR}/sycl
113123
COMMAND ${CMAKE_COMMAND} -E copy_directory ${sycl_inc_dir}/CL ${SYCL_INCLUDE_BUILD_DIR}/sycl/CL
114124
COMMENT "Copying SYCL headers ...")
115125

116-
configure_file("${sycl_inc_dir}/CL/sycl/version.hpp.in" "${SYCL_INCLUDE_BUILD_DIR}/CL/sycl/version.hpp")
117-
118-
119-
# Copy SYCL headers from sources to install directory
126+
# Copy SYCL headers from source to install directory
120127
install(DIRECTORY "${sycl_inc_dir}/sycl" DESTINATION ${SYCL_INCLUDE_DIR} COMPONENT sycl-headers)
121128
install(DIRECTORY "${sycl_inc_dir}/CL" DESTINATION ${SYCL_INCLUDE_DIR}/sycl COMPONENT sycl-headers)
122129

xpti/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,13 @@ set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR})
7777
add_subdirectory(src)
7878

7979
if (LLVM_BINARY_DIR)
80+
file(GLOB_RECURSE XPTI_HEADERS_LIST CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/include/xpti/*")
8081
add_custom_target(xpti-headers
8182
DEPENDS ${LLVM_BINARY_DIR}/include/xpti)
8283

8384
add_custom_command(
8485
OUTPUT ${LLVM_BINARY_DIR}/include/xpti
85-
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/include/xpti
86+
DEPENDS ${XPTI_HEADERS_LIST}
8687
COMMAND ${CMAKE_COMMAND} -E copy_directory
8788
${CMAKE_CURRENT_SOURCE_DIR}/include/xpti
8889
${LLVM_BINARY_DIR}/include/xpti

0 commit comments

Comments
 (0)