Skip to content

Commit dff9c43

Browse files
Change the CMake script that for copying header files to dpctl/include
Instead of using add_custom_command for a TARGET which does not specify the required PRE_BUILD/PRE_LINK/POST_LINK argument, use add_custom_command with OUTPUT to perform the copy, record files coped and create a custom target that depend on those. All Cython files then depend on that target.
1 parent db6b953 commit dff9c43

File tree

1 file changed

+36
-13
lines changed

1 file changed

+36
-13
lines changed

dpctl/CMakeLists.txt

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,41 +78,64 @@ add_custom_target(_build_time_create_dpctl_include ALL
7878
DEPENDS DPCTLSyclInterface
7979
)
8080

81+
set(_copied_header_files)
8182
file(GLOB _syclinterface_h ${CMAKE_SOURCE_DIR}/libsyclinterface/include/*.h)
8283
foreach(hf ${_syclinterface_h})
83-
add_custom_command(TARGET _build_time_create_dpctl_include
84-
COMMAND ${CMAKE_COMMAND} -E copy ${hf} ${DPCTL_INCLUDE_DIR}/syclinterface
85-
)
84+
get_filename_component(_header_name ${hf} NAME)
85+
set(_target_header_file ${DPCTL_INCLUDE_DIR}/syclinterface/${_header_name})
86+
list(APPEND _copied_header_files ${_target_header_file})
87+
add_custom_command(OUTPUT ${_target_header_file}
88+
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${hf} ${_target_header_file}
89+
DEPENDS ${hf} _build_time_create_dpctl_include
90+
VERBATIM
91+
)
8692
endforeach()
8793

8894
file(GLOB _syclinterface_Support_h ${CMAKE_SOURCE_DIR}/libsyclinterface/include/Support/*.h)
8995
foreach(hf ${_syclinterface_Support_h})
90-
add_custom_command(TARGET _build_time_create_dpctl_include
91-
COMMAND ${CMAKE_COMMAND} -E copy ${hf} ${DPCTL_INCLUDE_DIR}/syclinterface/Support
92-
)
96+
get_filename_component(_header_name ${hf} NAME)
97+
set(_target_header_file ${DPCTL_INCLUDE_DIR}/syclinterface/Support/${_header_name})
98+
list(APPEND _copied_header_files ${_target_header_file})
99+
add_custom_command(OUTPUT ${_target_header_file}
100+
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${hf} ${_target_header_file}
101+
DEPENDS ${hf} _build_time_create_dpctl_include
102+
)
93103
endforeach()
94104

95105
file(GLOB _syclinterface_Config_h ${CMAKE_SOURCE_DIR}/libsyclinterface/include/Config/*.h)
96106
foreach(hf ${_syclinterface_Config_h})
97-
add_custom_command(TARGET _build_time_create_dpctl_include
98-
COMMAND ${CMAKE_COMMAND} -E copy ${hf} ${DPCTL_INCLUDE_DIR}/syclinterface/Config
99-
)
107+
get_filename_component(_header_name ${hf} NAME)
108+
set(_target_header_file ${DPCTL_INCLUDE_DIR}/syclinterface/Config/${_header_name})
109+
list(APPEND _copied_header_files ${_target_header_file})
110+
add_custom_command(OUTPUT ${_target_header_file}
111+
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${hf} ${_target_header_file}
112+
DEPENDS ${hf} _build_time_create_dpctl_include
113+
)
100114
endforeach()
101115

102116
file(GLOB _apis_h ${CMAKE_CURRENT_SOURCE_DIR}/apis/include/*)
103117
foreach(hf ${_apis_h})
104-
add_custom_command(TARGET _build_time_create_dpctl_include
105-
COMMAND ${CMAKE_COMMAND} -E copy ${hf} ${DPCTL_INCLUDE_DIR}
106-
)
118+
get_filename_component(_header_name ${hf} NAME)
119+
set(_target_header_file ${DPCTL_INCLUDE_DIR}/${_header_name})
120+
list(APPEND _copied_header_files ${_target_header_file})
121+
add_custom_command(OUTPUT ${_target_header_file}
122+
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${hf} ${_target_header_file}
123+
DEPENDS ${hf} _build_time_create_dpctl_include
124+
)
107125
endforeach()
108126

127+
add_custom_target(
128+
_build_time_create_dpctl_include_copy ALL
129+
DEPENDS ${_copied_header_files}
130+
)
131+
109132
set(CMAKE_INSTALL_RPATH "$ORIGIN")
110133

111134
function(build_dpctl_ext _trgt _src _dest)
112135
add_cython_target(${_trgt} ${_src} CXX OUTPUT_VAR _generated_src)
113136
add_library(${_trgt} MODULE ${_generated_src})
114137
target_include_directories(${_trgt} PRIVATE ${NumPy_INCLUDE_DIR} ${DPCTL_INCLUDE_DIR})
115-
add_dependencies(${_trgt} _build_time_create_dpctl_include)
138+
add_dependencies(${_trgt} _build_time_create_dpctl_include_copy)
116139
if (DPCTL_GENERATE_COVERAGE)
117140
target_compile_definitions(${_trgt} PRIVATE CYTHON_TRACE=1 CYTHON_TRACE_NOGIL=1)
118141
target_compile_options(${_trgt} PRIVATE -fno-sycl-use-footer)

0 commit comments

Comments
 (0)