Skip to content

Commit b159172

Browse files
Changes for Cython.Coverage to work with scikit-build
When cython converts .pyx files to cxx it is now provided a working directory option. This makes sure that generated `__pyx_f` array lists sources relative to project directory. When generating coverage, cmake adds a target to copy generated .cxx files to the location of .pyx file.
1 parent aabbbef commit b159172

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

dpctl/CMakeLists.txt

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
find_package(PythonExtensions REQUIRED)
33
find_package(NumPy REQUIRED)
4+
5+
set(CYTHON_FLAGS "-w ${CMAKE_SOURCE_DIR}")
46
find_package(Cython REQUIRED)
57

68
if(WIN32)
@@ -135,8 +137,21 @@ function(build_dpctl_ext _trgt _src _dest)
135137
-P ${CMAKE_SOURCE_DIR}/dpctl/cmake/copy_existing.cmake
136138
DEPENDS ${_trgt}
137139
VERBATIM
138-
COMMENT "Copying Cython-generated headers to destination"
140+
COMMENT "Copying Cython-generated headers to dpctl"
139141
)
142+
if (DPCTL_GENERATE_COVERAGE)
143+
set(_copy_cxx_trgt "${_trgt}_copy_cxx")
144+
add_custom_target(
145+
${_copy_cxx_trgt} ALL
146+
COMMAND ${CMAKE_COMMAND}
147+
-DSOURCE_FILE=${_generated_src}
148+
-DDEST=${CMAKE_CURRENT_SOURCE_DIR}
149+
-P ${CMAKE_SOURCE_DIR}/dpctl/cmake/copy_existing.cmake
150+
DEPENDS ${_trgt}
151+
VERBATIM
152+
COMMENT "Copying Cython-generated source to dpctl"
153+
)
154+
endif()
140155
install(TARGETS ${_trgt} LIBRARY DESTINATION ${_dest})
141156
endfunction()
142157

0 commit comments

Comments
 (0)