mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-25 16:09:42 -06:00
Autogen: Fix library dependency forwarding to _autogen target
Library dependencies of the origin target were forwarded to the _autogen target as source file dependencies. This is fixed by forwarding the dependencies as target dependencies instead. Issue: #17278
This commit is contained in:
committed by
Brad King
parent
f5e48edaae
commit
bd49ae5109
@@ -821,40 +821,39 @@ void cmQtAutoGeneratorInitializer::InitCustomTargets()
|
||||
this->Target->Target->AddPreBuildCommand(cc);
|
||||
} else {
|
||||
|
||||
// Convert file dependencies std::set to std::vector
|
||||
std::vector<std::string> autogenDepends(autogenDependFiles.begin(),
|
||||
autogenDependFiles.end());
|
||||
|
||||
// Add link library target dependencies to the autogen target
|
||||
// dependencies
|
||||
for (std::string const& config : this->ConfigsList) {
|
||||
cmLinkImplementationLibraries const* libs =
|
||||
this->Target->GetLinkImplementationLibraries(config);
|
||||
if (libs != nullptr) {
|
||||
for (cmLinkItem const& item : libs->Libraries) {
|
||||
cmGeneratorTarget const* libTarget = item.Target;
|
||||
if ((libTarget != nullptr) &&
|
||||
!StaticLibraryCycle(this->Target, libTarget, config)) {
|
||||
std::string util;
|
||||
if (this->ConfigsList.size() > 1) {
|
||||
util += "$<$<CONFIG:";
|
||||
util += config;
|
||||
util += ">:";
|
||||
{
|
||||
// add_dependencies/addUtility do not support generator expressions.
|
||||
// We depend only on the libraries found in all configs therefore.
|
||||
std::map<cmGeneratorTarget const*, std::size_t> commonTargets;
|
||||
for (std::string const& config : this->ConfigsList) {
|
||||
cmLinkImplementationLibraries const* libs =
|
||||
this->Target->GetLinkImplementationLibraries(config);
|
||||
if (libs != nullptr) {
|
||||
for (cmLinkItem const& item : libs->Libraries) {
|
||||
cmGeneratorTarget const* libTarget = item.Target;
|
||||
if ((libTarget != nullptr) &&
|
||||
!StaticLibraryCycle(this->Target, libTarget, config)) {
|
||||
// Increment target config count
|
||||
commonTargets[libTarget]++;
|
||||
}
|
||||
util += libTarget->GetName();
|
||||
if (this->ConfigsList.size() > 1) {
|
||||
util += ">";
|
||||
}
|
||||
autogenDepends.push_back(util);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (auto const& item : commonTargets) {
|
||||
if (item.second == this->ConfigsList.size()) {
|
||||
autogenDependTargets.insert(item.first->Target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create autogen target
|
||||
cmTarget* autogenTarget = makefile->AddUtilityCommand(
|
||||
this->AutogenTargetName, cmMakefile::TargetOrigin::Generator, true,
|
||||
this->DirWork.c_str(), /*byproducts=*/autogenProvides, autogenDepends,
|
||||
this->DirWork.c_str(), /*byproducts=*/autogenProvides,
|
||||
std::vector<std::string>(autogenDependFiles.begin(),
|
||||
autogenDependFiles.end()),
|
||||
commandLines, false, autogenComment.c_str());
|
||||
// Create autogen generator target
|
||||
localGen->AddGeneratorTarget(
|
||||
|
||||
Reference in New Issue
Block a user