summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-11-08 14:08:08 (GMT)
committerKitware Robot <kwrobot@kitware.com>2017-11-08 14:08:15 (GMT)
commit30fcf13be6680d6a4eb112f98cc2d99c6881f401 (patch)
treef967b05d19f98294a6147adf67bcb060a744ac32 /Source
parent9f30cd13dad63b2a327162285711cd36dcc20b92 (diff)
parent6a3922bebea607dcc23944b1fe79b7b613a893d1 (diff)
downloadCMake-30fcf13be6680d6a4eb112f98cc2d99c6881f401.zip
CMake-30fcf13be6680d6a4eb112f98cc2d99c6881f401.tar.gz
CMake-30fcf13be6680d6a4eb112f98cc2d99c6881f401.tar.bz2
Merge topic 'imported-promotion'
6a3922be Add new target-property `IMPORTED_GLOBAL`. 854e482a cmTarget: Simplified and fixed a string-comparision. Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !1254
Diffstat (limited to 'Source')
-rw-r--r--Source/cmTarget.cxx55
-rw-r--r--Source/cmTargetPropertyComputer.cxx1
2 files changed, 55 insertions, 1 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index c6cd502..9cf835c 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -884,6 +884,13 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
return;
}
+ if (prop == "IMPORTED_GLOBAL" && !this->IsImported()) {
+ std::ostringstream e;
+ e << "IMPORTED_GLOBAL property can't be set on non-imported targets (\""
+ << this->Name << "\")\n";
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ return;
+ }
if (prop == "INCLUDE_DIRECTORIES") {
this->Internal->IncludeDirectoriesEntries.clear();
@@ -933,6 +940,19 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
this->Internal->SourceEntries.push_back(value);
this->Internal->SourceBacktraces.push_back(lfbt);
}
+ } else if (prop == "IMPORTED_GLOBAL") {
+ if (!cmSystemTools::IsOn(value)) {
+ std::ostringstream e;
+ e << "IMPORTED_GLOBAL property can't be set to FALSE on targets (\""
+ << this->Name << "\")\n";
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ return;
+ }
+ /* no need to change anything if value does not change */
+ if (!this->ImportedGloballyVisible) {
+ this->ImportedGloballyVisible = true;
+ this->GetGlobalGenerator()->IndexTarget(this);
+ }
} else if (cmHasLiteralPrefix(prop, "IMPORTED_LIBNAME") &&
!this->CheckImportedLibName(prop, value ? value : "")) {
/* error was reported by check method */
@@ -977,6 +997,14 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value,
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
return;
}
+ if (prop == "IMPORTED_GLOBAL") {
+ std::ostringstream e;
+ e << "IMPORTED_GLOBAL property can't be appended, only set on imported "
+ "targets (\""
+ << this->Name << "\")\n";
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ return;
+ }
if (prop == "INCLUDE_DIRECTORIES") {
if (value && *value) {
this->Internal->IncludeDirectoriesEntries.push_back(value);
@@ -1143,6 +1171,21 @@ static void cmTargetCheckINTERFACE_LINK_LIBRARIES(const char* value,
context->IssueMessage(cmake::FATAL_ERROR, e.str());
}
+static void cmTargetCheckIMPORTED_GLOBAL(const cmTarget* target,
+ cmMakefile* context)
+{
+ std::vector<cmTarget*> targets = context->GetOwnedImportedTargets();
+ std::vector<cmTarget*>::const_iterator it =
+ std::find(targets.begin(), targets.end(), target);
+ if (it == targets.end()) {
+ std::ostringstream e;
+ e << "Attempt to promote imported target \"" << target->GetName()
+ << "\" to global scope (by setting IMPORTED_GLOBAL) "
+ "which is not built in this directory.";
+ context->IssueMessage(cmake::FATAL_ERROR, e.str());
+ }
+}
+
void cmTarget::CheckProperty(const std::string& prop,
cmMakefile* context) const
{
@@ -1157,11 +1200,16 @@ void cmTarget::CheckProperty(const std::string& prop,
cmTargetCheckLINK_INTERFACE_LIBRARIES(prop, value, context, true);
}
}
- if (cmHasLiteralPrefix(prop, "INTERFACE_LINK_LIBRARIES")) {
+ if (prop == "INTERFACE_LINK_LIBRARIES") {
if (const char* value = this->GetProperty(prop)) {
cmTargetCheckINTERFACE_LINK_LIBRARIES(value, context);
}
}
+ if (prop == "IMPORTED_GLOBAL") {
+ if (this->IsImported()) {
+ cmTargetCheckIMPORTED_GLOBAL(this, context);
+ }
+ }
}
const char* cmTarget::GetComputedProperty(
@@ -1182,6 +1230,7 @@ const char* cmTarget::GetProperty(const std::string& prop) const
MAKE_STATIC_PROP(COMPILE_OPTIONS);
MAKE_STATIC_PROP(COMPILE_DEFINITIONS);
MAKE_STATIC_PROP(IMPORTED);
+ MAKE_STATIC_PROP(IMPORTED_GLOBAL);
MAKE_STATIC_PROP(MANUALLY_ADDED_DEPENDENCIES);
MAKE_STATIC_PROP(NAME);
MAKE_STATIC_PROP(BINARY_DIR);
@@ -1196,6 +1245,7 @@ const char* cmTarget::GetProperty(const std::string& prop) const
specialProps.insert(propCOMPILE_OPTIONS);
specialProps.insert(propCOMPILE_DEFINITIONS);
specialProps.insert(propIMPORTED);
+ specialProps.insert(propIMPORTED_GLOBAL);
specialProps.insert(propMANUALLY_ADDED_DEPENDENCIES);
specialProps.insert(propNAME);
specialProps.insert(propBINARY_DIR);
@@ -1264,6 +1314,9 @@ const char* cmTarget::GetProperty(const std::string& prop) const
if (prop == propIMPORTED) {
return this->IsImported() ? "TRUE" : "FALSE";
}
+ if (prop == propIMPORTED_GLOBAL) {
+ return this->IsImportedGloballyVisible() ? "TRUE" : "FALSE";
+ }
if (prop == propNAME) {
return this->GetName().c_str();
}
diff --git a/Source/cmTargetPropertyComputer.cxx b/Source/cmTargetPropertyComputer.cxx
index 1d2520d..ed9026e 100644
--- a/Source/cmTargetPropertyComputer.cxx
+++ b/Source/cmTargetPropertyComputer.cxx
@@ -57,6 +57,7 @@ bool cmTargetPropertyComputer::WhiteListedInterfaceProperty(
builtIns.insert("COMPATIBLE_INTERFACE_STRING");
builtIns.insert("EXPORT_NAME");
builtIns.insert("IMPORTED");
+ builtIns.insert("IMPORTED_GLOBAL");
builtIns.insert("NAME");
builtIns.insert("TYPE");
}