Merge topic 'custom_command-depfile-management'

8979e7aaab add_custom_command(DEPFILE): avoid duplicate entries in dependencies

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !9945
This commit is contained in:
Brad King 2024-10-28 13:30:00 +00:00 committed by Kitware Robot
commit 87778f46ca
2 changed files with 11 additions and 7 deletions

View File

@ -4,7 +4,6 @@
#include "cmDependsCompiler.h"
#include <algorithm>
#include <iterator>
#include <map>
#include <string>
#include <unordered_set>
@ -111,13 +110,9 @@ bool cmDependsCompiler::CheckDependencies(
// copy depends for each target, except first one, which can be
// moved
for (auto index = entry.rules.size() - 1; index > 0; --index) {
auto& rule_deps = dependencies[entry.rules[index]];
rule_deps.insert(rule_deps.end(), depends.cbegin(),
depends.cend());
dependencies[entry.rules[index]] = depends;
}
auto& rule_deps = dependencies[entry.rules.front()];
std::move(depends.cbegin(), depends.cend(),
std::back_inserter(rule_deps));
dependencies[entry.rules.front()] = std::move(depends);
}
} else {
if (format == "msvc"_s) {

View File

@ -77,5 +77,14 @@ if(check_step EQUAL 3)
\"${CMAKE_BINARY_DIR}/step3.timestamp|$<TARGET_FILE:subexe>\"
\"${CMAKE_BINARY_DIR}/step3.timestamp|$<TARGET_FILE:sublib>\"
)
if (RunCMake_GENERATOR MATCHES \"Make\")
file(STRINGS \"${CMAKE_BINARY_DIR}/CMakeFiles/topcc.dir/compiler_depend.internal\" deps REGEX \"^.*topccdep\\\\.txt$\")
list(LENGTH deps count)
if (NOT count EQUAL 1)
string(APPEND RunCMake_TEST_FAILED \"dependencies are duplicated\\n\")
set(RunCMake_TEST_FAILED \"\${RunCMake_TEST_FAILED}\" PARENT_SCOPE)
endif()
endif()
endif()
")