summaryrefslogtreecommitdiffstats
path: root/Source/cmExportFileGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-04-11 15:06:28 (GMT)
committerBrad King <brad.king@kitware.com>2022-04-11 17:40:13 (GMT)
commit8c65b7042e0e7bca3dc5c0cda8975fd2e9c6dc51 (patch)
tree340fba27fb9bd49f82197ba477939a2ee9bfcd2e /Source/cmExportFileGenerator.cxx
parent7fc248bde34c529c6f1312a56c7e82303238b9c1 (diff)
downloadCMake-8c65b7042e0e7bca3dc5c0cda8975fd2e9c6dc51.zip
CMake-8c65b7042e0e7bca3dc5c0cda8975fd2e9c6dc51.tar.gz
CMake-8c65b7042e0e7bca3dc5c0cda8975fd2e9c6dc51.tar.bz2
cmExportFileGenerator: Simplify collection of targets missing from export set
Store the list of missing target names in a member instead of threading an explicit reference to it through the call stack.
Diffstat (limited to 'Source/cmExportFileGenerator.cxx')
-rw-r--r--Source/cmExportFileGenerator.cxx92
1 files changed, 41 insertions, 51 deletions
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index dc94e76..6d6df71 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -106,9 +106,8 @@ bool cmExportFileGenerator::GenerateImportFile()
return result;
}
-void cmExportFileGenerator::GenerateImportConfig(
- std::ostream& os, const std::string& config,
- std::vector<std::string>& missingTargets)
+void cmExportFileGenerator::GenerateImportConfig(std::ostream& os,
+ const std::string& config)
{
// Construct the property configuration suffix.
std::string suffix = "_";
@@ -119,7 +118,7 @@ void cmExportFileGenerator::GenerateImportConfig(
}
// Generate the per-config target information.
- this->GenerateImportTargetsConfig(os, config, suffix, missingTargets);
+ this->GenerateImportTargetsConfig(os, config, suffix);
}
void cmExportFileGenerator::PopulateInterfaceProperty(
@@ -136,7 +135,7 @@ void cmExportFileGenerator::PopulateInterfaceProperty(
const std::string& propName, const std::string& outputName,
cmGeneratorTarget const* target,
cmGeneratorExpression::PreprocessContext preprocessRule,
- ImportPropertyMap& properties, std::vector<std::string>& missingTargets)
+ ImportPropertyMap& properties)
{
cmValue input = target->GetProperty(propName);
if (input) {
@@ -149,8 +148,7 @@ void cmExportFileGenerator::PopulateInterfaceProperty(
std::string prepro =
cmGeneratorExpression::Preprocess(*input, preprocessRule);
if (!prepro.empty()) {
- this->ResolveTargetsInGeneratorExpressions(prepro, target,
- missingTargets);
+ this->ResolveTargetsInGeneratorExpressions(prepro, target);
properties[outputName] = prepro;
}
}
@@ -170,7 +168,7 @@ void cmExportFileGenerator::GenerateRequiredCMakeVersion(
bool cmExportFileGenerator::PopulateInterfaceLinkLibrariesProperty(
cmGeneratorTarget const* target,
cmGeneratorExpression::PreprocessContext preprocessRule,
- ImportPropertyMap& properties, std::vector<std::string>& missingTargets)
+ ImportPropertyMap& properties)
{
if (!target->IsLinkable()) {
return false;
@@ -185,8 +183,8 @@ bool cmExportFileGenerator::PopulateInterfaceLinkLibrariesProperty(
std::string prepro =
cmGeneratorExpression::Preprocess(*input, preprocessRule);
if (!prepro.empty()) {
- this->ResolveTargetsInGeneratorExpressions(
- prepro, target, missingTargets, ReplaceFreeTargets);
+ this->ResolveTargetsInGeneratorExpressions(prepro, target,
+ ReplaceFreeTargets);
properties[linkIfaceProp] = prepro;
hadINTERFACE_LINK_LIBRARIES = true;
}
@@ -343,7 +341,7 @@ static void prefixItems(std::string& exportDirs)
void cmExportFileGenerator::PopulateSourcesInterface(
cmGeneratorTarget const* gt,
cmGeneratorExpression::PreprocessContext preprocessRule,
- ImportPropertyMap& properties, std::vector<std::string>& missingTargets)
+ ImportPropertyMap& properties)
{
assert(preprocessRule == cmGeneratorExpression::InstallInterface);
@@ -362,7 +360,7 @@ void cmExportFileGenerator::PopulateSourcesInterface(
std::string prepro =
cmGeneratorExpression::Preprocess(*input, preprocessRule, true);
if (!prepro.empty()) {
- this->ResolveTargetsInGeneratorExpressions(prepro, gt, missingTargets);
+ this->ResolveTargetsInGeneratorExpressions(prepro, gt);
if (!checkInterfaceDirs(prepro, gt, propName)) {
return;
@@ -374,8 +372,7 @@ void cmExportFileGenerator::PopulateSourcesInterface(
void cmExportFileGenerator::PopulateIncludeDirectoriesInterface(
cmGeneratorTarget const* target,
cmGeneratorExpression::PreprocessContext preprocessRule,
- ImportPropertyMap& properties, std::vector<std::string>& missingTargets,
- cmTargetExport const& te)
+ ImportPropertyMap& properties, cmTargetExport const& te)
{
assert(preprocessRule == cmGeneratorExpression::InstallInterface);
@@ -422,7 +419,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface(
std::string prepro =
cmGeneratorExpression::Preprocess(includes, preprocessRule, true);
if (!prepro.empty()) {
- this->ResolveTargetsInGeneratorExpressions(prepro, target, missingTargets);
+ this->ResolveTargetsInGeneratorExpressions(prepro, target);
if (!checkInterfaceDirs(prepro, target, propName)) {
return;
@@ -434,7 +431,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface(
void cmExportFileGenerator::PopulateLinkDependsInterface(
cmGeneratorTarget const* gt,
cmGeneratorExpression::PreprocessContext preprocessRule,
- ImportPropertyMap& properties, std::vector<std::string>& missingTargets)
+ ImportPropertyMap& properties)
{
assert(preprocessRule == cmGeneratorExpression::InstallInterface);
@@ -453,7 +450,7 @@ void cmExportFileGenerator::PopulateLinkDependsInterface(
std::string prepro =
cmGeneratorExpression::Preprocess(*input, preprocessRule, true);
if (!prepro.empty()) {
- this->ResolveTargetsInGeneratorExpressions(prepro, gt, missingTargets);
+ this->ResolveTargetsInGeneratorExpressions(prepro, gt);
if (!checkInterfaceDirs(prepro, gt, propName)) {
return;
@@ -465,7 +462,7 @@ void cmExportFileGenerator::PopulateLinkDependsInterface(
void cmExportFileGenerator::PopulateLinkDirectoriesInterface(
cmGeneratorTarget const* gt,
cmGeneratorExpression::PreprocessContext preprocessRule,
- ImportPropertyMap& properties, std::vector<std::string>& missingTargets)
+ ImportPropertyMap& properties)
{
assert(preprocessRule == cmGeneratorExpression::InstallInterface);
@@ -484,7 +481,7 @@ void cmExportFileGenerator::PopulateLinkDirectoriesInterface(
std::string prepro =
cmGeneratorExpression::Preprocess(*input, preprocessRule, true);
if (!prepro.empty()) {
- this->ResolveTargetsInGeneratorExpressions(prepro, gt, missingTargets);
+ this->ResolveTargetsInGeneratorExpressions(prepro, gt);
if (!checkInterfaceDirs(prepro, gt, propName)) {
return;
@@ -496,10 +493,10 @@ void cmExportFileGenerator::PopulateLinkDirectoriesInterface(
void cmExportFileGenerator::PopulateInterfaceProperty(
const std::string& propName, cmGeneratorTarget const* target,
cmGeneratorExpression::PreprocessContext preprocessRule,
- ImportPropertyMap& properties, std::vector<std::string>& missingTargets)
+ ImportPropertyMap& properties)
{
this->PopulateInterfaceProperty(propName, propName, target, preprocessRule,
- properties, missingTargets);
+ properties);
}
static void getPropertyContents(cmGeneratorTarget const* tgt,
@@ -604,9 +601,9 @@ void cmExportFileGenerator::GenerateInterfaceProperties(
}
}
-bool cmExportFileGenerator::AddTargetNamespace(
- std::string& input, cmGeneratorTarget const* target,
- cmLocalGenerator const* lg, std::vector<std::string>& missingTargets)
+bool cmExportFileGenerator::AddTargetNamespace(std::string& input,
+ cmGeneratorTarget const* target,
+ cmLocalGenerator const* lg)
{
cmGeneratorTarget::TargetOrString resolved =
target->ResolveTargetReference(input, lg);
@@ -625,7 +622,7 @@ bool cmExportFileGenerator::AddTargetNamespace(
input = this->Namespace + tgt->GetExportName();
} else {
std::string namespacedTarget;
- this->HandleMissingTarget(namespacedTarget, missingTargets, target, tgt);
+ this->HandleMissingTarget(namespacedTarget, target, tgt);
if (!namespacedTarget.empty()) {
input = namespacedTarget;
} else {
@@ -637,12 +634,11 @@ bool cmExportFileGenerator::AddTargetNamespace(
void cmExportFileGenerator::ResolveTargetsInGeneratorExpressions(
std::string& input, cmGeneratorTarget const* target,
- std::vector<std::string>& missingTargets, FreeTargetsReplace replace)
+ FreeTargetsReplace replace)
{
cmLocalGenerator const* lg = target->GetLocalGenerator();
if (replace == NoReplaceFreeTargets) {
- this->ResolveTargetsInGeneratorExpression(input, target, lg,
- missingTargets);
+ this->ResolveTargetsInGeneratorExpression(input, target, lg);
return;
}
std::vector<std::string> parts;
@@ -655,10 +651,9 @@ void cmExportFileGenerator::ResolveTargetsInGeneratorExpressions(
continue;
}
if (cmGeneratorExpression::Find(li) == std::string::npos) {
- this->AddTargetNamespace(li, target, lg, missingTargets);
+ this->AddTargetNamespace(li, target, lg);
} else {
- this->ResolveTargetsInGeneratorExpression(li, target, lg,
- missingTargets);
+ this->ResolveTargetsInGeneratorExpression(li, target, lg);
}
input += sep + li;
sep = ";";
@@ -667,7 +662,7 @@ void cmExportFileGenerator::ResolveTargetsInGeneratorExpressions(
void cmExportFileGenerator::ResolveTargetsInGeneratorExpression(
std::string& input, cmGeneratorTarget const* target,
- cmLocalGenerator const* lg, std::vector<std::string>& missingTargets)
+ cmLocalGenerator const* lg)
{
std::string::size_type pos = 0;
std::string::size_type lastPos = pos;
@@ -691,7 +686,7 @@ void cmExportFileGenerator::ResolveTargetsInGeneratorExpression(
std::string targetName =
input.substr(nameStartPos, commaPos - nameStartPos);
- if (this->AddTargetNamespace(targetName, target, lg, missingTargets)) {
+ if (this->AddTargetNamespace(targetName, target, lg)) {
input.replace(nameStartPos, commaPos - nameStartPos, targetName);
}
lastPos = nameStartPos + targetName.size() + 1;
@@ -713,7 +708,7 @@ void cmExportFileGenerator::ResolveTargetsInGeneratorExpression(
"literal.";
break;
}
- if (!this->AddTargetNamespace(targetName, target, lg, missingTargets)) {
+ if (!this->AddTargetNamespace(targetName, target, lg)) {
errorString = "$<TARGET_NAME:...> requires its parameter to be a "
"reachable target.";
break;
@@ -734,7 +729,7 @@ void cmExportFileGenerator::ResolveTargetsInGeneratorExpression(
}
std::string libName = input.substr(nameStartPos, endPos - nameStartPos);
if (cmGeneratorExpression::IsValidTargetName(libName) &&
- this->AddTargetNamespace(libName, target, lg, missingTargets)) {
+ this->AddTargetNamespace(libName, target, lg)) {
input.replace(nameStartPos, endPos - nameStartPos, libName);
}
lastPos = nameStartPos + libName.size() + 1;
@@ -756,8 +751,7 @@ void cmExportFileGenerator::ReplaceInstallPrefix(std::string& /*unused*/)
void cmExportFileGenerator::SetImportLinkInterface(
const std::string& config, std::string const& suffix,
cmGeneratorExpression::PreprocessContext preprocessRule,
- cmGeneratorTarget const* target, ImportPropertyMap& properties,
- std::vector<std::string>& missingTargets)
+ cmGeneratorTarget const* target, ImportPropertyMap& properties)
{
// Add the transitive link dependencies for this configuration.
cmLinkInterface const* iface = target->GetLinkInterface(config, target);
@@ -769,7 +763,7 @@ void cmExportFileGenerator::SetImportLinkInterface(
// Policy CMP0022 must not be NEW.
this->SetImportLinkProperty(
suffix, target, "IMPORTED_LINK_INTERFACE_LIBRARIES", iface->Libraries,
- properties, missingTargets, ImportLinkPropertyTargetNames::Yes);
+ properties, ImportLinkPropertyTargetNames::Yes);
return;
}
@@ -808,7 +802,7 @@ void cmExportFileGenerator::SetImportLinkInterface(
std::string prepro =
cmGeneratorExpression::Preprocess(*propContent, preprocessRule);
if (!prepro.empty()) {
- this->ResolveTargetsInGeneratorExpressions(prepro, target, missingTargets,
+ this->ResolveTargetsInGeneratorExpressions(prepro, target,
ReplaceFreeTargets);
properties["IMPORTED_LINK_INTERFACE_LIBRARIES" + suffix] = prepro;
}
@@ -816,8 +810,7 @@ void cmExportFileGenerator::SetImportLinkInterface(
void cmExportFileGenerator::SetImportDetailProperties(
const std::string& config, std::string const& suffix,
- cmGeneratorTarget* target, ImportPropertyMap& properties,
- std::vector<std::string>& missingTargets)
+ cmGeneratorTarget* target, ImportPropertyMap& properties)
{
// Get the makefile in which to lookup target information.
cmMakefile* mf = target->Makefile;
@@ -848,12 +841,11 @@ void cmExportFileGenerator::SetImportDetailProperties(
target->GetLinkInterface(config, target)) {
this->SetImportLinkProperty(
suffix, target, "IMPORTED_LINK_INTERFACE_LANGUAGES", iface->Languages,
- properties, missingTargets, ImportLinkPropertyTargetNames::No);
+ properties, ImportLinkPropertyTargetNames::No);
- std::vector<std::string> dummy;
this->SetImportLinkProperty(
suffix, target, "IMPORTED_LINK_DEPENDENT_LIBRARIES", iface->SharedDeps,
- properties, dummy, ImportLinkPropertyTargetNames::Yes);
+ properties, ImportLinkPropertyTargetNames::Yes);
if (iface->Multiplicity > 0) {
std::string prop =
cmStrCat("IMPORTED_LINK_INTERFACE_MULTIPLICITY", suffix);
@@ -894,8 +886,7 @@ template <typename T>
void cmExportFileGenerator::SetImportLinkProperty(
std::string const& suffix, cmGeneratorTarget const* target,
const std::string& propName, std::vector<T> const& entries,
- ImportPropertyMap& properties, std::vector<std::string>& missingTargets,
- ImportLinkPropertyTargetNames targetNames)
+ ImportPropertyMap& properties, ImportLinkPropertyTargetNames targetNames)
{
// Skip the property if there are no entries.
if (entries.empty()) {
@@ -914,7 +905,7 @@ void cmExportFileGenerator::SetImportLinkProperty(
if (targetNames == ImportLinkPropertyTargetNames::Yes) {
std::string temp = asString(l);
- this->AddTargetNamespace(temp, target, lg, missingTargets);
+ this->AddTargetNamespace(temp, target, lg);
link_entries += temp;
} else {
link_entries += asString(l);
@@ -1124,10 +1115,9 @@ void cmExportFileGenerator::GenerateImportPropertyCode(
<< "\n";
}
-void cmExportFileGenerator::GenerateMissingTargetsCheckCode(
- std::ostream& os, const std::vector<std::string>& missingTargets)
+void cmExportFileGenerator::GenerateMissingTargetsCheckCode(std::ostream& os)
{
- if (missingTargets.empty()) {
+ if (this->MissingTargets.empty()) {
/* clang-format off */
os << "# This file does not depend on other imported targets which have\n"
"# been exported from the same project but in a separate "
@@ -1142,7 +1132,7 @@ void cmExportFileGenerator::GenerateMissingTargetsCheckCode(
"foreach(_target ";
/* clang-format on */
std::set<std::string> emitted;
- for (std::string const& missingTarget : missingTargets) {
+ for (std::string const& missingTarget : this->MissingTargets) {
if (emitted.insert(missingTarget).second) {
os << "\"" << missingTarget << "\" ";
}