diff options
author | Stephen Kelly <steveire@gmail.com> | 2014-02-11 16:41:24 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2014-02-12 16:17:38 (GMT) |
commit | c248a437c47b4419fd955d4b1f406f7c8b9dcd74 (patch) | |
tree | 37a953da5b8130fdde1e36e9c731930c161fd896 /Source | |
parent | 418a155be7e44117297c072b6aa0f21f4407c052 (diff) | |
download | CMake-c248a437c47b4419fd955d4b1f406f7c8b9dcd74.zip CMake-c248a437c47b4419fd955d4b1f406f7c8b9dcd74.tar.gz CMake-c248a437c47b4419fd955d4b1f406f7c8b9dcd74.tar.bz2 |
Add policy CMP0049 to avoid variable expansion in source lists
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmPolicies.cxx | 5 | ||||
-rw-r--r-- | Source/cmPolicies.h | 1 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 32 |
3 files changed, 38 insertions, 0 deletions
diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index 9cfa1e4..78453db 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -333,6 +333,11 @@ 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); } cmPolicies::~cmPolicies() diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index f9a4768..9523650 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -102,6 +102,7 @@ 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 /** \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); |