summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/cmAddExecutableCommand.cxx11
-rw-r--r--Source/cmAddLibraryCommand.cxx11
-rw-r--r--Source/cmGeneratorExpressionNode.cxx8
-rw-r--r--Source/cmGetPropertyCommand.cxx16
-rw-r--r--Source/cmGetTargetPropertyCommand.cxx12
-rw-r--r--Source/cmLocalGenerator.cxx25
-rw-r--r--Source/cmMakefile.cxx17
-rw-r--r--Source/cmMakefile.h3
8 files changed, 71 insertions, 32 deletions
diff --git a/Source/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx
index e738bc4..9dd8a19 100644
--- a/Source/cmAddExecutableCommand.cxx
+++ b/Source/cmAddExecutableCommand.cxx
@@ -117,14 +117,9 @@ bool cmAddExecutableCommand(std::vector<std::string> const& args,
"\" is not an executable."));
return false;
}
- if (aliasedTarget->IsImported() &&
- !aliasedTarget->IsImportedGloballyVisible()) {
- status.SetError(cmStrCat("cannot create ALIAS target \"", exename,
- "\" because target \"", aliasedName,
- "\" is imported but not globally visible."));
- return false;
- }
- mf.AddAlias(exename, aliasedName);
+ mf.AddAlias(exename, aliasedName,
+ !aliasedTarget->IsImported() ||
+ aliasedTarget->IsImportedGloballyVisible());
return true;
}
diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx
index d79c04f..3e5d764 100644
--- a/Source/cmAddLibraryCommand.cxx
+++ b/Source/cmAddLibraryCommand.cxx
@@ -219,14 +219,9 @@ bool cmAddLibraryCommand(std::vector<std::string> const& args,
"\" is not a library."));
return false;
}
- if (aliasedTarget->IsImported() &&
- !aliasedTarget->IsImportedGloballyVisible()) {
- status.SetError(cmStrCat("cannot create ALIAS target \"", libName,
- "\" because target \"", aliasedName,
- "\" is imported but not globally visible."));
- return false;
- }
- mf.AddAlias(libName, aliasedName);
+ mf.AddAlias(libName, aliasedName,
+ !aliasedTarget->IsImported() ||
+ aliasedTarget->IsImportedGloballyVisible());
return true;
}
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx
index 906df2b..e4fb67e 100644
--- a/Source/cmGeneratorExpressionNode.cxx
+++ b/Source/cmGeneratorExpressionNode.cxx
@@ -1342,6 +1342,14 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
}
return std::string();
}
+ if (propertyName == "ALIAS_GLOBAL"_s) {
+ if (context->LG->GetMakefile()->IsAlias(targetName)) {
+ return context->LG->GetGlobalGenerator()->IsAlias(targetName)
+ ? "TRUE"
+ : "FALSE";
+ }
+ return std::string();
+ }
target = context->LG->FindGeneratorTargetToUse(targetName);
if (!target) {
diff --git a/Source/cmGetPropertyCommand.cxx b/Source/cmGetPropertyCommand.cxx
index 851f426..cba7704 100644
--- a/Source/cmGetPropertyCommand.cxx
+++ b/Source/cmGetPropertyCommand.cxx
@@ -344,10 +344,20 @@ bool HandleTargetMode(cmExecutionStatus& status, const std::string& name,
}
if (cmTarget* target = status.GetMakefile().FindTargetToUse(name)) {
- if (propertyName == "ALIASED_TARGET") {
+ if (propertyName == "ALIASED_TARGET" || propertyName == "ALIAS_GLOBAL") {
if (status.GetMakefile().IsAlias(name)) {
- return StoreResult(infoType, status.GetMakefile(), variable,
- target->GetName().c_str());
+ if (propertyName == "ALIASED_TARGET") {
+
+ return StoreResult(infoType, status.GetMakefile(), variable,
+ target->GetName().c_str());
+ }
+ if (propertyName == "ALIAS_GLOBAL") {
+ return StoreResult(
+ infoType, status.GetMakefile(), variable,
+ status.GetMakefile().GetGlobalGenerator()->IsAlias(name)
+ ? "TRUE"
+ : "FALSE");
+ }
}
return StoreResult(infoType, status.GetMakefile(), variable, nullptr);
}
diff --git a/Source/cmGetTargetPropertyCommand.cxx b/Source/cmGetTargetPropertyCommand.cxx
index e5a3669..8a304be 100644
--- a/Source/cmGetTargetPropertyCommand.cxx
+++ b/Source/cmGetTargetPropertyCommand.cxx
@@ -5,6 +5,7 @@
#include <sstream>
#include "cmExecutionStatus.h"
+#include "cmGlobalGenerator.h"
#include "cmListFileCache.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
@@ -29,10 +30,17 @@ bool cmGetTargetPropertyCommand(std::vector<std::string> const& args,
cmMakefile& mf = status.GetMakefile();
if (cmTarget* tgt = mf.FindTargetToUse(targetName)) {
- if (args[2] == "ALIASED_TARGET") {
+ if (args[2] == "ALIASED_TARGET" || args[2] == "ALIAS_GLOBAL") {
if (mf.IsAlias(targetName)) {
- prop = tgt->GetName();
prop_exists = true;
+ if (args[2] == "ALIASED_TARGET") {
+
+ prop = tgt->GetName();
+ }
+ if (args[2] == "ALIAS_GLOBAL") {
+ prop =
+ mf.GetGlobalGenerator()->IsAlias(targetName) ? "TRUE" : "FALSE";
+ }
}
} else if (!args[2].empty()) {
cmProp prop_cstr = nullptr;
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 3fca2d4..f299202 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -2049,6 +2049,15 @@ cmGeneratorTarget* cmLocalGenerator::FindGeneratorTargetToUse(
return imported->second;
}
+ // find local alias to imported target
+ auto aliased = this->AliasTargets.find(name);
+ if (aliased != this->AliasTargets.end()) {
+ imported = this->ImportedGeneratorTargets.find(aliased->second);
+ if (imported != this->ImportedGeneratorTargets.end()) {
+ return imported->second;
+ }
+ }
+
if (cmGeneratorTarget* t = this->FindLocalNonAliasGeneratorTarget(name)) {
return t;
}
@@ -2468,7 +2477,8 @@ bool cmLocalGenerator::GetShouldUseOldFlags(bool shared,
std::ostringstream e;
e << "Variable " << flagsVar
<< " has been modified. CMake "
- "will ignore the POSITION_INDEPENDENT_CODE target property for "
+ "will ignore the POSITION_INDEPENDENT_CODE target property "
+ "for "
"shared libraries and will use the "
<< flagsVar
<< " variable "
@@ -2565,7 +2575,8 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target)
}
for (std::string const& config : configsList) {
- // FIXME: Refactor collection of sources to not evaluate object libraries.
+ // FIXME: Refactor collection of sources to not evaluate object
+ // libraries.
std::vector<cmSourceFile*> sources;
target->GetSourceFiles(sources, config);
@@ -3270,8 +3281,8 @@ const char* cmLocalGenerator::GetFeature(const std::string& feature,
const std::string& config)
{
std::string featureName = feature;
- // TODO: Define accumulation policy for features (prepend, append, replace).
- // Currently we always replace.
+ // TODO: Define accumulation policy for features (prepend, append,
+ // replace). Currently we always replace.
if (!config.empty()) {
featureName += "_";
featureName += cmSystemTools::UpperCase(config);
@@ -4120,9 +4131,9 @@ void AddUtilityCommand(cmLocalGenerator& lg, const cmListFileBacktrace& lfbt,
cmImplicitDependsList no_implicit_depends;
cmSourceFile* rule = AddCustomCommand(
lg, lfbt, { force.Name }, byproducts, depends, no_main_dependency,
- no_implicit_depends, commandLines, comment, workingDir, /*replace=*/false,
- escapeOldStyle, uses_terminal, command_expand_lists, /*depfile=*/"",
- job_pool, stdPipesUTF8);
+ no_implicit_depends, commandLines, comment, workingDir,
+ /*replace=*/false, escapeOldStyle, uses_terminal, command_expand_lists,
+ /*depfile=*/"", job_pool, stdPipesUTF8);
if (rule) {
lg.GetMakefile()->AddTargetByproducts(target, byproducts);
}
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index c527a49..c78b751 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -2035,10 +2035,13 @@ void cmMakefile::AddGlobalLinkInformation(cmTarget& target)
}
}
-void cmMakefile::AddAlias(const std::string& lname, std::string const& tgtName)
+void cmMakefile::AddAlias(const std::string& lname, std::string const& tgtName,
+ bool globallyVisible)
{
this->AliasTargets[lname] = tgtName;
- this->GetGlobalGenerator()->AddAlias(lname, tgtName);
+ if (globallyVisible) {
+ this->GetGlobalGenerator()->AddAlias(lname, tgtName);
+ }
}
cmTarget* cmMakefile::AddLibrary(const std::string& lname,
@@ -4286,7 +4289,15 @@ cmTarget* cmMakefile::FindTargetToUse(const std::string& name,
{
// Look for an imported target. These take priority because they
// are more local in scope and do not have to be globally unique.
- auto imported = this->ImportedTargets.find(name);
+ auto targetName = name;
+ if (!excludeAliases) {
+ // Look for local alias targets.
+ auto alias = this->AliasTargets.find(name);
+ if (alias != this->AliasTargets.end()) {
+ targetName = alias->second;
+ }
+ }
+ auto imported = this->ImportedTargets.find(targetName);
if (imported != this->ImportedTargets.end()) {
return imported->second;
}
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 8dfa5b0..45d7109 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -356,7 +356,8 @@ public:
cmStateEnums::TargetType type,
const std::vector<std::string>& srcs,
bool excludeFromAll = false);
- void AddAlias(const std::string& libname, const std::string& tgt);
+ void AddAlias(const std::string& libname, const std::string& tgt,
+ bool globallyVisible = true);
//@{
/**