summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-04-04 13:32:44 (GMT)
committerKitware Robot <kwrobot@kitware.com>2022-04-04 13:32:52 (GMT)
commit1dbd4e9a4159b1a7f10d4bc70818ea1827a7c3e1 (patch)
treedadc6866f180486b930a9c91ee408f7eedb76ccd /Source
parentbcc3584912db48ba41112eabcd7a4b95fdf48265 (diff)
parent6d34cc3cb8062647030df9bf7a890615844d3d8f (diff)
downloadCMake-1dbd4e9a4159b1a7f10d4bc70818ea1827a7c3e1.zip
CMake-1dbd4e9a4159b1a7f10d4bc70818ea1827a7c3e1.tar.gz
CMake-1dbd4e9a4159b1a7f10d4bc70818ea1827a7c3e1.tar.bz2
Merge topic 'export-out-of-dir-TARGET_NAME'
6d34cc3cb8 export: Fix TARGET_NAME lookup for out-of-dir linking Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !7136
Diffstat (limited to 'Source')
-rw-r--r--Source/cmExportFileGenerator.cxx28
-rw-r--r--Source/cmExportFileGenerator.h4
-rw-r--r--Source/cmGeneratorTarget.h6
3 files changed, 22 insertions, 16 deletions
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index a21e614..dc94e76 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -16,7 +16,6 @@
#include "cmFileSet.h"
#include "cmGeneratedFileStream.h"
#include "cmGeneratorTarget.h"
-#include "cmGlobalGenerator.h"
#include "cmLinkItem.h"
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
@@ -607,10 +606,10 @@ void cmExportFileGenerator::GenerateInterfaceProperties(
bool cmExportFileGenerator::AddTargetNamespace(
std::string& input, cmGeneratorTarget const* target,
- std::vector<std::string>& missingTargets)
+ cmLocalGenerator const* lg, std::vector<std::string>& missingTargets)
{
cmGeneratorTarget::TargetOrString resolved =
- target->ResolveTargetReference(input);
+ target->ResolveTargetReference(input, lg);
cmGeneratorTarget* tgt = resolved.Target;
if (!tgt) {
@@ -640,8 +639,10 @@ void cmExportFileGenerator::ResolveTargetsInGeneratorExpressions(
std::string& input, cmGeneratorTarget const* target,
std::vector<std::string>& missingTargets, FreeTargetsReplace replace)
{
+ cmLocalGenerator const* lg = target->GetLocalGenerator();
if (replace == NoReplaceFreeTargets) {
- this->ResolveTargetsInGeneratorExpression(input, target, missingTargets);
+ this->ResolveTargetsInGeneratorExpression(input, target, lg,
+ missingTargets);
return;
}
std::vector<std::string> parts;
@@ -650,13 +651,14 @@ void cmExportFileGenerator::ResolveTargetsInGeneratorExpressions(
std::string sep;
input.clear();
for (std::string& li : parts) {
- if (cmHasLiteralPrefix(li, CMAKE_DIRECTORY_ID_SEP)) {
+ if (target->IsLinkLookupScope(li, lg)) {
continue;
}
if (cmGeneratorExpression::Find(li) == std::string::npos) {
- this->AddTargetNamespace(li, target, missingTargets);
+ this->AddTargetNamespace(li, target, lg, missingTargets);
} else {
- this->ResolveTargetsInGeneratorExpression(li, target, missingTargets);
+ this->ResolveTargetsInGeneratorExpression(li, target, lg,
+ missingTargets);
}
input += sep + li;
sep = ";";
@@ -665,7 +667,7 @@ void cmExportFileGenerator::ResolveTargetsInGeneratorExpressions(
void cmExportFileGenerator::ResolveTargetsInGeneratorExpression(
std::string& input, cmGeneratorTarget const* target,
- std::vector<std::string>& missingTargets)
+ cmLocalGenerator const* lg, std::vector<std::string>& missingTargets)
{
std::string::size_type pos = 0;
std::string::size_type lastPos = pos;
@@ -689,7 +691,7 @@ void cmExportFileGenerator::ResolveTargetsInGeneratorExpression(
std::string targetName =
input.substr(nameStartPos, commaPos - nameStartPos);
- if (this->AddTargetNamespace(targetName, target, missingTargets)) {
+ if (this->AddTargetNamespace(targetName, target, lg, missingTargets)) {
input.replace(nameStartPos, commaPos - nameStartPos, targetName);
}
lastPos = nameStartPos + targetName.size() + 1;
@@ -711,7 +713,7 @@ void cmExportFileGenerator::ResolveTargetsInGeneratorExpression(
"literal.";
break;
}
- if (!this->AddTargetNamespace(targetName, target, missingTargets)) {
+ if (!this->AddTargetNamespace(targetName, target, lg, missingTargets)) {
errorString = "$<TARGET_NAME:...> requires its parameter to be a "
"reachable target.";
break;
@@ -732,7 +734,7 @@ void cmExportFileGenerator::ResolveTargetsInGeneratorExpression(
}
std::string libName = input.substr(nameStartPos, endPos - nameStartPos);
if (cmGeneratorExpression::IsValidTargetName(libName) &&
- this->AddTargetNamespace(libName, target, missingTargets)) {
+ this->AddTargetNamespace(libName, target, lg, missingTargets)) {
input.replace(nameStartPos, endPos - nameStartPos, libName);
}
lastPos = nameStartPos + libName.size() + 1;
@@ -900,6 +902,8 @@ void cmExportFileGenerator::SetImportLinkProperty(
return;
}
+ cmLocalGenerator const* lg = target->GetLocalGenerator();
+
// Construct the property value.
std::string link_entries;
const char* sep = "";
@@ -910,7 +914,7 @@ void cmExportFileGenerator::SetImportLinkProperty(
if (targetNames == ImportLinkPropertyTargetNames::Yes) {
std::string temp = asString(l);
- this->AddTargetNamespace(temp, target, missingTargets);
+ this->AddTargetNamespace(temp, target, lg, missingTargets);
link_entries += temp;
} else {
link_entries += asString(l);
diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h
index d50f7e8..bde6f1b 100644
--- a/Source/cmExportFileGenerator.h
+++ b/Source/cmExportFileGenerator.h
@@ -17,6 +17,7 @@
class cmFileSet;
class cmGeneratorTarget;
+class cmLocalGenerator;
class cmTargetExport;
#define STRINGIFY_HELPER(X) #X
@@ -223,11 +224,12 @@ private:
std::vector<std::string>& missingTargets);
bool AddTargetNamespace(std::string& input, cmGeneratorTarget const* target,
+ cmLocalGenerator const* lg,
std::vector<std::string>& missingTargets);
void ResolveTargetsInGeneratorExpression(
std::string& input, cmGeneratorTarget const* target,
- std::vector<std::string>& missingTargets);
+ cmLocalGenerator const* lg, std::vector<std::string>& missingTargets);
virtual void ReplaceInstallPrefix(std::string& input);
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index 53844ae..b927848 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -856,6 +856,9 @@ public:
std::string GetFortranModuleDirectory(std::string const& working_dir) const;
bool IsFortranBuildingInstrinsicModules() const;
+ bool IsLinkLookupScope(std::string const& n,
+ cmLocalGenerator const*& lg) const;
+
cmValue GetSourcesProperty() const;
void AddISPCGeneratedHeader(std::string const& header,
@@ -1073,9 +1076,6 @@ private:
std::unordered_map<std::string, std::vector<std::string>>
ISPCGeneratedObjects;
- bool IsLinkLookupScope(std::string const& n,
- cmLocalGenerator const*& lg) const;
-
enum class LinkInterfaceField
{
Libraries,