mirror of
https://github.com/Kitware/CMake.git
synced 2025-12-31 10:50:16 -06:00
Ninja: Avoid re-linking a Swift executable on every build
Swift doesn't emit swiftmodules for executables, so we shouldn't put it in dependency graph. Ninja sees the "missing" dependency and always tries to rebuild/re-link the target.
This commit is contained in:
@@ -1112,7 +1112,9 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement(
|
||||
this->GetObjectFilePath(source, config));
|
||||
}
|
||||
}
|
||||
linkBuild.Outputs.push_back(vars["SWIFT_MODULE"]);
|
||||
if (targetType != cmStateEnums::EXECUTABLE) {
|
||||
linkBuild.Outputs.push_back(vars["SWIFT_MODULE"]);
|
||||
}
|
||||
} else {
|
||||
linkBuild.ExplicitDeps = this->GetObjects(config);
|
||||
}
|
||||
|
||||
1
Tests/RunCMake/Swift/NoWorkToDo-nowork-stdout.txt
Normal file
1
Tests/RunCMake/Swift/NoWorkToDo-nowork-stdout.txt
Normal file
@@ -0,0 +1 @@
|
||||
^ninja: no work to do
|
||||
2
Tests/RunCMake/Swift/NoWorkToDo.cmake
Normal file
2
Tests/RunCMake/Swift/NoWorkToDo.cmake
Normal file
@@ -0,0 +1,2 @@
|
||||
enable_language(Swift)
|
||||
add_executable(hello hello.swift)
|
||||
@@ -14,6 +14,16 @@ elseif(RunCMake_GENERATOR STREQUAL Ninja)
|
||||
run_cmake(SwiftMultiArch)
|
||||
unset(RunCMake_TEST_OPTIONS)
|
||||
endif()
|
||||
|
||||
# Test that a second build with no changes does nothing.
|
||||
block()
|
||||
run_cmake(NoWorkToDo)
|
||||
set(RunCMake_TEST_NO_CLEAN 1)
|
||||
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/NoWorkToDo-build)
|
||||
set(RunCMake_TEST_OUTPUT_MERGE 1)
|
||||
run_cmake_command(NoWorkToDo-build ${CMAKE_COMMAND} --build .)
|
||||
run_cmake_command(NoWorkToDo-nowork ${CMAKE_COMMAND} --build . -- -d explain)
|
||||
endblock()
|
||||
endif()
|
||||
elseif(RunCMake_GENERATOR STREQUAL "Ninja Multi-Config")
|
||||
if(CMAKE_Swift_COMPILER)
|
||||
|
||||
0
Tests/RunCMake/Swift/hello.swift
Normal file
0
Tests/RunCMake/Swift/hello.swift
Normal file
Reference in New Issue
Block a user