Skip to content

Commit 22251ef

Browse files
committed
[SYCL] Detect changes in sycl headers
When subdirectory of the DEPENDS directories are modified the change is not detected by CMake. The change set full list of files in subdirectory to DEPENDS to detect the change. file(GLOBE_RECURSE) is used with CONFIGURE_DEPENDS option to rerun configure if new entry is added to directory structure. Restore version.hpp in source directory as it is used to build SYCL library. Removing header file is the only case when change is not propagated to build and install directory. This problem existed before the change and TODO was left to fix it in future.
1 parent f844f70 commit 22251ef

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
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: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,27 +98,34 @@ 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
120-
install(DIRECTORY "${sycl_inc_dir}/sycl" DESTINATION ${SYCL_INCLUDE_DIR} COMPONENT sycl-headers)
121-
install(DIRECTORY "${sycl_inc_dir}/CL" DESTINATION ${SYCL_INCLUDE_DIR}/sycl COMPONENT sycl-headers)
126+
# Copy SYCL headers from build to install directory
127+
install(DIRECTORY "${SYCL_INCLUDE_BUILD_DIR}/sycl" DESTINATION ${SYCL_INCLUDE_DIR} COMPONENT sycl-headers)
128+
install(FILES "${version_header}" DESTINATION ${SYCL_INCLUDE_DIR}/sycl/CL/sycl COMPONENT sycl-headers)
122129

123130
set(SYCL_RT_LIBS sycl)
124131
if (MSVC)

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)