diff options
author | Brad King <brad.king@kitware.com> | 2022-06-06 13:47:37 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-06-06 13:47:45 (GMT) |
commit | ab1edff49268df77e1cdcf8074e24e64ef140370 (patch) | |
tree | 7d7f553823bc5581ec28df764d23269a95d9b97e /Source | |
parent | 9fdade1d6b1f62cbb24e0bdf79b98d72145ba17f (diff) | |
parent | be4b9e10afaae750ad184ce1b34d6cb2c3d7fd33 (diff) | |
download | CMake-ab1edff49268df77e1cdcf8074e24e64ef140370.zip CMake-ab1edff49268df77e1cdcf8074e24e64ef140370.tar.gz CMake-ab1edff49268df77e1cdcf8074e24e64ef140370.tar.bz2 |
Merge topic 'if-command-PATH_EQUAL'
be4b9e10af if command: Add PATH_EQUAL operator
Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !7321
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmConditionEvaluator.cxx | 26 | ||||
-rw-r--r-- | Source/cmConditionEvaluator.h | 1 | ||||
-rw-r--r-- | Source/cmPolicies.h | 6 |
3 files changed, 32 insertions, 1 deletions
diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx index 141c4eb..5de012a 100644 --- a/Source/cmConditionEvaluator.cxx +++ b/Source/cmConditionEvaluator.cxx @@ -16,6 +16,7 @@ #include "cmsys/RegularExpression.hxx" +#include "cmCMakePath.h" #include "cmExpandedCommandArgument.h" #include "cmMakefile.h" #include "cmMessageType.h" @@ -58,6 +59,7 @@ auto const keyVERSION_GREATER = "VERSION_GREATER"_s; auto const keyVERSION_GREATER_EQUAL = "VERSION_GREATER_EQUAL"_s; auto const keyVERSION_LESS = "VERSION_LESS"_s; auto const keyVERSION_LESS_EQUAL = "VERSION_LESS_EQUAL"_s; +auto const keyPATH_EQUAL = "PATH_EQUAL"_s; cmSystemTools::CompareOp const MATCH2CMPOP[5] = { cmSystemTools::OP_LESS, cmSystemTools::OP_LESS_EQUAL, @@ -217,6 +219,7 @@ cmConditionEvaluator::cmConditionEvaluator(cmMakefile& makefile, , Policy54Status(makefile.GetPolicyStatus(cmPolicies::CMP0054)) , Policy57Status(makefile.GetPolicyStatus(cmPolicies::CMP0057)) , Policy64Status(makefile.GetPolicyStatus(cmPolicies::CMP0064)) + , Policy139Status(makefile.GetPolicyStatus(cmPolicies::CMP0139)) { } @@ -775,6 +778,29 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList& newArgs, this->Makefile.IssueMessage(MessageType::AUTHOR_WARNING, e.str()); } } + + else if (this->IsKeyword(keyPATH_EQUAL, *args.next)) { + + if (this->Policy139Status != cmPolicies::OLD && + this->Policy139Status != cmPolicies::WARN) { + + cmValue lhs = this->GetVariableOrString(*args.current); + cmValue rhs = this->GetVariableOrString(*args.nextnext); + const auto result = cmCMakePath{ *lhs } == cmCMakePath{ *rhs }; + newArgs.ReduceTwoArgs(result, args); + } + + else if (this->Policy139Status == cmPolicies::WARN) { + std::ostringstream e; + e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0139) + << "\n" + "PATH_EQUAL 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(MessageType::AUTHOR_WARNING, e.str()); + } + } } return true; } diff --git a/Source/cmConditionEvaluator.h b/Source/cmConditionEvaluator.h index 37b7825..9486b16 100644 --- a/Source/cmConditionEvaluator.h +++ b/Source/cmConditionEvaluator.h @@ -79,4 +79,5 @@ private: cmPolicies::PolicyStatus Policy54Status; cmPolicies::PolicyStatus Policy57Status; cmPolicies::PolicyStatus Policy64Status; + cmPolicies::PolicyStatus Policy139Status; }; diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index f13432b..256d483 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -417,7 +417,11 @@ class cmMakefile; cmPolicies::WARN) \ SELECT(POLICY, CMP0138, \ "MSVC compilers use -ZI instead of /Zi for x86 and x64 by default.", \ - 3, 24, 0, cmPolicies::WARN) + 3, 24, 0, cmPolicies::WARN) \ + SELECT( \ + POLICY, CMP0139, \ + "The if() command supports path comparisons using PATH_EQUAL operator.", \ + 3, 24, 0, cmPolicies::WARN) #define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1) #define CM_FOR_EACH_POLICY_ID(POLICY) \ |