[Cmake-commits] CMake branch, next, updated. v2.8.12.2-1643-g8b0b0ee

Ben Boeckel ben.boeckel at kitware.com
Fri Feb 21 19:50:46 EST 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  8b0b0ee4c227e4a8dad4a12dd7a79abc5c275f54 (commit)
       via  670f4d6f82c2250b18e57151a77cad2799f0783f (commit)
       via  4ae4128fd5629575eb5cb665e108cfecd82e0636 (commit)
       via  162a583f90aea22a14e0356958e83156d2e07771 (commit)
       via  b667320a541efcb40444af1ce4a4f918a2f0469f (commit)
       via  07e466ca50456f8d2e99bb29034ca7f1e330419c (commit)
      from  2ad6f07fc31047755a6450dfff715957e8d9091d (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=8b0b0ee4c227e4a8dad4a12dd7a79abc5c275f54
commit 8b0b0ee4c227e4a8dad4a12dd7a79abc5c275f54
Merge: 2ad6f07 670f4d6
Author:     Ben Boeckel <ben.boeckel at kitware.com>
AuthorDate: Fri Feb 21 19:50:44 2014 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Fri Feb 21 19:50:44 2014 -0500

    Merge topic 'dev/faster-evis' into next
    
    670f4d6f relnotes: Add release notes for the branch
    4ae4128f EVIS: Reimplement using custom parsing code
    162a583f tests: Fix StringFileTest for CMP0052
    b667320a tests: Add tests for CMP0052
    07e466ca policy: Add policy CMP0052


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=670f4d6f82c2250b18e57151a77cad2799f0783f
commit 670f4d6f82c2250b18e57151a77cad2799f0783f
Author:     Ben Boeckel <ben.boeckel at kitware.com>
AuthorDate: Tue Feb 11 13:54:07 2014 -0500
Commit:     Ben Boeckel <ben.boeckel at kitware.com>
CommitDate: Fri Feb 21 17:21:01 2014 -0500

    relnotes: Add release notes for the branch

diff --git a/Help/release/dev/faster-evis.rst b/Help/release/dev/faster-evis.rst
new file mode 100644
index 0000000..14b60a0
--- /dev/null
+++ b/Help/release/dev/faster-evis.rst
@@ -0,0 +1,6 @@
+faster-evis
+-----------
+
+* The :manual:`cmake-language(7)` internal implementation of variable
+  evaluation has been optimized and shows non-trivial speedup on large
+  projects. The improvements may be used by setting :policy:`CMP0052` to NEW.

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4ae4128fd5629575eb5cb665e108cfecd82e0636
commit 4ae4128fd5629575eb5cb665e108cfecd82e0636
Author:     Ben Boeckel <ben.boeckel at kitware.com>
AuthorDate: Fri Feb 7 22:37:54 2014 -0500
Commit:     Ben Boeckel <ben.boeckel at kitware.com>
CommitDate: Fri Feb 21 17:20:46 2014 -0500

    EVIS: Reimplement using custom parsing code
    
    Testing the configure (no generate) step with ParaView shows ~20%
    performance improvement (~47s -> ~39s on my machine).
    
    In terms of complete configure/generate steps, further testing with
    ParaView shows a 20% performance improvement over 2.8.12.2 with Unix
    Makefiles and minimal with Ninja. Ninja is less because it generate step
    is the expensive part (future work will address this) by a long shot and
    these changes help the configure step for the most part.

diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index f248c57..a43d320 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -157,6 +157,7 @@ void cmMakefile::Initialize()
   this->cmDefineRegex.compile("#cmakedefine[ \t]+([A-Za-z_0-9]*)");
   this->cmDefine01Regex.compile("#cmakedefine01[ \t]+([A-Za-z_0-9]*)");
   this->cmAtVarRegex.compile("(@[A-Za-z_0-9/.+-]+@)");
+  this->cmNamedCurly.compile("^[A-Za-z0-9/_.+-]+{");
 
   // Enter a policy level for this directory.
   this->PushPolicy();
@@ -2533,23 +2534,88 @@ const char *cmMakefile::ExpandVariablesInString(std::string& source,
                                                 bool removeEmpty,
                                                 bool replaceAt) const
 {
-  if ( source.empty() || source.find_first_of("$@\\") == source.npos)
+  if ( source.find_first_of("$@\\") == source.npos)
     {
     return source.c_str();
     }
 
-  // Special-case the @ONLY mode.
-  if(atOnly)
+  bool compareResults = false;
+  cmake::MessageType mtype = cmake::LOG;
+  std::string errorstr;
+
+  // Sanity check the @ONLY mode.
+  if(atOnly && (!noEscapes || !removeEmpty))
+    {
+    // This case should never be called.  At-only is for
+    // configure-file/string which always does no escapes.
+    this->IssueMessage(cmake::INTERNAL_ERROR,
+                       "ExpandVariablesInString @ONLY called "
+                       "on something with escapes.");
+    return source.c_str();
+    }
+
+  // Variables used in the WARN case.
+  std::string newResult;
+  cmake::MessageType newError = cmake::LOG;
+
+  switch(this->GetPolicyStatus(cmPolicies::CMP0052))
+    {
+    case cmPolicies::WARN:
+      {
+      std::string newErrorstr;
+      newResult = source;
+      compareResults = true;
+      newError =
+        ExpandVariablesInStringNew(newErrorstr, newResult, escapeQuotes,
+                                   noEscapes, atOnly, filename, line,
+                                   removeEmpty, replaceAt);
+      }
+    case cmPolicies::OLD:
+      mtype = ExpandVariablesInStringOld(errorstr, source, escapeQuotes,
+                                         noEscapes, atOnly, filename,
+                                         line, removeEmpty, true);
+      break;
+    case cmPolicies::REQUIRED_IF_USED:
+    case cmPolicies::REQUIRED_ALWAYS:
+      // Messaging here would be *very* verbose.
+    case cmPolicies::NEW:
+      mtype = ExpandVariablesInStringNew(errorstr, source, escapeQuotes,
+                                         noEscapes, atOnly, filename,
+                                         line, removeEmpty, replaceAt);
+      break;
+    }
+
+  if(mtype != cmake::LOG)
     {
-    if(!noEscapes || !removeEmpty || !replaceAt)
+    if(mtype == cmake::FATAL_ERROR)
       {
-      // This case should never be called.  At-only is for
-      // configure-file/string which always does no escapes.
-      this->IssueMessage(cmake::INTERNAL_ERROR,
-                         "ExpandVariablesInString @ONLY called "
-                         "on something with escapes.");
+      cmSystemTools::SetFatalErrorOccured();
       }
+    this->IssueMessage(mtype, errorstr);
+    }
+  else if(compareResults && (newResult != source || newError != mtype))
+    {
+    this->IssueMessage(cmake::AUTHOR_WARNING,
+        this->GetPolicies()->GetPolicyWarning(cmPolicies::CMP0052));
+    }
+
+  return source.c_str();
+}
 
+cmake::MessageType cmMakefile::ExpandVariablesInStringOld(
+                                                std::string& errorstr,
+                                                std::string& source,
+                                                bool escapeQuotes,
+                                                bool noEscapes,
+                                                bool atOnly,
+                                                const char* filename,
+                                                long line,
+                                                bool removeEmpty,
+                                                bool replaceAt) const
+{
+  // Special-case the @ONLY mode.
+  if(atOnly)
+    {
     // Store an original copy of the input.
     std::string input = source;
 
@@ -2589,7 +2655,7 @@ const char *cmMakefile::ExpandVariablesInString(std::string& source,
     // Append the rest of the unchanged part of the string.
     source.append(in);
 
-    return source.c_str();
+    return cmake::LOG;
     }
 
   // This method replaces ${VAR} and @VAR@ where VAR is looked up
@@ -2606,6 +2672,7 @@ const char *cmMakefile::ExpandVariablesInString(std::string& source,
   parser.SetRemoveEmpty(removeEmpty);
   int res = parser.ParseString(source.c_str(), 0);
   const char* emsg = parser.GetError();
+  cmake::MessageType mtype = cmake::LOG;
   if ( res && !emsg[0] )
     {
     source = parser.GetResult();
@@ -2632,7 +2699,7 @@ const char *cmMakefile::ExpandVariablesInString(std::string& source,
     // parser reported an error message without failing because the
     // helper implementation is unhappy, which has always reported an
     // error.
-    cmake::MessageType mtype = cmake::FATAL_ERROR;
+    mtype = cmake::FATAL_ERROR;
     if(!res)
       {
       // This is a real argument parsing error.  Use policy CMP0010 to
@@ -2654,13 +2721,328 @@ const char *cmMakefile::ExpandVariablesInString(std::string& source,
                     ->GetRequiredPolicyError(cmPolicies::CMP0010));
         case cmPolicies::NEW:
           // NEW behavior is to report the error.
-          cmSystemTools::SetFatalErrorOccured();
           break;
         }
       }
-    this->IssueMessage(mtype, error.str());
+    errorstr = error.str();
     }
-  return source.c_str();
+  return mtype;
+}
+
+typedef enum
+  {
+  NORMAL,
+  ENVIRONMENT,
+  CACHE
+  } t_domain;
+struct t_lookup
+  {
+  t_domain domain;
+  std::string lookup;
+  };
+
+cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
+                                            std::string& errorstr,
+                                            std::string& source,
+                                            bool escapeQuotes,
+                                            bool noEscapes,
+                                            bool atOnly,
+                                            const char* filename,
+                                            long line,
+                                            bool removeEmpty,
+                                            bool replaceAt) const
+{
+  // This method replaces ${VAR} and @VAR@ where VAR is looked up
+  // with GetDefinition(), if not found in the map, nothing is expanded.
+  // It also supports the $ENV{VAR} syntax where VAR is looked up in
+  // the current environment variables.
+
+  const char* in = source.c_str();
+  const char* last = in;
+  std::stack<t_lookup> openstack;
+  bool error = false;
+  bool done = false;
+  openstack.push(t_lookup());
+  cmake::MessageType mtype = cmake::LOG;
+
+  do
+    {
+    char inc = *in;
+    switch(inc)
+      {
+      case '}':
+        if(openstack.size() > 1)
+          {
+          t_lookup var = openstack.top();
+          openstack.pop();
+          std::string lookup = var.lookup;
+          lookup.append(last, in - last);
+          const char* value = NULL;
+          switch(var.domain)
+            {
+            case NORMAL:
+              if(filename && lookup == "CMAKE_CURRENT_LIST_LINE")
+                {
+                cmOStringStream ostr;
+                ostr << line;
+                openstack.top().lookup.append(ostr.str());
+                }
+              else
+                {
+                value = this->GetDefinition(lookup.c_str());
+                }
+              break;
+            case ENVIRONMENT:
+              value = cmSystemTools::GetEnv(lookup.c_str());
+              break;
+            case CACHE:
+              value = this->GetCacheManager()->GetCacheValue(lookup.c_str());
+              break;
+            }
+          // Get the string we're meant to append to.
+          std::string result;
+          if(value)
+            {
+            if(escapeQuotes)
+              {
+              result = cmSystemTools::EscapeQuotes(value);
+              }
+            else
+              {
+              result = value;
+              }
+            }
+          else if(!removeEmpty)
+            {
+            // check to see if we need to print a warning
+            // if strict mode is on and the variable has
+            // not been "cleared"/initialized with a set(foo ) call
+            if(this->GetCMakeInstance()->GetWarnUninitialized() &&
+               !this->VariableInitialized(lookup.c_str()))
+              {
+              if (this->CheckSystemVars ||
+                  cmSystemTools::IsSubDirectory(filename,
+                                                this->GetHomeDirectory()) ||
+                  cmSystemTools::IsSubDirectory(filename,
+                                             this->GetHomeOutputDirectory()))
+                {
+                cmOStringStream msg;
+                cmListFileBacktrace bt;
+                cmListFileContext lfc;
+                lfc.FilePath = filename;
+                lfc.Line = line;
+                bt.push_back(lfc);
+                msg << "uninitialized variable \'" << lookup << "\'";
+                this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING,
+                                                       msg.str().c_str(), bt);
+                }
+              }
+            }
+          openstack.top().lookup.append(result);
+          // Start looking from here on out.
+          last = in + 1;
+          }
+        break;
+      case '$':
+        if(!atOnly)
+          {
+          t_lookup lookup;
+          const char* next = in + 1;
+          const char* start = NULL;
+          char nextc = *next;
+          if(nextc == '{')
+            {
+            // Looking for a variable.
+            start = in + 2;
+            lookup.domain = NORMAL;
+            }
+          else if(nextc == '<')
+            {
+            }
+          else if(!nextc)
+            {
+            openstack.top().lookup.append(last, next - last);
+            last = next;
+            }
+          else if(cmHasLiteralPrefix(next, "ENV{"))
+            {
+            // Looking for an environment variable.
+            start = in + 5;
+            lookup.domain = ENVIRONMENT;
+            }
+          else if(cmHasLiteralPrefix(next, "CACHE{"))
+            {
+            // Looking for a cache variable.
+            start = in + 7;
+            lookup.domain = CACHE;
+            }
+          else
+            {
+            if(this->cmNamedCurly.find(next))
+              {
+              errorstr = "Syntax $"
+                  + std::string(next, this->cmNamedCurly.end())
+                  + "{} is not supported.  Only ${}, $ENV{}, "
+                    "and $CACHE{} are allowed.";
+              mtype = cmake::FATAL_ERROR;
+              error = true;
+              }
+            }
+          if(start)
+            {
+            openstack.top().lookup.append(last, in - last);
+            last = start;
+            in = start - 1;
+            openstack.push(lookup);
+            }
+          break;
+          }
+      case '\\':
+        if(!noEscapes)
+          {
+          const char* next = in + 1;
+          char nextc = *next;
+          if(nextc == 't')
+            {
+            openstack.top().lookup.append(last, in - last);
+            openstack.top().lookup.append("\t");
+            last = next + 1;
+            }
+          else if(nextc == 'n')
+            {
+            openstack.top().lookup.append(last, in - last);
+            openstack.top().lookup.append("\n");
+            last = next + 1;
+            }
+          else if(nextc == 'r')
+            {
+            openstack.top().lookup.append(last, in - last);
+            openstack.top().lookup.append("\r");
+            last = next + 1;
+            }
+          else if(nextc == ';')
+            {
+            // Handled in ExpandListArgument.
+            }
+          else
+            {
+            // Take what we've found so far, skipping the escape character.
+            openstack.top().lookup.append(last, in - last);
+            // Start tracking from the next character.
+            last = in + 1;
+            }
+          // Skip the next character since it was escaped, but don't read past
+          // the end of the string.
+          if(*last)
+            {
+            ++in;
+            }
+          }
+        break;
+      case '\n':
+        // Onto the next line.
+        ++line;
+        break;
+      case '\0':
+        done = true;
+        break;
+      case '@':
+        if(replaceAt)
+          {
+          const char* nextAt = strchr(in + 1, '@');
+          if(nextAt && nextAt != in + 1 &&
+             nextAt == in + 1 + strspn(in + 1,
+                "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+                "abcdefghijklmnopqrstuvwxyz"
+                "0123456789/_.+-"))
+            {
+            std::string variable(in + 1, nextAt - in - 1);
+            std::string result = this->GetSafeDefinition(variable.c_str());
+            if(escapeQuotes)
+              {
+              result = cmSystemTools::EscapeQuotes(result.c_str());
+              }
+            // Skip over the variable.
+            openstack.top().lookup.append(last, in);
+            openstack.top().lookup.append(result);
+            in = nextAt;
+            last = in + 1;
+            break;
+            }
+          }
+        // Failed to find a valid @ expansion; treat it as literal.
+        /* FALLTHROUGH */
+      default:
+        {
+        if(openstack.size() > 1 &&
+           !(isalnum(inc) || inc == '/' ||
+             inc == '_' || inc == '.' ||
+             inc == '+' || inc == '-'))
+          {
+          errorstr += "Invalid character (\'";
+          errorstr += inc;
+          errorstr += "\') in a variable name: " + openstack.top().lookup;
+          mtype = cmake::FATAL_ERROR;
+          error = true;
+          }
+        break;
+        }
+      }
+    // Look at the next character.
+    } while(!error && !done && *++in);
+
+  // Check for open variable references yet.
+  if(!error && openstack.size() != 1)
+    {
+    // There's an open variable reference waiting.  Use policy CMP0010 to
+    // decide whether it is an error.
+    switch(this->GetPolicyStatus(cmPolicies::CMP0010))
+      {
+      case cmPolicies::WARN:
+        errorstr += "\n" + this->GetPolicies()
+                       ->GetPolicyWarning(cmPolicies::CMP0010);
+      case cmPolicies::OLD:
+        // OLD behavior is to just warn and continue.
+        mtype = cmake::AUTHOR_WARNING;
+        break;
+      case cmPolicies::REQUIRED_IF_USED:
+      case cmPolicies::REQUIRED_ALWAYS:
+        errorstr += "\n" + this->GetPolicies()
+                       ->GetRequiredPolicyError(cmPolicies::CMP0010);
+      case cmPolicies::NEW:
+        // NEW behavior is to report the error.
+        mtype = cmake::FATAL_ERROR;
+        break;
+      }
+    error = true;
+    }
+
+  if(error)
+    {
+    cmOStringStream emsg;
+    emsg << "Syntax error in cmake code ";
+    if(filename)
+      {
+      // This filename and line number may be more specific than the
+      // command context because one command invocation can have
+      // arguments on multiple lines.
+      emsg << "at\n"
+            << "  " << filename << ":" << line << "\n";
+      }
+    emsg << "when parsing string\n"
+         << "  " << source << "\n";
+    emsg << errorstr;
+    errorstr = emsg.str();
+    }
+  else
+    {
+    // Append the rest of the unchanged part of the string.
+    openstack.top().lookup.append(last);
+
+    source = openstack.top().lookup;
+    }
+
+  return mtype;
 }
 
 void cmMakefile::RemoveVariablesInString(std::string& source,
@@ -2883,7 +3265,7 @@ bool cmMakefile::ExpandArguments(
     value = i->Value;
     this->ExpandVariablesInString(value, false, false, false,
                                   i->FilePath, i->Line,
-                                  false, true);
+                                  false, false);
 
     // If the argument is quoted, it should be one argument.
     // Otherwise, it may be a list of arguments.
@@ -3442,7 +3824,7 @@ void cmMakefile::ConfigureString(const std::string& input,
 
   // Perform variable replacements.
   this->ExpandVariablesInString(output, escapeQuotes, true,
-                                atOnly, 0, -1, true);
+                                atOnly, 0, -1, true, true);
 }
 
 int cmMakefile::ConfigureFile(const char* infile, const char* outfile,
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 45f3b9f..3f24c48 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -673,7 +673,7 @@ public:
                                       const char* filename = 0,
                                       long line = -1,
                                       bool removeEmpty = false,
-                                      bool replaceAt = true) const;
+                                      bool replaceAt = false) const;
 
   /**
    * Remove any remaining variables in the string. Anything with ${var} or
@@ -971,6 +971,7 @@ private:
   mutable cmsys::RegularExpression cmDefineRegex;
   mutable cmsys::RegularExpression cmDefine01Regex;
   mutable cmsys::RegularExpression cmAtVarRegex;
+  mutable cmsys::RegularExpression cmNamedCurly;
 
   cmPropertyMap Properties;
 
@@ -1027,6 +1028,28 @@ private:
   // Enforce rules about CMakeLists.txt files.
   void EnforceDirectoryLevelRules() const;
 
+  // CMP0052 == old
+  cmake::MessageType ExpandVariablesInStringOld(
+                                  std::string& errorstr,
+                                  std::string& source,
+                                  bool escapeQuotes,
+                                  bool noEscapes,
+                                  bool atOnly,
+                                  const char* filename,
+                                  long line,
+                                  bool removeEmpty,
+                                  bool replaceAt) const;
+  // CMP0052 == new
+  cmake::MessageType ExpandVariablesInStringNew(
+                                  std::string& errorstr,
+                                  std::string& source,
+                                  bool escapeQuotes,
+                                  bool noEscapes,
+                                  bool atOnly,
+                                  const char* filename,
+                                  long line,
+                                  bool removeEmpty,
+                                  bool replaceAt) const;
   bool GeneratingBuildSystem;
   /**
    * Old version of GetSourceFileWithOutput(const char*) kept for

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=162a583f90aea22a14e0356958e83156d2e07771
commit 162a583f90aea22a14e0356958e83156d2e07771
Author:     Ben Boeckel <ben.boeckel at kitware.com>
AuthorDate: Tue Feb 18 14:48:11 2014 -0500
Commit:     Ben Boeckel <ben.boeckel at kitware.com>
CommitDate: Fri Feb 21 17:20:46 2014 -0500

    tests: Fix StringFileTest for CMP0052

diff --git a/Tests/StringFileTest/CMakeLists.txt b/Tests/StringFileTest/CMakeLists.txt
index 00383ab..9b0312b 100644
--- a/Tests/StringFileTest/CMakeLists.txt
+++ b/Tests/StringFileTest/CMakeLists.txt
@@ -143,8 +143,9 @@ endif()
 
 # Obscure environment variable name
 set("ENV{x+(y)}" "Obscure environment variable value")
-message("Output: [$ENV{x+(y)}]")
-if(NOT "$ENV{x+(y)}" STREQUAL "Obscure environment variable value")
+set(envvarname "x+(y)")
+message("Output: [$ENV{${envvarname}}]")
+if(NOT "$ENV{${envvarname}}" STREQUAL "Obscure environment variable value")
   message(SEND_ERROR "Environment variable \"ENV{x+(y)}\" does not work.")
 endif()
 

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b667320a541efcb40444af1ce4a4f918a2f0469f
commit b667320a541efcb40444af1ce4a4f918a2f0469f
Author:     Ben Boeckel <ben.boeckel at kitware.com>
AuthorDate: Tue Feb 18 14:47:56 2014 -0500
Commit:     Ben Boeckel <ben.boeckel at kitware.com>
CommitDate: Fri Feb 21 17:20:46 2014 -0500

    tests: Add tests for CMP0052

diff --git a/Tests/RunCMake/CMP0052/CMP0052-At-NEW-stderr.txt b/Tests/RunCMake/CMP0052/CMP0052-At-NEW-stderr.txt
new file mode 100644
index 0000000..cbd1be4
--- /dev/null
+++ b/Tests/RunCMake/CMP0052/CMP0052-At-NEW-stderr.txt
@@ -0,0 +1 @@
+-->\${right}<--
diff --git a/Tests/RunCMake/CMP0052/CMP0052-At-NEW.cmake b/Tests/RunCMake/CMP0052/CMP0052-At-NEW.cmake
new file mode 100644
index 0000000..5a3de4f
--- /dev/null
+++ b/Tests/RunCMake/CMP0052/CMP0052-At-NEW.cmake
@@ -0,0 +1,9 @@
+cmake_policy(SET CMP0052 NEW)
+
+set(right "wrong")
+set(var "\${right}")
+# Not expanded here with the new policy.
+set(ref "@var@")
+
+string(CONFIGURE "${ref}" output)
+message("-->${output}<--")
diff --git a/Tests/RunCMake/CMP0052/CMP0052-At-OLD-stderr.txt b/Tests/RunCMake/CMP0052/CMP0052-At-OLD-stderr.txt
new file mode 100644
index 0000000..5dcd4d7
--- /dev/null
+++ b/Tests/RunCMake/CMP0052/CMP0052-At-OLD-stderr.txt
@@ -0,0 +1 @@
+-->wrong<--
diff --git a/Tests/RunCMake/CMP0052/CMP0052-At-OLD.cmake b/Tests/RunCMake/CMP0052/CMP0052-At-OLD.cmake
new file mode 100644
index 0000000..e40a5d1
--- /dev/null
+++ b/Tests/RunCMake/CMP0052/CMP0052-At-OLD.cmake
@@ -0,0 +1,9 @@
+cmake_policy(SET CMP0052 OLD)
+
+set(right "wrong")
+set(var "\${right}")
+# Expanded here with the old policy.
+set(ref "@var@")
+
+string(CONFIGURE "${ref}" output)
+message("-->${output}<--")
diff --git a/Tests/RunCMake/CMP0052/CMP0052-At-WARN-stderr.txt b/Tests/RunCMake/CMP0052/CMP0052-At-WARN-stderr.txt
new file mode 100644
index 0000000..a5f0537
--- /dev/null
+++ b/Tests/RunCMake/CMP0052/CMP0052-At-WARN-stderr.txt
@@ -0,0 +1,7 @@
+CMake Warning \(dev\) at CMP0052-At-WARN.cmake:4 \(set\):
+  Policy CMP0052 is not set: Use the new variable expansion rules.  Run
+  "cmake --help-policy CMP0052" for policy details.  Use the cmake_policy
+  command to set the policy and suppress this warning.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
+This warning is for project developers.  Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/CMP0052/CMP0052-At-WARN.cmake b/Tests/RunCMake/CMP0052/CMP0052-At-WARN.cmake
new file mode 100644
index 0000000..19c7f53
--- /dev/null
+++ b/Tests/RunCMake/CMP0052/CMP0052-At-WARN.cmake
@@ -0,0 +1,4 @@
+set(right "wrong")
+set(var "\${right}")
+# Expanded here with the old policy.
+set(ref "@var@")
diff --git a/Tests/RunCMake/CMP0052/CMP0052-ENV-NEW-result.txt b/Tests/RunCMake/CMP0052/CMP0052-ENV-NEW-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CMP0052/CMP0052-ENV-NEW-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CMP0052/CMP0052-ENV-NEW-stderr.txt b/Tests/RunCMake/CMP0052/CMP0052-ENV-NEW-stderr.txt
new file mode 100644
index 0000000..bc799c7
--- /dev/null
+++ b/Tests/RunCMake/CMP0052/CMP0052-ENV-NEW-stderr.txt
@@ -0,0 +1,12 @@
+CMake Error at CMP0052-ENV-NEW.cmake:4 \(message\):
+  Syntax error in cmake code at
+
+    .*/Tests/RunCMake/CMP0052/CMP0052-ENV-NEW.cmake:4
+
+  when parsing string
+
+    -->\$ENV{e\(x\)}<--
+
+  Invalid character \('\('\) in a variable name:
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/CMP0052/CMP0052-ENV-NEW.cmake b/Tests/RunCMake/CMP0052/CMP0052-ENV-NEW.cmake
new file mode 100644
index 0000000..bbea56c
--- /dev/null
+++ b/Tests/RunCMake/CMP0052/CMP0052-ENV-NEW.cmake
@@ -0,0 +1,4 @@
+cmake_policy(SET CMP0052 NEW)
+
+set("ENV{e(x)}" value)
+message("-->$ENV{e(x)}<--")
diff --git a/Tests/RunCMake/CMP0052/CMP0052-ENV-OLD-stderr.txt b/Tests/RunCMake/CMP0052/CMP0052-ENV-OLD-stderr.txt
new file mode 100644
index 0000000..7020c7e
--- /dev/null
+++ b/Tests/RunCMake/CMP0052/CMP0052-ENV-OLD-stderr.txt
@@ -0,0 +1 @@
+-->value<--
diff --git a/Tests/RunCMake/CMP0052/CMP0052-ENV-OLD.cmake b/Tests/RunCMake/CMP0052/CMP0052-ENV-OLD.cmake
new file mode 100644
index 0000000..dbb5451
--- /dev/null
+++ b/Tests/RunCMake/CMP0052/CMP0052-ENV-OLD.cmake
@@ -0,0 +1,4 @@
+cmake_policy(SET CMP0052 OLD)
+
+set("ENV{e(x)}" value)
+message("-->$ENV{e(x)}<--")
diff --git a/Tests/RunCMake/CMP0052/CMP0052-ENV-WARN-stderr.txt b/Tests/RunCMake/CMP0052/CMP0052-ENV-WARN-stderr.txt
new file mode 100644
index 0000000..ff255c3
--- /dev/null
+++ b/Tests/RunCMake/CMP0052/CMP0052-ENV-WARN-stderr.txt
@@ -0,0 +1,9 @@
+CMake Warning \(dev\) at CMP0052-ENV-WARN.cmake:2 \(message\):
+  Policy CMP0052 is not set: Use the new variable expansion rules.  Run
+  "cmake --help-policy CMP0052" for policy details.  Use the cmake_policy
+  command to set the policy and suppress this warning.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
+This warning is for project developers.  Use -Wno-dev to suppress it.
+
+-->value<--
diff --git a/Tests/RunCMake/CMP0052/CMP0052-ENV-WARN.cmake b/Tests/RunCMake/CMP0052/CMP0052-ENV-WARN.cmake
new file mode 100644
index 0000000..6333717
--- /dev/null
+++ b/Tests/RunCMake/CMP0052/CMP0052-ENV-WARN.cmake
@@ -0,0 +1,2 @@
+set("ENV{e(x)}" value)
+message("-->$ENV{e(x)}<--")
diff --git a/Tests/RunCMake/CMP0052/CMakeLists.txt b/Tests/RunCMake/CMP0052/CMakeLists.txt
new file mode 100644
index 0000000..2f10cb0
--- /dev/null
+++ b/Tests/RunCMake/CMP0052/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 2.8.12)
+project(${RunCMake_TEST} CXX)
+include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE)
diff --git a/Tests/RunCMake/CMP0052/RunCMakeTest.cmake b/Tests/RunCMake/CMP0052/RunCMakeTest.cmake
new file mode 100644
index 0000000..15719d9
--- /dev/null
+++ b/Tests/RunCMake/CMP0052/RunCMakeTest.cmake
@@ -0,0 +1,9 @@
+include(RunCMake)
+
+run_cmake(CMP0052-At-OLD)
+run_cmake(CMP0052-At-NEW)
+run_cmake(CMP0052-At-WARN)
+
+run_cmake(CMP0052-ENV-OLD)
+run_cmake(CMP0052-ENV-NEW)
+run_cmake(CMP0052-ENV-WARN)
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 9bb097b..cf01fa6 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -34,6 +34,7 @@ add_RunCMake_test(CMP0045)
 add_RunCMake_test(CMP0046)
 add_RunCMake_test(CMP0049)
 add_RunCMake_test(CMP0050)
+add_RunCMake_test(CMP0052)
 add_RunCMake_test(CTest)
 if(UNIX AND "${CMAKE_TEST_GENERATOR}" MATCHES "Unix Makefiles")
   add_RunCMake_test(CompilerChange)

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=07e466ca50456f8d2e99bb29034ca7f1e330419c
commit 07e466ca50456f8d2e99bb29034ca7f1e330419c
Author:     Ben Boeckel <ben.boeckel at kitware.com>
AuthorDate: Tue Feb 18 12:59:25 2014 -0500
Commit:     Ben Boeckel <ben.boeckel at kitware.com>
CommitDate: Fri Feb 21 17:20:46 2014 -0500

    policy: Add policy CMP0052
    
    This policy switches between the old EVIS parser and the new, faster
    parser.

diff --git a/Help/policy/CMP0052.rst b/Help/policy/CMP0052.rst
new file mode 100644
index 0000000..83f58c4
--- /dev/null
+++ b/Help/policy/CMP0052.rst
@@ -0,0 +1,23 @@
+CMP0052
+-------
+
+Use new variable expansion rules.
+
+CMake 3.0 and lower used an older, slower implementation of variable expansion
+which offered some behavior no longer allowed by the new parser. Specifically,
+'@' expansion is no longer performed in files not configured using
+:command:`configure_file` or the CONFIGURE signature of :command:`string` and
+literal variable names are restricted to alphanumerics and the characters
+"./-+". If variables with other characters are required, use
+
+.. code-block:: cmake
+
+  set(varname "parens()")
+  message("${${varname}}")
+
+The OLD behavior for this policy is to use the old variable expansion parser.
+The NEW behavior is to use the new variable expansion rules.
+
+This policy was introduced in CMake version 3.1. CMake version |release| warns
+when the policy is not set and uses OLD behavior.  Use the cmake_policy
+command to set it to OLD or NEW explicitly.
diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx
index 93072f5..eec9903 100644
--- a/Source/cmPolicies.cxx
+++ b/Source/cmPolicies.cxx
@@ -343,6 +343,11 @@ cmPolicies::cmPolicies()
     CMP0050, "CMP0050",
     "Disallow add_custom_command SOURCE signatures.",
     3,0,0, cmPolicies::WARN);
+
+  this->DefinePolicy(
+    CMP0052, "CMP0052",
+    "Use the new variable expansion rules.",
+    3,1,0, cmPolicies::WARN);
 }
 
 cmPolicies::~cmPolicies()
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index b77235d..001fd45 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -105,6 +105,8 @@ public:
     CMP0049, ///< Do not expand variables in target source entries
     CMP0050, ///< Disallow add_custom_command SOURCE signatures
 
+    CMP0052, ///< Use the new EVIS parser and rules
+
     /** \brief Always the last entry.
      *
      * Useful mostly to avoid adding a comma the last policy when adding a new

-----------------------------------------------------------------------

Summary of changes:
 Help/policy/CMP0052.rst                            |   23 ++
 Help/release/dev/faster-evis.rst                   |    6 +
 Source/cmMakefile.cxx                              |  414 +++++++++++++++++++-
 Source/cmMakefile.h                                |   25 +-
 Source/cmPolicies.cxx                              |    5 +
 Source/cmPolicies.h                                |    2 +
 .../CMP0052-At-NEW-stderr.txt}                     |    0
 .../CMP0052-At-NEW.cmake}                          |    7 +-
 .../CMP0052-At-OLD-stderr.txt}                     |    0
 .../CMP0052-At-OLD.cmake}                          |    7 +-
 Tests/RunCMake/CMP0052/CMP0052-At-WARN-stderr.txt  |    7 +
 Tests/RunCMake/CMP0052/CMP0052-At-WARN.cmake       |    4 +
 .../CMP0052-ENV-NEW-result.txt}                    |    0
 Tests/RunCMake/CMP0052/CMP0052-ENV-NEW-stderr.txt  |   12 +
 .../CMP0052-ENV-NEW.cmake}                         |    2 +
 .../CMP0052-ENV-OLD-stderr.txt}                    |    0
 .../CMP0052-ENV-OLD.cmake}                         |    2 +
 Tests/RunCMake/CMP0052/CMP0052-ENV-WARN-stderr.txt |    9 +
 .../CMP0052-ENV-WARN.cmake}                        |    0
 Tests/RunCMake/{CMP0038 => CMP0052}/CMakeLists.txt |    0
 Tests/RunCMake/CMP0052/RunCMakeTest.cmake          |    9 +
 Tests/RunCMake/CMakeLists.txt                      |    1 +
 Tests/StringFileTest/CMakeLists.txt                |    5 +-
 23 files changed, 515 insertions(+), 25 deletions(-)
 create mode 100644 Help/policy/CMP0052.rst
 create mode 100644 Help/release/dev/faster-evis.rst
 copy Tests/RunCMake/{Syntax/AtWithVariableAtOnly-stderr.txt => CMP0052/CMP0052-At-NEW-stderr.txt} (100%)
 copy Tests/RunCMake/{Syntax/AtWithVariableEmptyExpansion.cmake => CMP0052/CMP0052-At-NEW.cmake} (62%)
 copy Tests/RunCMake/{Syntax/AtWithVariable-stderr.txt => CMP0052/CMP0052-At-OLD-stderr.txt} (100%)
 copy Tests/RunCMake/{Syntax/AtWithVariableEmptyExpansion.cmake => CMP0052/CMP0052-At-OLD.cmake} (63%)
 create mode 100644 Tests/RunCMake/CMP0052/CMP0052-At-WARN-stderr.txt
 create mode 100644 Tests/RunCMake/CMP0052/CMP0052-At-WARN.cmake
 copy Tests/RunCMake/{CMP0004/CMP0004-NEW-result.txt => CMP0052/CMP0052-ENV-NEW-result.txt} (100%)
 create mode 100644 Tests/RunCMake/CMP0052/CMP0052-ENV-NEW-stderr.txt
 copy Tests/RunCMake/{Syntax/ParenInQuotedENV.cmake => CMP0052/CMP0052-ENV-NEW.cmake} (62%)
 copy Tests/RunCMake/{Syntax/ParenInQuotedENV-stderr.txt => CMP0052/CMP0052-ENV-OLD-stderr.txt} (100%)
 copy Tests/RunCMake/{Syntax/ParenInQuotedENV.cmake => CMP0052/CMP0052-ENV-OLD.cmake} (62%)
 create mode 100644 Tests/RunCMake/CMP0052/CMP0052-ENV-WARN-stderr.txt
 copy Tests/RunCMake/{Syntax/ParenInQuotedENV.cmake => CMP0052/CMP0052-ENV-WARN.cmake} (100%)
 copy Tests/RunCMake/{CMP0038 => CMP0052}/CMakeLists.txt (100%)
 create mode 100644 Tests/RunCMake/CMP0052/RunCMakeTest.cmake


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list