mirror of
https://github.com/Kitware/CMake.git
synced 2026-11-06 05:16:58 +00:00
cmTestGenerator,cmInstallGenerator: Factor out BUILD_DEPENDS entry resolution
Move the resolution of a single `BUILD_DEPENDS` entry to a target or file into a local helper in `cmTestGenerator::EvaluateBuildDependencies` and `cmInstallGenerator::ResolveBuildDepends`, in preparation for also using it on values evaluated from generator expressions. No change in behavior.
This commit is contained in:
1 parent
ef35763dd1
commit
7047fa76f6
2 files changed
+27
-15
No files matched your search
@@ -288,10 +288,12 @@ bool cmInstallGenerator::ResolveBuildDepends(
|
||||
return gg->FindArtifactOwningTarget(file, config);
|
||||
});
|
||||
};
|
||||
for (std::string const& name : names) {
|
||||
// Resolve a name to a target or a file.
|
||||
auto const resolve = [this, lg, gg, &signature, &entries,
|
||||
&isArtifact](std::string const& name) -> bool {
|
||||
if (cmGeneratorTarget const* target = lg->FindGeneratorTargetToUse(name)) {
|
||||
entries.Targets.push_back(target);
|
||||
continue;
|
||||
return true;
|
||||
}
|
||||
// A relative path is interpreted with respect to the current source
|
||||
// directory if the file exists there, and otherwise the current binary
|
||||
@@ -300,13 +302,19 @@ bool cmInstallGenerator::ResolveBuildDepends(
|
||||
if (gg->IsGeneratedByBuild(file) || isArtifact(file) ||
|
||||
cmSystemTools::FileExists(file)) {
|
||||
entries.Files.push_back(std::move(file));
|
||||
} else {
|
||||
lg->IssueMessage(
|
||||
MessageType::FATAL_ERROR,
|
||||
cmStrCat("install(", signature, ") BUILD_DEPENDS entry \"", name,
|
||||
"\" is neither a target nor a file that exists or is "
|
||||
"generated by the build."),
|
||||
this->GetBacktrace());
|
||||
return true;
|
||||
}
|
||||
lg->IssueMessage(
|
||||
MessageType::FATAL_ERROR,
|
||||
cmStrCat("install(", signature, ") BUILD_DEPENDS entry \"", name,
|
||||
"\" is neither a target nor a file that exists or is "
|
||||
"generated by the build."),
|
||||
this->GetBacktrace());
|
||||
return false;
|
||||
};
|
||||
|
||||
for (std::string const& name : names) {
|
||||
if (!resolve(name)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,21 +132,25 @@ bool cmTestGenerator::EvaluateBuildDependencies(
|
||||
}
|
||||
|
||||
// Add dependencies from BUILD_DEPENDS keyword
|
||||
for (std::string const& depName : buildDepends) {
|
||||
if (depName.empty()) {
|
||||
continue;
|
||||
}
|
||||
cmGlobalGenerator* gg = lg->GetGlobalGenerator();
|
||||
auto addBuildDependency = [lg, gg, &dependencies,
|
||||
&info](std::string const& depName) {
|
||||
cmGeneratorTarget* depTarget = lg->FindGeneratorTargetToUse(depName);
|
||||
if (!depTarget) {
|
||||
cmGlobalGenerator* gg = lg->GetGlobalGenerator();
|
||||
BuildDependencies::FileDependency file;
|
||||
file.Path = lg->GetRealFileDependency(depName);
|
||||
file.Owner = gg->FindOutputOwningTarget(file.Path);
|
||||
file.Generated = gg->IsGeneratedByBuild(file.Path);
|
||||
info.Files.push_back(std::move(file));
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
dependencies.insert(depTarget);
|
||||
};
|
||||
for (std::string const& depName : buildDepends) {
|
||||
if (depName.empty()) {
|
||||
continue;
|
||||
}
|
||||
addBuildDependency(depName);
|
||||
}
|
||||
|
||||
for (cmGeneratorTarget* gt : dependencies) {
|
||||
|
||||
Reference in new issue
Block a user