diff options
author | Nils Gladitz <nilsgladitz@gmail.com> | 2015-04-29 15:25:13 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2015-04-30 14:21:19 (GMT) |
commit | aed6239e40e7046c3f32e018d9c360ad0f624336 (patch) | |
tree | 704a638d740870f5c2c94d56d09e5f9b8a240472 /Source | |
parent | 32a2f41402d38e1c5be3547bd042328df0b28124 (diff) | |
download | CMake-aed6239e40e7046c3f32e018d9c360ad0f624336.zip CMake-aed6239e40e7046c3f32e018d9c360ad0f624336.tar.gz CMake-aed6239e40e7046c3f32e018d9c360ad0f624336.tar.bz2 |
if: Implement new IN_LIST operator
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmConditionEvaluator.cxx | 38 | ||||
-rw-r--r-- | Source/cmConditionEvaluator.h | 1 | ||||
-rw-r--r-- | Source/cmPolicies.cxx | 5 | ||||
-rw-r--r-- | Source/cmPolicies.h | 1 |
4 files changed, 44 insertions, 1 deletions
diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx index 0a71c60..1f9b9d4 100644 --- a/Source/cmConditionEvaluator.cxx +++ b/Source/cmConditionEvaluator.cxx @@ -15,7 +15,8 @@ cmConditionEvaluator::cmConditionEvaluator(cmMakefile& makefile): Makefile(makefile), Policy12Status(makefile.GetPolicyStatus(cmPolicies::CMP0012)), - Policy54Status(makefile.GetPolicyStatus(cmPolicies::CMP0054)) + Policy54Status(makefile.GetPolicyStatus(cmPolicies::CMP0054)), + Policy57Status(makefile.GetPolicyStatus(cmPolicies::CMP0057)) { } @@ -676,6 +677,41 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList &newArgs, reducible, arg, newArgs, argP1, argP2); } + if (argP1 != newArgs.end() && argP2 != newArgs.end() && + this->IsKeyword("IN_LIST", *argP1)) + { + if(this->Policy57Status != cmPolicies::OLD && + this->Policy57Status != cmPolicies::WARN) + { + bool result = false; + + def = this->GetVariableOrString(*arg); + def2 = this->Makefile.GetDefinition(argP2->GetValue()); + + if(def2) + { + std::vector<std::string> list; + cmSystemTools::ExpandListArgument(def2, list, true); + + result = std::find(list.begin(), list.end(), def) != list.end(); + } + + this->HandleBinaryOp(result, + reducible, arg, newArgs, argP1, argP2); + } + else if(this->Policy57Status == cmPolicies::WARN) + { + std::ostringstream e; + e << (this->Makefile.GetPolicies()->GetPolicyWarning( + cmPolicies::CMP0057)) << "\n"; + e << "IN_LIST will be interpreted as an operator " + "when the policy is set to NEW. " + "Since the policy is not set the OLD behavior will be used."; + + this->Makefile.IssueMessage(cmake::AUTHOR_WARNING, e.str()); + } + } + ++arg; } } diff --git a/Source/cmConditionEvaluator.h b/Source/cmConditionEvaluator.h index fcef234..c923d76 100644 --- a/Source/cmConditionEvaluator.h +++ b/Source/cmConditionEvaluator.h @@ -93,6 +93,7 @@ private: cmMakefile& Makefile; cmPolicies::PolicyStatus Policy12Status; cmPolicies::PolicyStatus Policy54Status; + cmPolicies::PolicyStatus Policy57Status; }; #endif diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index ab60f93..76990f0 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -390,6 +390,11 @@ cmPolicies::cmPolicies() CMP0060, "CMP0060", "Link libraries by full path even in implicit directories.", 3,3,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0057, "CMP0057", + "Support new IN_LIST if() operator.", + 3,3,0, cmPolicies::WARN); } cmPolicies::~cmPolicies() diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 90acf8e..ca82264 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -117,6 +117,7 @@ public: CMP0059, ///< Do not treat ``DEFINITIONS`` as a built-in directory /// property. CMP0060, ///< Link libraries by full path even in implicit directories. + CMP0057, ///< Support new IN_LIST if() operator. /** \brief Always the last entry. * |