[Cmake-commits] CMake branch, next, updated. v2.8.9-556-g33d81a5

Stephen Kelly steveire at gmail.com
Mon Sep 17 10:19:42 EDT 2012


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  33d81a51278de8d2b45c566d901c680330ce4b2c (commit)
       via  3e711580249fbce6837dae38724c9db91f04dc87 (commit)
      from  d36a52b1202b9603729bc3a946f893c472ea1101 (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=33d81a51278de8d2b45c566d901c680330ce4b2c
commit 33d81a51278de8d2b45c566d901c680330ce4b2c
Merge: d36a52b 3e71158
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Mon Sep 17 10:19:40 2012 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Mon Sep 17 10:19:40 2012 -0400

    Merge topic 'generator-expression-refactor' into next
    
    3e71158 Use static evaluation of target property to generate.


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3e711580249fbce6837dae38724c9db91f04dc87
commit 3e711580249fbce6837dae38724c9db91f04dc87
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Mon Sep 17 16:15:37 2012 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Mon Sep 17 16:18:24 2012 +0200

    Use static evaluation of target property to generate.
    
    Avoid compiler warnings emitted otherwise.

diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx
index f6d2db1..0dd8ac1 100644
--- a/Source/cmGeneratorExpressionEvaluator.cxx
+++ b/Source/cmGeneratorExpressionEvaluator.cxx
@@ -179,12 +179,116 @@ static const struct ConfigurationTestNode : public cmGeneratorExpressionNode
   }
 } configurationTestNode;
 
-#if defined(__BORLANDC__)
-# pragma warn -8008 /* condition is always true */
-# pragma warn -8066 /* unreachable code */
-// Borland gets confused about the template argument bools
-// used in if statements.
-#endif
+//----------------------------------------------------------------------------
+template<bool linker, bool soname>
+struct TargetFilesystemArtifactResultCreator
+{
+  static std::string Create(cmTarget* target,
+                            cmGeneratorExpressionContext *context,
+                            const GeneratorExpressionContent *content,
+                            bool hadError);
+};
+
+//----------------------------------------------------------------------------
+template<>
+struct TargetFilesystemArtifactResultCreator<false, true>
+{
+  static std::string Create(cmTarget* target,
+                            cmGeneratorExpressionContext *context,
+                            const GeneratorExpressionContent *content,
+                            bool *hadError)
+  {
+    // The target soname file (.so.1).
+    if(target->IsDLLPlatform())
+      {
+      ::reportError(context, content->GetOriginalExpression(),
+                    "TARGET_SONAME_FILE is not allowed "
+                    "for DLL target platforms.");
+      *hadError = true;
+      return std::string();
+      }
+    if(target->GetType() != cmTarget::SHARED_LIBRARY)
+      {
+      ::reportError(context, content->GetOriginalExpression(),
+                    "TARGET_SONAME_FILE is allowed only for "
+                    "SHARED libraries.");
+      *hadError = true;
+      return std::string();
+      }
+    std::string result = target->GetDirectory(context->Config);
+    result += "/";
+    result += target->GetSOName(context->Config);
+    return result;
+  }
+};
+
+//----------------------------------------------------------------------------
+template<>
+struct TargetFilesystemArtifactResultCreator<true, false>
+{
+  static std::string Create(cmTarget* target,
+                            cmGeneratorExpressionContext *context,
+                            const GeneratorExpressionContent *content,
+                            bool *hadError)
+  {
+    // The file used to link to the target (.so, .lib, .a).
+    if(!target->IsLinkable())
+      {
+      ::reportError(context, content->GetOriginalExpression(),
+                    "TARGET_LINKER_FILE is allowed only for libraries and "
+                    "executables with ENABLE_EXPORTS.");
+      *hadError = true;
+      return std::string();
+      }
+    return target->GetFullPath(context->Config,
+                               target->HasImportLibrary());
+  }
+};
+
+//----------------------------------------------------------------------------
+template<>
+struct TargetFilesystemArtifactResultCreator<false, false>
+{
+  static std::string Create(cmTarget* target,
+                            cmGeneratorExpressionContext *context,
+                            const GeneratorExpressionContent *,
+                            bool *)
+  {
+    return target->GetFullPath(context->Config, false, true);
+  }
+};
+
+
+//----------------------------------------------------------------------------
+template<bool dirQual, bool nameQual>
+struct TargetFilesystemArtifactResultGetter
+{
+  static std::string Get(const std::string &result);
+};
+
+//----------------------------------------------------------------------------
+template<>
+struct TargetFilesystemArtifactResultGetter<false, true>
+{
+  static std::string Get(const std::string &result)
+  { return cmSystemTools::GetFilenameName(result); }
+};
+
+//----------------------------------------------------------------------------
+template<>
+struct TargetFilesystemArtifactResultGetter<true, false>
+{
+  static std::string Get(const std::string &result)
+  { return cmSystemTools::GetFilenamePath(result); }
+};
+
+//----------------------------------------------------------------------------
+template<>
+struct TargetFilesystemArtifactResultGetter<false, false>
+{
+  static std::string Get(const std::string &result)
+  { return result; }
+};
 
 //----------------------------------------------------------------------------
 template<bool linker, bool soname, bool dirQual, bool nameQual>
@@ -225,58 +329,19 @@ struct TargetFilesystemArtifact : public cmGeneratorExpressionNode
       }
     context->Targets.insert(target);
 
-    std::string result;
-
-    // TODO: static_assert(!(linker && soname))
-    if (!linker && !soname)
-      {
-        result = target->GetFullPath(context->Config, false, true);
-      }
-    else if (linker)
+    bool hadError;
+    std::string result =
+                TargetFilesystemArtifactResultCreator<linker, soname>::Create(
+                          target,
+                          context,
+                          content,
+                          &hadError);
+    if (hadError)
       {
-      // The file used to link to the target (.so, .lib, .a).
-      if(!target->IsLinkable())
-        {
-        ::reportError(context, content->GetOriginalExpression(),
-                      "TARGET_LINKER_FILE is allowed only for libraries and "
-                      "executables with ENABLE_EXPORTS.");
-        return std::string();
-        }
-      result = target->GetFullPath(context->Config,
-                                   target->HasImportLibrary());
-      }
-    else if (soname)
-      {
-      // The target soname file (.so.1).
-      if(target->IsDLLPlatform())
-        {
-        ::reportError(context, content->GetOriginalExpression(),
-                      "TARGET_SONAME_FILE is not allowed "
-                      "for DLL target platforms.");
-        return std::string();
-        }
-      if(target->GetType() != cmTarget::SHARED_LIBRARY)
-        {
-        ::reportError(context, content->GetOriginalExpression(),
-                      "TARGET_SONAME_FILE is allowed only for "
-                      "SHARED libraries.");
-        return std::string();
-        }
-      result = target->GetDirectory(context->Config);
-      result += "/";
-      result += target->GetSOName(context->Config);
+      return std::string();
       }
-
-  // TODO: static_assert(!(name && dir))
-  if(nameQual)
-    {
-    return cmSystemTools::GetFilenameName(result);
-    }
-  else if (dirQual)
-    {
-    return cmSystemTools::GetFilenamePath(result);
-    }
-  return result;
+    return
+        TargetFilesystemArtifactResultGetter<dirQual, nameQual>::Get(result);
   }
 };
 

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

Summary of changes:
 Source/cmGeneratorExpressionEvaluator.cxx |  177 ++++++++++++++++++++---------
 1 files changed, 121 insertions(+), 56 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list