6060
6161 target_include_directories (dpct
6262 PUBLIC
63- $<BUILD_INTERFACE :${CMAKE_CURRENT_SOURCE_DIR } /include >
6463 $<INSTALL_INTERFACE :${CMAKE_INSTALL_INCLUDEDIR} >
6564 )
6665
@@ -69,6 +68,31 @@ else()
6968 EXPORT_NAME dpct
7069 )
7170
71+ # Consumers (src/*.cpp, python/*.cpp) include headers as <dpct/foo.h>.
72+ # After `make install`, that layout exists because headers are copied to
73+ # ${prefix}/include/dpct/*.h. But target_include_directories'
74+ # BUILD_INTERFACE above pointed straight at the flat source include/
75+ # directory (no dpct/ subfolder), so an in-tree/single-stage build (as
76+ # opposed to conda's two-stage build, which always builds against an
77+ # *installed* dpct) failed to resolve <dpct/foo.h>. Mirror the installed
78+ # layout in the build tree via a symlinked include/dpct/ so both build
79+ # and install interfaces agree.
80+ set (DPCT_BUILD_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR } /build_include" )
81+ file (MAKE_DIRECTORY "${DPCT_BUILD_INCLUDE_DIR} " )
82+ if (NOT EXISTS "${DPCT_BUILD_INCLUDE_DIR} /dpct" )
83+ file (CREATE_LINK "${CMAKE_CURRENT_SOURCE_DIR } /include" "${DPCT_BUILD_INCLUDE_DIR} /dpct"
84+ SYMBOLIC RESULT _dpct_link_result )
85+ if (NOT _dpct_link_result EQUAL 0)
86+ message (STATUS "dpct: symlinking include/ as dpct/ failed (${_dpct_link_result} ), copying headers instead" )
87+ file (REMOVE_RECURSE "${DPCT_BUILD_INCLUDE_DIR} /dpct" )
88+ file (COPY "${CMAKE_CURRENT_SOURCE_DIR } /include/" DESTINATION "${DPCT_BUILD_INCLUDE_DIR} /dpct" )
89+ endif ()
90+ endif ()
91+ target_include_directories (dpct
92+ PUBLIC
93+ $<BUILD_INTERFACE :${DPCT_BUILD_INCLUDE_DIR} >
94+ )
95+
7296 # installation
7397 install (TARGETS dpct
7498 EXPORT dpctTargets
0 commit comments