diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGetTargetPropertyCommand.cxx | 31 | ||||
-rw-r--r-- | Source/cmPolicies.cxx | 5 | ||||
-rw-r--r-- | Source/cmPolicies.h | 1 |
3 files changed, 36 insertions, 1 deletions
diff --git a/Source/cmGetTargetPropertyCommand.cxx b/Source/cmGetTargetPropertyCommand.cxx index 02f00a5..488cc28 100644 --- a/Source/cmGetTargetPropertyCommand.cxx +++ b/Source/cmGetTargetPropertyCommand.cxx @@ -40,7 +40,36 @@ bool cmGetTargetPropertyCommand cmTarget& target = *tgt; prop = target.GetProperty(args[2].c_str()); } - + else + { + bool issueMessage = false; + cmOStringStream e; + cmake::MessageType messageType = cmake::AUTHOR_WARNING; + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0045)) + { + case cmPolicies::WARN: + issueMessage = true; + e << this->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0045) << "\n"; + case cmPolicies::OLD: + break; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + issueMessage = true; + messageType = cmake::FATAL_ERROR; + } + if (issueMessage) + { + e << "get_target_property() called with non-existent target \"" + << targetName << "\"."; + this->Makefile->IssueMessage(messageType, e.str().c_str()); + if (messageType == cmake::FATAL_ERROR) + { + return false; + } + } + } if (prop) { this->Makefile->AddDefinition(var.c_str(), prop); diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index c9dacaf..5a189f8 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -326,6 +326,11 @@ cmPolicies::cmPolicies() CMP0044, "CMP0044", "Case sensitive <LANG>_COMPILER_ID generator expressions.", 3,0,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0045, "CMP0045", + "Error on non-existent target in get_target_property.", + 3,0,0,0, cmPolicies::WARN); } cmPolicies::~cmPolicies() diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 0d7327f..b1342bf 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -98,6 +98,7 @@ public: CMP0042, ///< Enable MACOSX_RPATH by default CMP0043, ///< Ignore COMPILE_DEFINITIONS_<Config> properties CMP0044, ///< Case sensitive <LANG>_COMPILER_ID generator expressions + CMP0045, ///< Error on non-existent target in get_target_property /** \brief Always the last entry. * |