Files
cmake/Tests/RunCMake/Swift/EmitModuleSeparatelyExistingModulePath-build-check.cmake
T
Roman Lavrov 899f1496f8 Swift/Ninja: Fix emit-module-path clobbering on separate emit-module edge
Since commit b6367f723b (Swift/Ninja: Emit modules separately from
compilation, 2026-04-10) the compile edge still appends
-emit-module -emit-module-path when emitModuleSeparately is active,
duplicating the emit-module edge.  For targets with directory-style
module paths (CMP0195=NEW), this causes a file/directory conflict
that fails the build.

Guard -emit-module -emit-module-path on both the compile and
emit-module edges so they are not appended when the flags already
contain -emit-module-path (e.g. from the target's compile options).

Discovered building swift-syntax on Windows where the directory-style
path was overwritten by the flat path from the compile edge.

Issue: #27748
2026-04-27 18:57:47 -04:00

12 lines
448 B
CMake

# When the target's flags already contain -emit-module-path, the emit-module
# edge should not append a second one that clobbers it.
# Match command lines that have two -emit-module-path flags on the same line.
string(
REGEX MATCHALL
"-emit-module-path [^\n]*-emit-module-path"
duplicate_flags "${actual_stdout}")
if(duplicate_flags)
string(APPEND RunCMake_TEST_FAILED
"Found command with duplicate -emit-module-path flags.\n")
endif()