diff options
author | Stephen Kelly <steveire@gmail.com> | 2013-07-30 07:51:56 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2013-10-21 13:56:31 (GMT) |
commit | f063c45589e83bf8e4ef61f49b17084debf085a2 (patch) | |
tree | 2de4dc557c9360fc134985d4f34bace214d4ec39 /Source | |
parent | 919e1e845361d6e29789f5347d12af3318452843 (diff) | |
download | CMake-f063c45589e83bf8e4ef61f49b17084debf085a2.zip CMake-f063c45589e83bf8e4ef61f49b17084debf085a2.tar.gz CMake-f063c45589e83bf8e4ef61f49b17084debf085a2.tar.bz2 |
Consider targets with double colons to be IMPORTED or ALIAS targets.
Introduce a policy to control the behavior.
The AliasTargets unit test already tests that using a
double-semicolon in the name is not an error. Change the ExportImport
test to use a namespace with a double-semicolon too.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmPolicies.cxx | 5 | ||||
-rw-r--r-- | Source/cmPolicies.h | 1 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 40 |
3 files changed, 46 insertions, 0 deletions
diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index ffab8e5..f7efc1e 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -241,6 +241,11 @@ cmPolicies::cmPolicies() CMP0027, "CMP0027", "Conditionally linked imported targets with missing include directories.", 3,0,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0028, "CMP0028", + "Double colon in target name means ALIAS or IMPORTED target.", + 3,0,0,0, cmPolicies::WARN); } cmPolicies::~cmPolicies() diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 39c2afb..68cd7c2 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -79,6 +79,7 @@ public: CMP0026, ///< Disallow use of the LOCATION target property. CMP0027, ///< Conditionally linked imported targets with missing include /// directories. + CMP0028, ///< Double colon in target name means ALIAS or IMPORTED target. /** \brief Always the last entry. * diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index b6182ab..647eb76 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -5483,6 +5483,46 @@ void cmTarget::ComputeLinkImplementation(const char* config, { continue; } + cmTarget *tgt = this->Makefile->FindTargetToUse(li->c_str()); + + if(!tgt && std::string(item).find("::") != std::string::npos) + { + bool noMessage = false; + cmake::MessageType messageType = cmake::FATAL_ERROR; + cmOStringStream e; + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0028)) + { + case cmPolicies::WARN: + { + e << (this->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0028)) << "\n"; + messageType = cmake::AUTHOR_WARNING; + } + break; + case cmPolicies::OLD: + noMessage = true; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + // Issue the fatal message. + break; + } + + if(!noMessage) + { + e << "Target \"" << this->GetName() << "\" links to target \"" << item + << "\" but the target was not found. Perhaps a find_package() " + "call is missing for an IMPORTED target, or a ALIAS target is " + "missing?"; + this->Makefile->GetCMakeInstance()->IssueMessage(messageType, + e.str(), + this->GetBacktrace()); + if (messageType == cmake::FATAL_ERROR) + { + return; + } + } + } // The entry is meant for this configuration. impl.Libraries.push_back(item); } |