diff options
author | Brad King <brad.king@kitware.com> | 2014-02-12 16:31:30 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2014-02-12 16:31:30 (GMT) |
commit | 54d9e014874b43172626b416f49c68c9f86cacb8 (patch) | |
tree | b47f715ef309e6092446624a213f6143929d01b6 /Source | |
parent | 764d467d24ca07eb6ebaad33be1c7f7f56294e8c (diff) | |
parent | f2eee72facb9b4a658e1205bbe9113a808e76775 (diff) | |
download | CMake-54d9e014874b43172626b416f49c68c9f86cacb8.zip CMake-54d9e014874b43172626b416f49c68c9f86cacb8.tar.gz CMake-54d9e014874b43172626b416f49c68c9f86cacb8.tar.bz2 |
Merge topic 'backward-compatibility'
f2eee72f add_custom_command: Disallow use of SOURCE signatures.
c248a437 Add policy CMP0049 to avoid variable expansion in source lists
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmAddCustomCommandCommand.cxx | 30 | ||||
-rw-r--r-- | Source/cmPolicies.cxx | 10 | ||||
-rw-r--r-- | Source/cmPolicies.h | 2 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 32 |
4 files changed, 74 insertions, 0 deletions
diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx index 5634849..3de04f5 100644 --- a/Source/cmAddCustomCommandCommand.cxx +++ b/Source/cmAddCustomCommandCommand.cxx @@ -344,6 +344,36 @@ bool cmAddCustomCommandCommand } else { + bool issueMessage = true; + cmOStringStream e; + cmake::MessageType messageType = cmake::AUTHOR_WARNING; + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0050)) + { + case cmPolicies::WARN: + e << (this->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0050)) << "\n"; + break; + case cmPolicies::OLD: + issueMessage = false; + break; + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::NEW: + messageType = cmake::FATAL_ERROR; + break; + } + + if (issueMessage) + { + e << "The SOURCE signatures of add_custom_command are no longer " + "supported."; + this->Makefile->IssueMessage(messageType, e.str().c_str()); + if (messageType == cmake::FATAL_ERROR) + { + return false; + } + } + // Use the old-style mode for backward compatibility. this->Makefile->AddCustomCommandOldStyle(target.c_str(), outputs, depends, source.c_str(), commandLines, diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index 9cfa1e4..93072f5 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -333,6 +333,16 @@ cmPolicies::cmPolicies() CMP0048, "CMP0048", "project() command manages VERSION variables.", 3,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0049, "CMP0049", + "Do not expand variables in target source entries.", + 3,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0050, "CMP0050", + "Disallow add_custom_command SOURCE signatures.", + 3,0,0, cmPolicies::WARN); } cmPolicies::~cmPolicies() diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index f9a4768..b77235d 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -102,6 +102,8 @@ public: CMP0046, ///< Error on non-existent dependency in add_dependencies CMP0047, ///< Use QCC compiler id for the qcc drivers on QNX. CMP0048, ///< project() command manages VERSION variables + CMP0049, ///< Do not expand variables in target source entries + CMP0050, ///< Disallow add_custom_command SOURCE signatures /** \brief Always the last entry. * diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index d440f7c..3e96b69 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -590,6 +590,38 @@ cmSourceFile* cmTarget::AddSource(const char* s) // For backwards compatibility replace varibles in source names. // This should eventually be removed. this->Makefile->ExpandVariablesInString(src); + if (src != s) + { + cmOStringStream e; + bool noMessage = false; + cmake::MessageType messageType = cmake::AUTHOR_WARNING; + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0049)) + { + case cmPolicies::WARN: + e << (this->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0049)) << "\n"; + break; + case cmPolicies::OLD: + noMessage = true; + break; + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::NEW: + messageType = cmake::FATAL_ERROR; + } + if (!noMessage) + { + e << "Legacy variable expansion in source file \"" + << s << "\" expanded to \"" << src << "\" in target \"" + << this->GetName() << "\". This behavior will be removed in a " + "future version of CMake."; + this->Makefile->IssueMessage(messageType, e.str().c_str()); + if (messageType == cmake::FATAL_ERROR) + { + return 0; + } + } + } cmSourceFile* sf = this->Makefile->GetOrCreateSource(src.c_str()); this->AddSourceFile(sf); |