[Cmake-commits] CMake branch, next, updated. v2.8.12.1-5297-g8e900ea

Nils Gladitz nilsgladitz at gmail.com
Mon Nov 18 11:55:02 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  8e900ea793d3833c29967845d2a48fc676cf1f7c (commit)
       via  33ce1f63c8eafde87f8440e5e692bed8c9148e06 (commit)
      from  90491b3ed238fd07f9876818a0e69e07968dde57 (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=8e900ea793d3833c29967845d2a48fc676cf1f7c
commit 8e900ea793d3833c29967845d2a48fc676cf1f7c
Merge: 90491b3 33ce1f6
Author:     Nils Gladitz <nilsgladitz at gmail.com>
AuthorDate: Mon Nov 18 11:54:48 2013 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Mon Nov 18 11:54:48 2013 -0500

    Merge topic 'forbid-reserved-targets' into next
    
    33ce1f6 TargetNames: extracted cmGlobalGenerator::IsReservedTarget, added INSTALL


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=33ce1f63c8eafde87f8440e5e692bed8c9148e06
commit 33ce1f63c8eafde87f8440e5e692bed8c9148e06
Author:     Nils Gladitz <nilsgladitz at gmail.com>
AuthorDate: Mon Nov 18 17:53:03 2013 +0100
Commit:     Nils Gladitz <nilsgladitz at gmail.com>
CommitDate: Mon Nov 18 17:53:03 2013 +0100

    TargetNames: extracted cmGlobalGenerator::IsReservedTarget, added INSTALL

diff --git a/Source/cmAddCustomTargetCommand.cxx b/Source/cmAddCustomTargetCommand.cxx
index e2a87f1..ef62523 100644
--- a/Source/cmAddCustomTargetCommand.cxx
+++ b/Source/cmAddCustomTargetCommand.cxx
@@ -12,6 +12,7 @@
 #include "cmAddCustomTargetCommand.h"
 
 #include "cmGeneratorExpression.h"
+#include "cmGlobalGenerator.h"
 
 // cmAddCustomTargetCommand
 bool cmAddCustomTargetCommand
@@ -155,7 +156,8 @@ bool cmAddCustomTargetCommand
   // 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);
+  bool nameOk = cmGeneratorExpression::IsValidTargetName(targetName) &&
+    !cmGlobalGenerator::IsReservedTarget(targetName);
   if (nameOk)
     {
     nameOk = targetName.find(":") == std::string::npos;
diff --git a/Source/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx
index 3ce0ce9..a352be0 100644
--- a/Source/cmAddExecutableCommand.cxx
+++ b/Source/cmAddExecutableCommand.cxx
@@ -69,7 +69,9 @@ bool cmAddExecutableCommand
       }
     }
 
-  bool nameOk = cmGeneratorExpression::IsValidTargetName(exename);
+  bool nameOk = cmGeneratorExpression::IsValidTargetName(exename) &&
+    !cmGlobalGenerator::IsReservedTarget(exename);
+
   if (nameOk && !importTarget && !isAlias)
     {
     nameOk = exename.find(":") == std::string::npos;
diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx
index da4e1d1..0f98f35 100644
--- a/Source/cmAddLibraryCommand.cxx
+++ b/Source/cmAddLibraryCommand.cxx
@@ -109,7 +109,9 @@ bool cmAddLibraryCommand
       }
     }
 
-  bool nameOk = cmGeneratorExpression::IsValidTargetName(libName);
+  bool nameOk = cmGeneratorExpression::IsValidTargetName(libName) &&
+    !cmGlobalGenerator::IsReservedTarget(libName);
+
   if (nameOk && !importTarget && !isAlias)
     {
     nameOk = libName.find(":") == std::string::npos;
diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx
index 80ebcd4..f34a35b 100644
--- a/Source/cmGeneratorExpression.cxx
+++ b/Source/cmGeneratorExpression.cxx
@@ -449,39 +449,10 @@ 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_.:+-]+$");
 
-  if(!targetNameValidator.find(input.c_str()))
-    {
-    return false;
-    }
-
-  for(const char** reservedTarget = reservedTargets;
-    *reservedTarget; ++reservedTarget)
-    {
-    if(input == *reservedTarget) return false;
-    }
-
-  return true;
+  return targetNameValidator.find(input.c_str());
 }
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index b2a0ef7..b76b943 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -2466,6 +2466,37 @@ void cmGlobalGenerator::AddTarget(cmTarget* t)
     }
 }
 
+bool cmGlobalGenerator::IsReservedTarget(std::string const& name)
+{
+  // The following is a list of targets reserved
+  // by one or more of the cmake generators.
+
+  // Adding additional targets to this list will require a policy!
+  const char* reservedTargets[] =
+  {
+    "all", "ALL_BUILD",
+    "help",
+    "install", "INSTALL",
+    "preinstall",
+    "clean",
+    "edit_cache",
+    "rebuild_cache",
+    "test", "RUN_TESTS",
+    "package", "PACKAGE",
+    "package_source",
+    "ZERO_CHECK",
+    0
+  };
+
+  for(const char** reservedTarget = reservedTargets;
+    *reservedTarget; ++reservedTarget)
+    {
+    if(name == *reservedTarget) return true;
+    }
+
+  return false;
+}
+
 void cmGlobalGenerator::SetExternalMakefileProjectGenerator(
                             cmExternalMakefileProjectGenerator *extraGenerator)
 {
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 2761158..8aebae8 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -239,6 +239,8 @@ public:
 
   void AddTarget(cmTarget* t);
 
+  static bool IsReservedTarget(std::string const& name);
+
   virtual const char* GetAllTargetName()         const { return "ALL_BUILD"; }
   virtual const char* GetInstallTargetName()       const { return "INSTALL"; }
   virtual const char* GetInstallLocalTargetName()  const { return 0; }

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

Summary of changes:
 Source/cmAddCustomTargetCommand.cxx |    4 +++-
 Source/cmAddExecutableCommand.cxx   |    4 +++-
 Source/cmAddLibraryCommand.cxx      |    4 +++-
 Source/cmGeneratorExpression.cxx    |   31 +------------------------------
 Source/cmGlobalGenerator.cxx        |   31 +++++++++++++++++++++++++++++++
 Source/cmGlobalGenerator.h          |    2 ++
 6 files changed, 43 insertions(+), 33 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list