[Cmake-commits] CMake branch, next, updated. v2.8.12.1-5176-gb9059ab

Nils Gladitz nilsgladitz at gmail.com
Sat Nov 16 05:37:31 EST 2013


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  b9059ab34d8f659bf0cff970f31964f1fc7b38ed (commit)
       via  42f16f6c0bd19778045c7ad1e02a7433dddd4d79 (commit)
      from  3766f02c8a2b556e154665f1b1f63512df4bc7d8 (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=b9059ab34d8f659bf0cff970f31964f1fc7b38ed
commit b9059ab34d8f659bf0cff970f31964f1fc7b38ed
Merge: 3766f02 42f16f6
Author:     Nils Gladitz <nilsgladitz at gmail.com>
AuthorDate: Sat Nov 16 05:37:26 2013 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Sat Nov 16 05:37:26 2013 -0500

    Merge topic 'forbid-reserved-targets' into next
    
    42f16f6 TargetNames: extend CMP0037 to reserved names and custom targets


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=42f16f6c0bd19778045c7ad1e02a7433dddd4d79
commit 42f16f6c0bd19778045c7ad1e02a7433dddd4d79
Author:     Nils Gladitz <nilsgladitz at gmail.com>
AuthorDate: Sat Nov 16 11:07:24 2013 +0100
Commit:     Nils Gladitz <nilsgladitz at gmail.com>
CommitDate: Sat Nov 16 11:07:24 2013 +0100

    TargetNames: extend CMP0037 to reserved names and custom targets

diff --git a/Help/policy/CMP0037.rst b/Help/policy/CMP0037.rst
index 5df3c00..059b2e6 100644
--- a/Help/policy/CMP0037.rst
+++ b/Help/policy/CMP0037.rst
@@ -1,19 +1,24 @@
 CMP0037
 -------
 
-Target names should match a validity pattern.
+Target names should not be reserved and should match a validity pattern.
 
-CMake 2.8.12 and lower allowed creating targets using :command:`add_library` and
-:command:`add_executable` with unrestricted choice for the target name.  Newer
-cmake features such as :manual:`cmake-generator-expressions(7)` and some
+CMake 2.8.12 and lower allowed creating targets using :command:`add_library`,
+:command:`add_executable` and :command:`add_custom_target` with unrestricted
+choice for the target name.  Newer cmake features such
+as :manual:`cmake-generator-expressions(7)` and some
 diagnostics expect target names to match a restricted pattern.
 
 Target names may contain upper and lower case letters, numbers, the underscore
 character (_), dot(.), plus(+) and minus(-).  As a special case, ALIAS
 targets and INTERFACE library targets may contain two consequtive colons.
 
-The OLD behavior for this policy is to allow creating targets which do not match
-the validity pattern.  The NEW behavior for this policy is to report an error
+Target names reserved by one or more CMake generators are not allowed.
+Among others these include "all", "help" and "test".
+
+The OLD behavior for this policy is to allow creating targets with
+reserved names or which do not match the validity pattern.
+The NEW behavior for this policy is to report an error
 if an add_* command is used with an invalid target name.
 
 This policy was introduced in CMake version 3.0.0.  CMake version
diff --git a/Source/cmAddCustomTargetCommand.cxx b/Source/cmAddCustomTargetCommand.cxx
index 2a683a4..e2a87f1 100644
--- a/Source/cmAddCustomTargetCommand.cxx
+++ b/Source/cmAddCustomTargetCommand.cxx
@@ -11,6 +11,8 @@
 ============================================================================*/
 #include "cmAddCustomTargetCommand.h"
 
+#include "cmGeneratorExpression.h"
+
 // cmAddCustomTargetCommand
 bool cmAddCustomTargetCommand
 ::InitialPass(std::vector<std::string> const& args,
@@ -22,11 +24,13 @@ bool cmAddCustomTargetCommand
     return false;
     }
 
+  std::string targetName = args[0];
+
   // Check the target name.
-  if(args[0].find_first_of("/\\") != args[0].npos)
+  if(targetName.find_first_of("/\\") != targetName.npos)
     {
     cmOStringStream e;
-    e << "called with invalid target name \"" << args[0]
+    e << "called with invalid target name \"" << targetName
       << "\".  Target names may not contain a slash.  "
       << "Use ADD_CUSTOM_COMMAND to generate files.";
     this->SetError(e.str().c_str());
@@ -138,16 +142,58 @@ bool cmAddCustomTargetCommand
       }
     }
 
-  std::string::size_type pos = args[0].find_first_of("#<>");
-  if(pos != args[0].npos)
+  std::string::size_type pos = targetName.find_first_of("#<>");
+  if(pos != targetName.npos)
     {
     cmOStringStream msg;
-    msg << "called with target name containing a \"" << args[0][pos]
+    msg << "called with target name containing a \"" << targetName[pos]
         << "\".  This character is not allowed.";
     this->SetError(msg.str().c_str());
     return false;
     }
 
+  // Some requirements on custom target names already exist
+  // and have been checked at this point.
+  // The following restrictions overlap but depend on policy CMP0037.
+  bool nameOk = cmGeneratorExpression::IsValidTargetName(targetName);
+  if (nameOk)
+    {
+    nameOk = targetName.find(":") == std::string::npos;
+    }
+  if (!nameOk)
+    {
+    cmake::MessageType messageType = cmake::AUTHOR_WARNING;
+    bool issueMessage = false;
+    switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0037))
+      {
+      case cmPolicies::WARN:
+        issueMessage = true;
+      case cmPolicies::OLD:
+        break;
+      case cmPolicies::NEW:
+      case cmPolicies::REQUIRED_IF_USED:
+      case cmPolicies::REQUIRED_ALWAYS:
+        issueMessage = true;
+        messageType = cmake::FATAL_ERROR;
+      }
+    if (issueMessage)
+      {
+      cmOStringStream e;
+      e << (this->Makefile->GetPolicies()
+           ->GetPolicyWarning(cmPolicies::CMP0037)) << "\n";
+      e << "The target name \"" << targetName <<
+          "\" is reserved or not valid for certain "
+          "CMake features, such as generator expressions, and may result "
+          "in undefined behavior.";
+      this->Makefile->IssueMessage(messageType, e.str().c_str());
+
+      if (messageType == cmake::FATAL_ERROR)
+        {
+        return false;
+        }
+      }
+    }
+
   // Store the last command line finished.
   if(!currentLine.empty())
     {
@@ -158,7 +204,7 @@ bool cmAddCustomTargetCommand
   // Enforce name uniqueness.
   {
   std::string msg;
-  if(!this->Makefile->EnforceUniqueName(args[0], msg, true))
+  if(!this->Makefile->EnforceUniqueName(targetName, msg, true))
     {
     this->SetError(msg.c_str());
     return false;
@@ -176,7 +222,7 @@ bool cmAddCustomTargetCommand
   // Add the utility target to the makefile.
   bool escapeOldStyle = !verbatim;
   cmTarget* target =
-    this->Makefile->AddUtilityCommand(args[0].c_str(), excludeFromAll,
+    this->Makefile->AddUtilityCommand(targetName.c_str(), excludeFromAll,
                                       working_directory.c_str(), depends,
                                       commandLines, escapeOldStyle, comment);
 
diff --git a/Source/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx
index a93e834..3ce0ce9 100644
--- a/Source/cmAddExecutableCommand.cxx
+++ b/Source/cmAddExecutableCommand.cxx
@@ -95,7 +95,8 @@ bool cmAddExecutableCommand
       cmOStringStream e;
       e << (this->Makefile->GetPolicies()
             ->GetPolicyWarning(cmPolicies::CMP0037)) << "\n";
-      e << "The target name \"" << exename << "\" is not valid for certain "
+      e << "The target name \"" << exename <<
+          "\" is reserved or not valid for certain "
           "CMake features, such as generator expressions, and may result "
           "in undefined behavior.";
       this->Makefile->IssueMessage(messageType, e.str().c_str());
diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx
index e9c5d6b..da4e1d1 100644
--- a/Source/cmAddLibraryCommand.cxx
+++ b/Source/cmAddLibraryCommand.cxx
@@ -135,7 +135,8 @@ bool cmAddLibraryCommand
       cmOStringStream e;
       e << (this->Makefile->GetPolicies()
             ->GetPolicyWarning(cmPolicies::CMP0037)) << "\n";
-      e << "The target name \"" << libName << "\" is not valid for certain "
+      e << "The target name \"" << libName <<
+          "\" is reserved or not valid for certain "
           "CMake features, such as generator expressions, and may result "
           "in undefined behavior.";
       this->Makefile->IssueMessage(messageType, e.str().c_str());
diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx
index f34a35b..80ebcd4 100644
--- a/Source/cmGeneratorExpression.cxx
+++ b/Source/cmGeneratorExpression.cxx
@@ -449,10 +449,39 @@ std::string::size_type cmGeneratorExpression::Find(const std::string &input)
 //----------------------------------------------------------------------------
 bool cmGeneratorExpression::IsValidTargetName(const std::string &input)
 {
+  // The following is a list of targets reserved
+  // by one or more of the cmake generators
+  const char* reservedTargets[] =
+  {
+    "all", "ALL_BUILD",
+    "help",
+    "install",
+    "preinstall",
+    "clean",
+    "edit_cache",
+    "rebuild_cache",
+    "test", "RUN_TESTS",
+    "package", "PACKAGE",
+    "package_source",
+    "ZERO_CHECK",
+    0
+  };
+
   cmsys::RegularExpression targetNameValidator;
   // The ':' is supported to allow use with IMPORTED targets. At least
   // Qt 4 and 5 IMPORTED targets use ':' as the namespace delimiter.
   targetNameValidator.compile("^[A-Za-z0-9_.:+-]+$");
 
-  return targetNameValidator.find(input.c_str());
+  if(!targetNameValidator.find(input.c_str()))
+    {
+    return false;
+    }
+
+  for(const char** reservedTarget = reservedTargets;
+    *reservedTarget; ++reservedTarget)
+    {
+    if(input == *reservedTarget) return false;
+    }
+
+  return true;
 }
diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx
index 7b80d14..a18fc16 100644
--- a/Source/cmPolicies.cxx
+++ b/Source/cmPolicies.cxx
@@ -289,7 +289,7 @@ cmPolicies::cmPolicies()
 
   this->DefinePolicy(
     CMP0037, "CMP0037",
-    "Target names should match a validity pattern.",
+    "Target names should not be reserved and should match a validity pattern.",
     3,0,0,0, cmPolicies::WARN);
 
   this->DefinePolicy(
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index fc239d4..361d820 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -88,7 +88,8 @@ public:
     CMP0034, ///< Disallow command: utility_source
     CMP0035, ///< Disallow command: variable_requires
     CMP0036, ///< Disallow command: build_name
-    CMP0037, ///< Target names should match a validity pattern.
+    CMP0037, ///< Target names should not be reserved and
+    /// should match a validity pattern.
     CMP0038, ///< Targets may not link directly to themselves
     CMP0039, ///< Utility targets may not have link dependencies
 
diff --git a/Tests/RunCMake/CMP0037/CMP0037-NEW-colon-stderr.txt b/Tests/RunCMake/CMP0037/CMP0037-NEW-colon-stderr.txt
index aadc7d7..9d2c35b 100644
--- a/Tests/RunCMake/CMP0037/CMP0037-NEW-colon-stderr.txt
+++ b/Tests/RunCMake/CMP0037/CMP0037-NEW-colon-stderr.txt
@@ -1,19 +1,35 @@
 CMake Error at CMP0037-NEW-colon.cmake:4 \(add_library\):
-  Policy CMP0037 is not set: Target names should match a validity pattern.
-  Run "cmake --help-policy CMP0037" for policy details.  Use the cmake_policy
-  command to set the policy and suppress this warning.
+  Policy CMP0037 is not set: Target names should not be reserved and should
+  match a validity pattern.  Run "cmake --help-policy CMP0037" for policy
+  details.  Use the cmake_policy command to set the policy and suppress this
+  warning.
 
-  The target name "lib:colon" is not valid for certain CMake features, such
-  as generator expressions, and may result in undefined behavior.
+  The target name "lib:colon" is reserved or not valid for certain CMake
+  features, such as generator expressions, and may result in undefined
+  behavior.
 Call Stack \(most recent call first\):
   CMakeLists.txt:3 \(include\)
 +
 CMake Error at CMP0037-NEW-colon.cmake:5 \(add_executable\):
-  Policy CMP0037 is not set: Target names should match a validity pattern.
-  Run "cmake --help-policy CMP0037" for policy details.  Use the cmake_policy
-  command to set the policy and suppress this warning.
+  Policy CMP0037 is not set: Target names should not be reserved and should
+  match a validity pattern.  Run "cmake --help-policy CMP0037" for policy
+  details.  Use the cmake_policy command to set the policy and suppress this
+  warning.
 
-  The target name "exe:colon" is not valid for certain CMake features, such
-  as generator expressions, and may result in undefined behavior.
+  The target name "exe:colon" is reserved or not valid for certain CMake
+  features, such as generator expressions, and may result in undefined
+  behavior.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
++
+CMake Error at CMP0037-NEW-colon.cmake:6 \(add_custom_target\):
+  Policy CMP0037 is not set: Target names should not be reserved and should
+  match a validity pattern.  Run "cmake --help-policy CMP0037" for policy
+  details.  Use the cmake_policy command to set the policy and suppress this
+  warning.
+
+  The target name "custom:colon" is reserved or not valid for certain CMake
+  features, such as generator expressions, and may result in undefined
+  behavior.
 Call Stack \(most recent call first\):
   CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/CMP0037/CMP0037-NEW-colon.cmake b/Tests/RunCMake/CMP0037/CMP0037-NEW-colon.cmake
index 5c564f3..f4c070d 100644
--- a/Tests/RunCMake/CMP0037/CMP0037-NEW-colon.cmake
+++ b/Tests/RunCMake/CMP0037/CMP0037-NEW-colon.cmake
@@ -3,3 +3,4 @@ cmake_policy(SET CMP0037 NEW)
 
 add_library("lib:colon" empty.cpp)
 add_executable("exe:colon" empty.cpp)
+add_custom_target("custom:colon")
diff --git a/Tests/RunCMake/CMP0037/CMP0037-NEW-reserved-result.txt b/Tests/RunCMake/CMP0037/CMP0037-NEW-reserved-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CMP0037/CMP0037-NEW-reserved-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CMP0037/CMP0037-NEW-reserved-stderr.txt b/Tests/RunCMake/CMP0037/CMP0037-NEW-reserved-stderr.txt
new file mode 100644
index 0000000..13835af
--- /dev/null
+++ b/Tests/RunCMake/CMP0037/CMP0037-NEW-reserved-stderr.txt
@@ -0,0 +1,33 @@
+CMake Error at CMP0037-NEW-reserved.cmake:4 \(add_library\):
+  Policy CMP0037 is not set: Target names should not be reserved and should
+  match a validity pattern.  Run "cmake --help-policy CMP0037" for policy
+  details.  Use the cmake_policy command to set the policy and suppress this
+  warning.
+
+  The target name "all" is reserved or not valid for certain CMake features,
+  such as generator expressions, and may result in undefined behavior.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
++
+CMake Error at CMP0037-NEW-reserved.cmake:5 \(add_executable\):
+  Policy CMP0037 is not set: Target names should not be reserved and should
+  match a validity pattern.  Run "cmake --help-policy CMP0037" for policy
+  details.  Use the cmake_policy command to set the policy and suppress this
+  warning.
+
+  The target name "clean" is reserved or not valid for certain CMake
+  features, such as generator expressions, and may result in undefined
+  behavior.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
++
+CMake Error at CMP0037-NEW-reserved.cmake:6 \(add_custom_target\):
+  Policy CMP0037 is not set: Target names should not be reserved and should
+  match a validity pattern.  Run "cmake --help-policy CMP0037" for policy
+  details.  Use the cmake_policy command to set the policy and suppress this
+  warning.
+
+  The target name "help" is reserved or not valid for certain CMake features,
+  such as generator expressions, and may result in undefined behavior.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/CMP0037/CMP0037-NEW-reserved.cmake b/Tests/RunCMake/CMP0037/CMP0037-NEW-reserved.cmake
new file mode 100644
index 0000000..e9f6404
--- /dev/null
+++ b/Tests/RunCMake/CMP0037/CMP0037-NEW-reserved.cmake
@@ -0,0 +1,6 @@
+
+cmake_policy(SET CMP0037 NEW)
+
+add_library(all empty.cpp)
+add_executable(clean empty.cpp)
+add_custom_target(help)
diff --git a/Tests/RunCMake/CMP0037/CMP0037-NEW-space-stderr.txt b/Tests/RunCMake/CMP0037/CMP0037-NEW-space-stderr.txt
index 169db86..2525bcd 100644
--- a/Tests/RunCMake/CMP0037/CMP0037-NEW-space-stderr.txt
+++ b/Tests/RunCMake/CMP0037/CMP0037-NEW-space-stderr.txt
@@ -1,19 +1,35 @@
 CMake Error at CMP0037-NEW-space.cmake:4 \(add_library\):
-  Policy CMP0037 is not set: Target names should match a validity pattern.
-  Run "cmake --help-policy CMP0037" for policy details.  Use the cmake_policy
-  command to set the policy and suppress this warning.
+  Policy CMP0037 is not set: Target names should not be reserved and should
+  match a validity pattern.  Run "cmake --help-policy CMP0037" for policy
+  details.  Use the cmake_policy command to set the policy and suppress this
+  warning.
 
-  The target name "lib with spaces" is not valid for certain CMake features,
-  such as generator expressions, and may result in undefined behavior.
+  The target name "lib with spaces" is reserved or not valid for certain
+  CMake features, such as generator expressions, and may result in undefined
+  behavior.
 Call Stack \(most recent call first\):
   CMakeLists.txt:3 \(include\)
 +
 CMake Error at CMP0037-NEW-space.cmake:5 \(add_executable\):
-  Policy CMP0037 is not set: Target names should match a validity pattern.
-  Run "cmake --help-policy CMP0037" for policy details.  Use the cmake_policy
-  command to set the policy and suppress this warning.
+  Policy CMP0037 is not set: Target names should not be reserved and should
+  match a validity pattern.  Run "cmake --help-policy CMP0037" for policy
+  details.  Use the cmake_policy command to set the policy and suppress this
+  warning.
 
-  The target name "exe with spaces" is not valid for certain CMake features,
-  such as generator expressions, and may result in undefined behavior.
+  The target name "exe with spaces" is reserved or not valid for certain
+  CMake features, such as generator expressions, and may result in undefined
+  behavior.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
++
+CMake Error at CMP0037-NEW-space.cmake:6 \(add_custom_target\):
+  Policy CMP0037 is not set: Target names should not be reserved and should
+  match a validity pattern.  Run "cmake --help-policy CMP0037" for policy
+  details.  Use the cmake_policy command to set the policy and suppress this
+  warning.
+
+  The target name "custom with spaces" is reserved or not valid for certain
+  CMake features, such as generator expressions, and may result in undefined
+  behavior.
 Call Stack \(most recent call first\):
   CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/CMP0037/CMP0037-NEW-space.cmake b/Tests/RunCMake/CMP0037/CMP0037-NEW-space.cmake
index 9e2faaa..9227986 100644
--- a/Tests/RunCMake/CMP0037/CMP0037-NEW-space.cmake
+++ b/Tests/RunCMake/CMP0037/CMP0037-NEW-space.cmake
@@ -3,3 +3,4 @@ cmake_policy(SET CMP0037 NEW)
 
 add_library("lib with spaces" empty.cpp)
 add_executable("exe with spaces" empty.cpp)
+add_custom_target("custom with spaces")
diff --git a/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved-result.txt b/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved-stderr.txt b/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved-stderr.txt
new file mode 100644
index 0000000..10f3293
--- /dev/null
+++ b/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved-stderr.txt
@@ -0,0 +1 @@
+^$
diff --git a/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved.cmake b/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved.cmake
new file mode 100644
index 0000000..870a286
--- /dev/null
+++ b/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved.cmake
@@ -0,0 +1,6 @@
+
+cmake_policy(SET CMP0037 OLD)
+
+add_library(all empty.cpp)
+add_executable(clean empty.cpp)
+add_custom_target(help)
diff --git a/Tests/RunCMake/CMP0037/CMP0037-OLD-space.cmake b/Tests/RunCMake/CMP0037/CMP0037-OLD-space.cmake
index af98f12..46193a1 100644
--- a/Tests/RunCMake/CMP0037/CMP0037-OLD-space.cmake
+++ b/Tests/RunCMake/CMP0037/CMP0037-OLD-space.cmake
@@ -3,3 +3,4 @@ cmake_policy(SET CMP0037 OLD)
 
 add_library("lib with spaces" empty.cpp)
 add_executable("exe with spaces" empty.cpp)
+add_custom_target("custom with spaces")
diff --git a/Tests/RunCMake/CMP0037/CMP0037-WARN-colon-stderr.txt b/Tests/RunCMake/CMP0037/CMP0037-WARN-colon-stderr.txt
index c9366fa..d3b0e17 100644
--- a/Tests/RunCMake/CMP0037/CMP0037-WARN-colon-stderr.txt
+++ b/Tests/RunCMake/CMP0037/CMP0037-WARN-colon-stderr.txt
@@ -1,21 +1,38 @@
 CMake Warning \(dev\) at CMP0037-WARN-colon.cmake:2 \(add_library\):
-  Policy CMP0037 is not set: Target names should match a validity pattern.
-  Run "cmake --help-policy CMP0037" for policy details.  Use the cmake_policy
-  command to set the policy and suppress this warning.
+  Policy CMP0037 is not set: Target names should not be reserved and should
+  match a validity pattern.  Run "cmake --help-policy CMP0037" for policy
+  details.  Use the cmake_policy command to set the policy and suppress this
+  warning.
 
-  The target name "lib:colon" is not valid for certain CMake features, such
-  as generator expressions, and may result in undefined behavior.
+  The target name "lib:colon" is reserved or not valid for certain CMake
+  features, such as generator expressions, and may result in undefined
+  behavior.
 Call Stack \(most recent call first\):
   CMakeLists.txt:3 \(include\)
 This warning is for project developers.  Use -Wno-dev to suppress it.
 +
 CMake Warning \(dev\) at CMP0037-WARN-colon.cmake:3 \(add_executable\):
-  Policy CMP0037 is not set: Target names should match a validity pattern.
-  Run "cmake --help-policy CMP0037" for policy details.  Use the cmake_policy
-  command to set the policy and suppress this warning.
+  Policy CMP0037 is not set: Target names should not be reserved and should
+  match a validity pattern.  Run "cmake --help-policy CMP0037" for policy
+  details.  Use the cmake_policy command to set the policy and suppress this
+  warning.
 
-  The target name "exe:colon" is not valid for certain CMake features, such
-  as generator expressions, and may result in undefined behavior.
+  The target name "exe:colon" is reserved or not valid for certain CMake
+  features, such as generator expressions, and may result in undefined
+  behavior.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
+This warning is for project developers.  Use -Wno-dev to suppress it.
++
+CMake Warning \(dev\) at CMP0037-WARN-colon.cmake:4 \(add_custom_target\):
+  Policy CMP0037 is not set: Target names should not be reserved and should
+  match a validity pattern.  Run "cmake --help-policy CMP0037" for policy
+  details.  Use the cmake_policy command to set the policy and suppress this
+  warning.
+
+  The target name "custom:colon" is reserved or not valid for certain CMake
+  features, such as generator expressions, and may result in undefined
+  behavior.
 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/CMP0037/CMP0037-WARN-colon.cmake b/Tests/RunCMake/CMP0037/CMP0037-WARN-colon.cmake
index 17c815e..445e3b2 100644
--- a/Tests/RunCMake/CMP0037/CMP0037-WARN-colon.cmake
+++ b/Tests/RunCMake/CMP0037/CMP0037-WARN-colon.cmake
@@ -1,3 +1,4 @@
 
 add_library("lib:colon" empty.cpp)
 add_executable("exe:colon" empty.cpp)
+add_custom_target("custom:colon")
diff --git a/Tests/RunCMake/CMP0037/CMP0037-WARN-space-stderr.txt b/Tests/RunCMake/CMP0037/CMP0037-WARN-space-stderr.txt
index b29aad5..e39477a 100644
--- a/Tests/RunCMake/CMP0037/CMP0037-WARN-space-stderr.txt
+++ b/Tests/RunCMake/CMP0037/CMP0037-WARN-space-stderr.txt
@@ -1,21 +1,37 @@
 CMake Warning \(dev\) at CMP0037-WARN-space.cmake:2 \(add_library\):
-  Policy CMP0037 is not set: Target names should match a validity pattern.
-  Run "cmake --help-policy CMP0037" for policy details.  Use the cmake_policy
-  command to set the policy and suppress this warning.
+  Policy CMP0037 is not set: Target names should not be reserved and should
+  match a validity pattern.  Run "cmake --help-policy CMP0037" for policy
+  details.  Use the cmake_policy command to set the policy and suppress this
+  warning.
 
-  The target name "lib with spaces" is not valid for certain CMake features,
-  such as generator expressions, and may result in undefined behavior.
+  The target name "lib with spaces" is reserved or not valid for certain
+  CMake features, such as generator expressions, and may result in undefined
+  behavior.
 Call Stack \(most recent call first\):
   CMakeLists.txt:3 \(include\)
 This warning is for project developers.  Use -Wno-dev to suppress it.
 +
 CMake Warning \(dev\) at CMP0037-WARN-space.cmake:3 \(add_executable\):
-  Policy CMP0037 is not set: Target names should match a validity pattern.
-  Run "cmake --help-policy CMP0037" for policy details.  Use the cmake_policy
-  command to set the policy and suppress this warning.
+  Policy CMP0037 is not set: Target names should not be reserved and should
+  match a validity pattern.  Run "cmake --help-policy CMP0037" for policy
+  details.  Use the cmake_policy command to set the policy and suppress this
+  warning.
 
-  The target name "exe with spaces" is not valid for certain CMake features,
-  such as generator expressions, and may result in undefined behavior.
+  The target name "exe with spaces" is reserved or not valid for certain
+  CMake features, such as generator expressions, and may result in undefined
+  behavior.
 Call Stack \(most recent call first\):
   CMakeLists.txt:3 \(include\)
 This warning is for project developers.  Use -Wno-dev to suppress it.
++
+CMake Warning \(dev\) at CMP0037-WARN-space.cmake:4 \(add_custom_target\):
+  Policy CMP0037 is not set: Target names should not be reserved and should
+  match a validity pattern.  Run "cmake --help-policy CMP0037" for policy
+  details.  Use the cmake_policy command to set the policy and suppress this
+  warning.
+
+  The target name "custom with spaces" is reserved or not valid for certain
+  CMake features, such as generator expressions, and may result in undefined
+  behavior.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/CMP0037/CMP0037-WARN-space.cmake b/Tests/RunCMake/CMP0037/CMP0037-WARN-space.cmake
index 4a10828..e50a64d 100644
--- a/Tests/RunCMake/CMP0037/CMP0037-WARN-space.cmake
+++ b/Tests/RunCMake/CMP0037/CMP0037-WARN-space.cmake
@@ -1,3 +1,4 @@
 
 add_library("lib with spaces" empty.cpp)
 add_executable("exe with spaces" empty.cpp)
+add_custom_target("custom with spaces")
diff --git a/Tests/RunCMake/CMP0037/RunCMakeTest.cmake b/Tests/RunCMake/CMP0037/RunCMakeTest.cmake
index fbb1788..b7d8d7b 100644
--- a/Tests/RunCMake/CMP0037/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CMP0037/RunCMakeTest.cmake
@@ -8,3 +8,6 @@ run_cmake(CMP0037-NEW-colon)
 if(NOT (WIN32 AND "${RunCMake_GENERATOR}" MATCHES "Make"))
   run_cmake(CMP0037-WARN-colon)
 endif()
+
+run_cmake(CMP0037-OLD-reserved)
+run_cmake(CMP0037-NEW-reserved)

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

Summary of changes:
 Help/policy/CMP0037.rst                            |   17 ++++--
 Source/cmAddCustomTargetCommand.cxx                |   60 +++++++++++++++++--
 Source/cmAddExecutableCommand.cxx                  |    3 +-
 Source/cmAddLibraryCommand.cxx                     |    3 +-
 Source/cmGeneratorExpression.cxx                   |   31 ++++++++++-
 Source/cmPolicies.cxx                              |    2 +-
 Source/cmPolicies.h                                |    3 +-
 .../RunCMake/CMP0037/CMP0037-NEW-colon-stderr.txt  |   36 +++++++++---
 Tests/RunCMake/CMP0037/CMP0037-NEW-colon.cmake     |    1 +
 .../CMP0037-NEW-reserved-result.txt}               |    0
 .../CMP0037/CMP0037-NEW-reserved-stderr.txt        |   33 +++++++++++
 Tests/RunCMake/CMP0037/CMP0037-NEW-reserved.cmake  |    6 ++
 .../RunCMake/CMP0037/CMP0037-NEW-space-stderr.txt  |   36 +++++++++---
 Tests/RunCMake/CMP0037/CMP0037-NEW-space.cmake     |    1 +
 .../CMP0037-OLD-reserved-result.txt}               |    0
 .../CMP0037-OLD-reserved-stderr.txt}               |    0
 Tests/RunCMake/CMP0037/CMP0037-OLD-reserved.cmake  |    6 ++
 Tests/RunCMake/CMP0037/CMP0037-OLD-space.cmake     |    1 +
 .../RunCMake/CMP0037/CMP0037-WARN-colon-stderr.txt |   37 +++++++++---
 Tests/RunCMake/CMP0037/CMP0037-WARN-colon.cmake    |    1 +
 .../RunCMake/CMP0037/CMP0037-WARN-space-stderr.txt |   36 +++++++++---
 Tests/RunCMake/CMP0037/CMP0037-WARN-space.cmake    |    1 +
 Tests/RunCMake/CMP0037/RunCMakeTest.cmake          |    3 +
 23 files changed, 259 insertions(+), 58 deletions(-)
 copy Tests/RunCMake/{CMP0004/CMP0004-NEW-result.txt => CMP0037/CMP0037-NEW-reserved-result.txt} (100%)
 create mode 100644 Tests/RunCMake/CMP0037/CMP0037-NEW-reserved-stderr.txt
 create mode 100644 Tests/RunCMake/CMP0037/CMP0037-NEW-reserved.cmake
 copy Tests/RunCMake/{CMP0022/CMP0022-WARN-empty-old-result.txt => CMP0037/CMP0037-OLD-reserved-result.txt} (100%)
 copy Tests/RunCMake/{CMP0022/CMP0022-NOWARN-exe-stderr.txt => CMP0037/CMP0037-OLD-reserved-stderr.txt} (100%)
 create mode 100644 Tests/RunCMake/CMP0037/CMP0037-OLD-reserved.cmake


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list