[Cmake-commits] CMake branch, next, updated. v3.0.1-5170-gf63493a
Nils Gladitz
nilsgladitz at gmail.com
Thu Sep 4 16:33:17 EDT 2014
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".
The branch, next has been updated
via f63493a09ea51b547c62ded01c7ad23b58a7e0b7 (commit)
via 080819bba68d1b11723d1049285cb7b295e2d898 (commit)
from 967d7d765d982860c9ac322b1869de3e80de16f2 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f63493a09ea51b547c62ded01c7ad23b58a7e0b7
commit f63493a09ea51b547c62ded01c7ad23b58a7e0b7
Merge: 967d7d7 080819b
Author: Nils Gladitz <nilsgladitz at gmail.com>
AuthorDate: Thu Sep 4 16:33:14 2014 -0400
Commit: CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Thu Sep 4 16:33:14 2014 -0400
Merge topic 'if-sanity' into next
080819bb If: Extend CMP0054 to boolean evaluation
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=080819bba68d1b11723d1049285cb7b295e2d898
commit 080819bba68d1b11723d1049285cb7b295e2d898
Author: Nils Gladitz <nilsgladitz at gmail.com>
AuthorDate: Thu Sep 4 22:32:42 2014 +0200
Commit: Nils Gladitz <nilsgladitz at gmail.com>
CommitDate: Thu Sep 4 22:32:42 2014 +0200
If: Extend CMP0054 to boolean evaluation
diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx
index 71971a7..8c92a6a 100644
--- a/Source/cmIfCommand.cxx
+++ b/Source/cmIfCommand.cxx
@@ -263,7 +263,7 @@ namespace
}
// Check definition.
- const char* def = mf->GetDefinition(arg.GetValue());
+ const char* def = cmIfCommand::GetDefinitionIfUnquoted(mf, arg);
return !cmSystemTools::IsOff(def);
}
@@ -280,12 +280,15 @@ namespace
else if(arg == "1")
{ return true; }
else
- { return !cmSystemTools::IsOff(mf->GetDefinition(arg.GetValue())); }
+ {
+ const char* def = cmIfCommand::GetDefinitionIfUnquoted(mf, arg);
+ return !cmSystemTools::IsOff(def);
+ }
}
else
{
// Old GetVariableOrNumber behavior.
- const char* def = mf->GetDefinition(arg.GetValue());
+ const char* def = cmIfCommand::GetDefinitionIfUnquoted(mf, arg);
if(!def && atoi(arg.c_str()))
{
def = arg.c_str();
@@ -912,11 +915,12 @@ bool cmIfCommand::IsTrue(const std::vector<cmExpandedCommandArgument> &args,
}
//=========================================================================
-const char* cmIfCommand::GetVariableOrString(
- const cmExpandedCommandArgument& argument,
- const cmMakefile* mf)
+const char* cmIfCommand::GetDefinitionIfUnquoted(
+ const cmMakefile* mf,
+ cmExpandedCommandArgument const& argument)
{
const char* def = mf->GetDefinition(argument.GetValue());
+
if(def && argument.WasQuoted())
{
cmOStringStream e;
@@ -940,6 +944,16 @@ const char* cmIfCommand::GetVariableOrString(
}
}
+ return def;
+}
+
+//=========================================================================
+const char* cmIfCommand::GetVariableOrString(
+ const cmExpandedCommandArgument& argument,
+ const cmMakefile* mf)
+{
+ const char* def = cmIfCommand::GetDefinitionIfUnquoted(mf, argument);
+
if(!def)
{
def = argument.c_str();
diff --git a/Source/cmIfCommand.h b/Source/cmIfCommand.h
index a5ace73..2749754 100644
--- a/Source/cmIfCommand.h
+++ b/Source/cmIfCommand.h
@@ -77,6 +77,10 @@ public:
std::string &errorString, cmMakefile *mf,
cmake::MessageType &status);
+ // Filter the given variable definition based on policy CMP0054.
+ static const char* GetDefinitionIfUnquoted(
+ const cmMakefile* mf, cmExpandedCommandArgument const& argument);
+
// Get a definition from the makefile. If it doesn't exist,
// return the original string.
static const char* GetVariableOrString(
diff --git a/Tests/RunCMake/CMP0054/CMP0054-NEW.cmake b/Tests/RunCMake/CMP0054/CMP0054-NEW.cmake
index 6b21b05..d4f8de0 100644
--- a/Tests/RunCMake/CMP0054/CMP0054-NEW.cmake
+++ b/Tests/RunCMake/CMP0054/CMP0054-NEW.cmake
@@ -9,3 +9,13 @@ endif()
if(NOT FOO STREQUAL "BAR")
message(FATAL_ERROR "The given variable should match the literal")
endif()
+
+set(MYTRUE ON)
+
+if(NOT MYTRUE)
+ message(FATAL_ERROR "Expected MYTRUE to evaluate true")
+endif()
+
+if("MYTRUE")
+ message(FATAL_ERROR "Expected quoted MYTRUE to evaluate false")
+endif()
diff --git a/Tests/RunCMake/CMP0054/CMP0054-OLD.cmake b/Tests/RunCMake/CMP0054/CMP0054-OLD.cmake
index bb3d6a6..3730af4 100644
--- a/Tests/RunCMake/CMP0054/CMP0054-OLD.cmake
+++ b/Tests/RunCMake/CMP0054/CMP0054-OLD.cmake
@@ -9,3 +9,13 @@ endif()
if(NOT FOO STREQUAL "BAR")
message(FATAL_ERROR "The given literals should match")
endif()
+
+set(MYTRUE ON)
+
+if(NOT MYTRUE)
+ message(FATAL_ERROR "Expected MYTRUE to evaluate true")
+endif()
+
+if(NOT "MYTRUE")
+ message(FATAL_ERROR "Expected quoted MYTRUE to evaluate true as well")
+endif()
-----------------------------------------------------------------------
Summary of changes:
Source/cmIfCommand.cxx | 26 ++++++++++++++++++++------
Source/cmIfCommand.h | 4 ++++
Tests/RunCMake/CMP0054/CMP0054-NEW.cmake | 10 ++++++++++
Tests/RunCMake/CMP0054/CMP0054-OLD.cmake | 10 ++++++++++
4 files changed, 44 insertions(+), 6 deletions(-)
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list