Skip to content

Commit b54c92a

Browse files
authored
Merge pull request #26 from adetaylor/header-dep-tracking
Improve tracking dependencies of header generation.
2 parents 36f0a94 + 280b532 commit b54c92a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

3_bidirectional_cxx_interop/cmake/modules/AddSwift.cmake

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ function(_swift_generate_cxx_header target header)
4848
cmake_path(APPEND base_path ${header}
4949
OUTPUT_VARIABLE header_path)
5050

51-
set(_AllSources $<TARGET_PROPERTY:${target},SOURCES>)
51+
cmake_path(APPEND CMAKE_CURRENT_BINARY_DIR "${ARG_MODULE_NAME}.emit-module.d" OUTPUT_VARIABLE depfile_path)
52+
53+
set(_AllSources $<PATH:ABSOLUTE_PATH,$<TARGET_PROPERTY:${target},SOURCES>,${CMAKE_CURRENT_SOURCE_DIR}>)
5254
set(_SwiftSources $<FILTER:${_AllSources},INCLUDE,\\.swift$>)
5355
add_custom_command(OUTPUT ${header_path}
5456
DEPENDS ${_SwiftSources}
@@ -61,6 +63,9 @@ function(_swift_generate_cxx_header target header)
6163
-module-name "${ARG_MODULE_NAME}"
6264
-cxx-interoperability-mode=default
6365
-emit-clang-header-path ${header_path}
66+
-emit-dependencies
67+
DEPFILE "${depfile_path}"
68+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
6469
COMMENT
6570
"Generating '${header_path}'"
6671
COMMAND_EXPAND_LISTS)

0 commit comments

Comments
 (0)