Skip to content

Commit bbf6c31

Browse files
committed
Add headers interface
1 parent 27956d1 commit bbf6c31

File tree

6 files changed

+29
-5
lines changed

6 files changed

+29
-5
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ add_subdirectory(libsyclinterface)
5353

5454
add_library(DpctlCAPI INTERFACE)
5555
target_include_directories(DpctlCAPI INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/dpctl/apis/include)
56-
target_link_libraries(DpctlCAPI INTERFACE DPCTLSyclInterface)
56+
target_link_libraries(DpctlCAPI INTERFACE DPCTLSyclInterfaceHeaders)
5757

5858
install(DIRECTORY
5959
${CMAKE_CURRENT_SOURCE_DIR}/dpctl/apis/include/

dpctl/CMakeLists.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ function(build_dpctl_ext _trgt _src _dest)
116116
# headers related to this target and appropriate folder structure to
117117
# eliminate shadow dependencies
118118
get_filename_component(_generated_src_dir_dir ${_generated_src_dir} DIRECTORY)
119+
# TODO: do not set directory if we did not generate header
119120
target_include_directories(${_trgt} INTERFACE ${_generated_src_dir_dir})
120121

121122
install(TARGETS ${_trgt}
@@ -128,21 +129,32 @@ function(build_dpctl_ext _trgt _src _dest)
128129
${_generated_public_h}
129130
DESTINATION ${CMAKE_INSTALL_PREFIX}/dpctl/include/${_dest}
130131
OPTIONAL)
132+
133+
set(_trgt_headers ${_trgt}_headers)
134+
add_library(${_trgt_headers} INTERFACE)
135+
add_dependencies(${_trgt_headers} ${_trgt})
136+
get_target_property(_trgt_headers_dir ${_trgt} INTERFACE_INCLUDE_DIRECTORIES)
137+
target_include_directories(${_trgt_headers} INTERFACE ${_trgt_headers_dir})
131138
endfunction()
132139

133140
file(GLOB _cython_sources ${CMAKE_CURRENT_SOURCE_DIR}/*.pyx)
134141
list(REMOVE_ITEM _cython_sources ${CMAKE_CURRENT_SOURCE_DIR}/_sycl_queue.pyx)
135142
foreach(_cy_file ${_cython_sources})
136143
get_filename_component(_trgt ${_cy_file} NAME_WLE)
137144
build_dpctl_ext(${_trgt} ${_cy_file} "dpctl")
138-
target_link_libraries(DpctlCAPI INTERFACE ${_trgt})
145+
target_link_libraries(DpctlCAPI INTERFACE ${_trgt}_headers)
146+
# TODO: cleanup
147+
# add_dependencies(DpctlCAPI ${_trgt})
148+
# get_target_property(_trgt_headers ${_trgt} INTERFACE_INCLUDE_DIRECTORIES)
149+
# target_include_directories(DpctlCAPI INTERFACE ${_trgt_headers})
139150
endforeach()
140151

141152
set(_cy_file ${CMAKE_CURRENT_SOURCE_DIR}/_sycl_queue.pyx)
142153
get_filename_component(_trgt ${_cy_file} NAME_WLE)
143154
build_dpctl_ext(${_trgt} ${_cy_file} "dpctl" SYCL)
144155
# _sycl_queue include _host_task_util.hpp
145156
target_include_directories(${_trgt} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
157+
target_link_libraries(DpctlCAPI INTERFACE ${_trgt}_headers)
146158

147159
add_subdirectory(program)
148160
add_subdirectory(memory)

dpctl/memory/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ file(GLOB _cython_sources *.pyx)
33
foreach(_cy_file ${_cython_sources})
44
get_filename_component(_trgt ${_cy_file} NAME_WLE)
55
build_dpctl_ext(${_trgt} ${_cy_file} "dpctl/memory")
6-
target_link_libraries(DpctlCAPI INTERFACE ${_trgt})
6+
target_link_libraries(DpctlCAPI INTERFACE ${_trgt}_headers)
77
endforeach()

dpctl/program/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ file(GLOB _cython_sources *.pyx)
33
foreach(_cy_file ${_cython_sources})
44
get_filename_component(_trgt ${_cy_file} NAME_WLE)
55
build_dpctl_ext(${_trgt} ${_cy_file} "dpctl/program")
6-
target_link_libraries(DpctlCAPI INTERFACE ${_trgt})
6+
target_link_libraries(DpctlCAPI INTERFACE ${_trgt}_headers)
77
endforeach()

dpctl/tensor/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ foreach(_cy_file ${_cython_sources})
33
get_filename_component(_trgt ${_cy_file} NAME_WLE)
44
build_dpctl_ext(${_trgt} ${_cy_file} "dpctl/tensor")
55
target_include_directories(${_trgt} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
6-
target_link_libraries(DpctlCAPI INTERFACE ${_trgt})
6+
target_link_libraries(DpctlCAPI INTERFACE ${_trgt}_headers)
77
endforeach()
88

99
# TODO: do we need to write this dependencies explicitly? Does it even work this

libsyclinterface/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,11 +269,18 @@ if(DPCTL_ENABLE_L0_PROGRAM_CREATION)
269269
endif()
270270

271271
target_include_directories(DPCTLSyclInterface INTERFACE
272+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
273+
$<INSTALL_INTERFACE:include>
274+
)
275+
add_library(DPCTLSyclInterfaceHeaders INTERFACE)
276+
add_dependencies(DPCTLSyclInterfaceHeaders DPCTLSyclInterface)
277+
target_include_directories(DPCTLSyclInterfaceHeaders INTERFACE
272278
${CMAKE_CURRENT_SOURCE_DIR}/include
273279
)
274280

275281
install(TARGETS
276282
DPCTLSyclInterface
283+
EXPORT DPCTLSyclInterface
277284
LIBRARY
278285
DESTINATION ${CMAKE_INSTALL_PREFIX}/dpctl
279286
)
@@ -283,6 +290,11 @@ install(DIRECTORY
283290
FILES_MATCHING REGEX "\\.h(pp)?$"
284291
)
285292

293+
install(EXPORT DPCTLSyclInterface
294+
FILE DPCTLSyclInterface.cmake
295+
DESTINATION cmake/DPCTLSyclInterface
296+
)
297+
286298
# Add sub-directory to build the dpctl C API test cases
287299
if(DPCTL_BUILD_CAPI_TESTS)
288300
add_subdirectory(tests)

0 commit comments

Comments
 (0)