Skip to content

Commit

Permalink
[SYCL] Detect changes in sycl headers (#4723)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
vladimirlaz authored Oct 7, 2021
1 parent 20d9346 commit 8d979f0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
1 change: 1 addition & 0 deletions sycl/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include/CL/sycl/version.hpp
19 changes: 13 additions & 6 deletions sycl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,25 +98,32 @@ set(sycl_inc_dir ${CMAKE_CURRENT_SOURCE_DIR}/include)
set(sycl_src_dir ${CMAKE_CURRENT_SOURCE_DIR}/source)
set(sycl_plugin_dir ${CMAKE_CURRENT_SOURCE_DIR}/plugins)
string(TIMESTAMP __SYCL_COMPILER_VERSION "%Y%m%d")
set(version_header "${sycl_inc_dir}/CL/sycl/version.hpp")
configure_file("${version_header}.in" "${version_header}")

# This is workaround to detect changes (add or modify) in subtree which
# are not detected by copy_directory command.
# TODO: detect and process remove header/directory case
file(GLOB_RECURSE HEADERS_IN_SYCL_DIR CONFIGURE_DEPENDS "${sycl_inc_dir}/sycl/*")
file(GLOB_RECURSE HEADERS_IN_CL_DIR CONFIGURE_DEPENDS "${sycl_inc_dir}/CL/*")

# Copy SYCL headers from sources to build directory
add_custom_target(sycl-headers
DEPENDS ${SYCL_INCLUDE_BUILD_DIR}/sycl
${SYCL_INCLUDE_BUILD_DIR}/sycl/sycl.hpp
${SYCL_INCLUDE_BUILD_DIR}/sycl/CL)

add_custom_command(
OUTPUT ${SYCL_INCLUDE_BUILD_DIR}/sycl
${SYCL_INCLUDE_BUILD_DIR}/sycl/sycl.hpp
${SYCL_INCLUDE_BUILD_DIR}/sycl/CL
DEPENDS ${sycl_inc_dir}/sycl
${sycl_inc_dir}/CL
DEPENDS ${HEADERS_IN_SYCL_DIR}
${HEADERS_IN_CL_DIR}
COMMAND ${CMAKE_COMMAND} -E copy_directory ${sycl_inc_dir}/sycl ${SYCL_INCLUDE_BUILD_DIR}/sycl
COMMAND ${CMAKE_COMMAND} -E copy_directory ${sycl_inc_dir}/CL ${SYCL_INCLUDE_BUILD_DIR}/sycl/CL
COMMENT "Copying SYCL headers ...")

configure_file("${sycl_inc_dir}/CL/sycl/version.hpp.in" "${SYCL_INCLUDE_BUILD_DIR}/CL/sycl/version.hpp")


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

Expand Down
3 changes: 2 additions & 1 deletion xpti/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,13 @@ set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR})
add_subdirectory(src)

if (LLVM_BINARY_DIR)
file(GLOB_RECURSE XPTI_HEADERS_LIST CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/include/xpti/*")
add_custom_target(xpti-headers
DEPENDS ${LLVM_BINARY_DIR}/include/xpti)

add_custom_command(
OUTPUT ${LLVM_BINARY_DIR}/include/xpti
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/include/xpti
DEPENDS ${XPTI_HEADERS_LIST}
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_CURRENT_SOURCE_DIR}/include/xpti
${LLVM_BINARY_DIR}/include/xpti
Expand Down

0 comments on commit 8d979f0

Please sign in to comment.