[Cmake-commits] CMake branch, next, updated. v2.8.11.2-3032-g8e3f6e7

Stephen Kelly steveire at gmail.com
Thu Jul 11 03:21:31 EDT 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  8e3f6e702e1fa04c72284ffc70d58e84d0fe1c42 (commit)
       via  cf1eeb57d5bb39f2d4daa1d0b8d39cb95961fad7 (commit)
      from  f29dff967e93630268a750f486f8242c4910bc65 (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=8e3f6e702e1fa04c72284ffc70d58e84d0fe1c42
commit 8e3f6e702e1fa04c72284ffc70d58e84d0fe1c42
Merge: f29dff9 cf1eeb5
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Thu Jul 11 03:21:27 2013 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Thu Jul 11 03:21:27 2013 -0400

    Merge topic 'target-policies' into next
    
    cf1eeb5 Genex: Make CMP0021 and CMP0022 usable with TARGET_POLICY


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cf1eeb57d5bb39f2d4daa1d0b8d39cb95961fad7
commit cf1eeb57d5bb39f2d4daa1d0b8d39cb95961fad7
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Fri Jun 28 11:25:40 2013 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Thu Jul 11 09:19:49 2013 +0200

    Genex: Make CMP0021 and CMP0022 usable with TARGET_POLICY
    
    Use preprocessor loops and add a unit test for the appropriate
    policies. All policies whose value is recorded at target creation
    time should be part of this list.

diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx
index 08d9d03..2bdff78 100644
--- a/Source/cmGeneratorExpressionEvaluator.cxx
+++ b/Source/cmGeneratorExpressionEvaluator.cxx
@@ -1033,10 +1033,13 @@ static const struct TargetNameNode : public cmGeneratorExpressionNode
 
 //----------------------------------------------------------------------------
 static const char* targetPolicyWhitelist[] = {
-    "CMP0003"
-  , "CMP0004"
-  , "CMP0008"
-  , "CMP0020"
+  0
+#define TARGET_POLICY_STRING(POLICY) \
+  , #POLICY
+
+  CM_FOR_EACH_TARGET_POLICY(TARGET_POLICY_STRING)
+
+#undef TARGET_POLICY_STRING
 };
 
 cmPolicies::PolicyStatus statusForTarget(cmTarget *tgt, const char *policy)
@@ -1047,10 +1050,7 @@ cmPolicies::PolicyStatus statusForTarget(cmTarget *tgt, const char *policy)
     return tgt->GetPolicyStatus ## POLICY (); \
   } \
 
-  RETURN_POLICY(CMP0003)
-  RETURN_POLICY(CMP0004)
-  RETURN_POLICY(CMP0008)
-  RETURN_POLICY(CMP0020)
+  CM_FOR_EACH_TARGET_POLICY(RETURN_POLICY)
 
 #undef RETURN_POLICY
 
@@ -1066,10 +1066,7 @@ cmPolicies::PolicyID policyForString(const char *policy_id)
     return cmPolicies:: POLICY_ID; \
   } \
 
-  RETURN_POLICY_ID(CMP0003)
-  RETURN_POLICY_ID(CMP0004)
-  RETURN_POLICY_ID(CMP0008)
-  RETURN_POLICY_ID(CMP0020)
+  CM_FOR_EACH_TARGET_POLICY(RETURN_POLICY_ID)
 
 #undef RETURN_POLICY_ID
 
@@ -1099,7 +1096,7 @@ static const struct TargetPolicyNode : public cmGeneratorExpressionNode
 
     context->HadContextSensitiveCondition = true;
 
-    for (size_t i = 0;
+    for (size_t i = 1;
          i < (sizeof(targetPolicyWhitelist) /
               sizeof(*targetPolicyWhitelist));
          ++i)
@@ -1125,8 +1122,17 @@ static const struct TargetPolicyNode : public cmGeneratorExpressionNode
       }
     reportError(context, content->GetOriginalExpression(),
       "$<TARGET_POLICY:prop> may only be used with a limited number of "
-      "policies.  Currently it may be used with policies CMP0003, CMP0004, "
-      "CMP0008 and CMP0020."
+      "policies.  Currently it may be used with the following policies:\n"
+
+#define STRINGIFY_HELPER(X) #X
+#define STRINGIFY(X) STRINGIFY_HELPER(X)
+
+#define TARGET_POLICY_LIST_ITEM(POLICY) \
+      " * " STRINGIFY(POLICY) "\n"
+
+      CM_FOR_EACH_TARGET_POLICY(TARGET_POLICY_LIST_ITEM)
+
+#undef TARGET_POLICY_LIST_ITEM
       );
     return std::string();
   }
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 1dbf665..87b65ce 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -191,13 +191,14 @@ cmTargetInternals::~cmTargetInternals()
 //----------------------------------------------------------------------------
 cmTarget::cmTarget()
 {
+#define INITIALIZE_TARGET_POLICY_MEMBER(POLICY) \
+  this->PolicyStatus ## POLICY = cmPolicies::WARN;
+
+  CM_FOR_EACH_TARGET_POLICY(INITIALIZE_TARGET_POLICY_MEMBER)
+
+#undef INITIALIZE_TARGET_POLICY_MEMBER
+
   this->Makefile = 0;
-  this->PolicyStatusCMP0003 = cmPolicies::WARN;
-  this->PolicyStatusCMP0004 = cmPolicies::WARN;
-  this->PolicyStatusCMP0008 = cmPolicies::WARN;
-  this->PolicyStatusCMP0020 = cmPolicies::WARN;
-  this->PolicyStatusCMP0021 = cmPolicies::WARN;
-  this->PolicyStatusCMP0022 = cmPolicies::WARN;
   this->LinkLibrariesAnalyzed = false;
   this->HaveInstallRule = false;
   this->DLLPlatform = false;
@@ -1694,18 +1695,13 @@ void cmTarget::SetMakefile(cmMakefile* mf)
   this->SetPropertyDefault("POSITION_INDEPENDENT_CODE", 0);
 
   // Record current policies for later use.
-  this->PolicyStatusCMP0003 =
-    this->Makefile->GetPolicyStatus(cmPolicies::CMP0003);
-  this->PolicyStatusCMP0004 =
-    this->Makefile->GetPolicyStatus(cmPolicies::CMP0004);
-  this->PolicyStatusCMP0008 =
-    this->Makefile->GetPolicyStatus(cmPolicies::CMP0008);
-  this->PolicyStatusCMP0020 =
-    this->Makefile->GetPolicyStatus(cmPolicies::CMP0020);
-  this->PolicyStatusCMP0021 =
-    this->Makefile->GetPolicyStatus(cmPolicies::CMP0021);
-  this->PolicyStatusCMP0022 =
-    this->Makefile->GetPolicyStatus(cmPolicies::CMP0022);
+#define CAPTURE_TARGET_POLICY(POLICY) \
+  this->PolicyStatus ## POLICY = \
+    this->Makefile->GetPolicyStatus(cmPolicies::POLICY);
+
+  CM_FOR_EACH_TARGET_POLICY(CAPTURE_TARGET_POLICY)
+
+#undef CAPTURE_TARGET_POLICY
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index d7ee332..273f4e9 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -19,6 +19,14 @@
 
 #include <cmsys/auto_ptr.hxx>
 
+#define CM_FOR_EACH_TARGET_POLICY(F) \
+  F(CMP0003) \
+  F(CMP0004) \
+  F(CMP0008) \
+  F(CMP0020) \
+  F(CMP0021) \
+  F(CMP0022)
+
 class cmake;
 class cmMakefile;
 class cmSourceFile;
@@ -91,29 +99,13 @@ public:
   void SetMakefile(cmMakefile *mf);
   cmMakefile *GetMakefile() const { return this->Makefile;};
 
-  /** Get the status of policy CMP0003 when the target was created.  */
-  cmPolicies::PolicyStatus GetPolicyStatusCMP0003() const
-    { return this->PolicyStatusCMP0003; }
-
-  /** Get the status of policy CMP0004 when the target was created.  */
-  cmPolicies::PolicyStatus GetPolicyStatusCMP0004() const
-    { return this->PolicyStatusCMP0004; }
-
-  /** Get the status of policy CMP0008 when the target was created.  */
-  cmPolicies::PolicyStatus GetPolicyStatusCMP0008() const
-    { return this->PolicyStatusCMP0008; }
+#define DECLARE_TARGET_POLICY(POLICY) \
+  cmPolicies::PolicyStatus GetPolicyStatus ## POLICY () const \
+    { return this->PolicyStatus ## POLICY; }
 
-  /** Get the status of policy CMP0020 when the target was created.  */
-  cmPolicies::PolicyStatus GetPolicyStatusCMP0020() const
-    { return this->PolicyStatusCMP0020; }
+  CM_FOR_EACH_TARGET_POLICY(DECLARE_TARGET_POLICY)
 
-  /** Get the status of policy CMP0021 when the target was created.  */
-  cmPolicies::PolicyStatus GetPolicyStatusCMP0021() const
-    { return this->PolicyStatusCMP0021; }
-
-  /** Get the status of policy CMP0022 when the target was created.  */
-  cmPolicies::PolicyStatus GetPolicyStatusCMP0022() const
-    { return this->PolicyStatusCMP0022; }
+#undef DECLARE_TARGET_POLICY
 
   /**
    * Get the list of the custom commands for this target
@@ -694,12 +686,12 @@ private:
   cmMakefile* Makefile;
 
   // Policy status recorded when target was created.
-  cmPolicies::PolicyStatus PolicyStatusCMP0003;
-  cmPolicies::PolicyStatus PolicyStatusCMP0004;
-  cmPolicies::PolicyStatus PolicyStatusCMP0008;
-  cmPolicies::PolicyStatus PolicyStatusCMP0020;
-  cmPolicies::PolicyStatus PolicyStatusCMP0021;
-  cmPolicies::PolicyStatus PolicyStatusCMP0022;
+#define TARGET_POLICY_MEMBER(POLICY) \
+  cmPolicies::PolicyStatus PolicyStatus ## POLICY;
+
+  CM_FOR_EACH_TARGET_POLICY(TARGET_POLICY_MEMBER)
+
+#undef TARGET_POLICY_MEMBER
 
   // Internal representation details.
   friend class cmTargetInternals;
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index e07c42f..7fd3dba 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -96,6 +96,7 @@ add_RunCMake_test(list)
 add_RunCMake_test(try_compile)
 add_RunCMake_test(variable_watch)
 add_RunCMake_test(CMP0004)
+add_RunCMake_test(TargetPolicies)
 
 find_package(Qt4 QUIET)
 find_package(Qt5Core QUIET)
diff --git a/Tests/RunCMake/TargetPolicies/CMakeLists.txt b/Tests/RunCMake/TargetPolicies/CMakeLists.txt
new file mode 100644
index 0000000..e8db6b0
--- /dev/null
+++ b/Tests/RunCMake/TargetPolicies/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 2.8)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/TargetPolicies/PolicyList-result.txt b/Tests/RunCMake/TargetPolicies/PolicyList-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/TargetPolicies/PolicyList-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt
new file mode 100644
index 0000000..6e83b09
--- /dev/null
+++ b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt
@@ -0,0 +1,14 @@
+CMake Error:
+  Error evaluating generator expression:
+
+    \$<TARGET_POLICY:NOT_A_POLICY>
+
+  \$<TARGET_POLICY:prop> may only be used with a limited number of policies.
+  Currently it may be used with the following policies:
+
+   \* CMP0003
+   \* CMP0004
+   \* CMP0008
+   \* CMP0020
+   \* CMP0021
+   \* CMP0022
diff --git a/Tests/RunCMake/TargetPolicies/PolicyList.cmake b/Tests/RunCMake/TargetPolicies/PolicyList.cmake
new file mode 100644
index 0000000..c290b65
--- /dev/null
+++ b/Tests/RunCMake/TargetPolicies/PolicyList.cmake
@@ -0,0 +1,8 @@
+
+enable_language(CXX)
+
+add_library(empty empty.cpp)
+target_compile_definitions(empty
+  PRIVATE
+    $<$<TARGET_POLICY:NOT_A_POLICY>:SOME_DEFINE>
+)
diff --git a/Tests/RunCMake/TargetPolicies/RunCMakeTest.cmake b/Tests/RunCMake/TargetPolicies/RunCMakeTest.cmake
new file mode 100644
index 0000000..7a94630
--- /dev/null
+++ b/Tests/RunCMake/TargetPolicies/RunCMakeTest.cmake
@@ -0,0 +1,3 @@
+include(RunCMake)
+
+run_cmake(PolicyList)
diff --git a/Tests/RunCMake/TargetPolicies/empty.cpp b/Tests/RunCMake/TargetPolicies/empty.cpp
new file mode 100644
index 0000000..7279c5e
--- /dev/null
+++ b/Tests/RunCMake/TargetPolicies/empty.cpp
@@ -0,0 +1,7 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+int empty(void)
+{
+  return 0;
+}

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

Summary of changes:
 Source/cmGeneratorExpressionEvaluator.cxx          |   36 +++++++++------
 Source/cmTarget.cxx                                |   32 ++++++--------
 Source/cmTarget.h                                  |   46 ++++++++-----------
 Tests/RunCMake/CMakeLists.txt                      |    1 +
 .../{CMP0004 => TargetPolicies}/CMakeLists.txt     |    0
 .../PolicyList-result.txt}                         |    0
 .../RunCMake/TargetPolicies/PolicyList-stderr.txt  |   14 ++++++
 Tests/RunCMake/TargetPolicies/PolicyList.cmake     |    8 +++
 Tests/RunCMake/TargetPolicies/RunCMakeTest.cmake   |    3 +
 .../TargetPolicies}/empty.cpp                      |    0
 10 files changed, 80 insertions(+), 60 deletions(-)
 copy Tests/RunCMake/{CMP0004 => TargetPolicies}/CMakeLists.txt (100%)
 copy Tests/RunCMake/{CMP0004/CMP0004-NEW-result.txt => TargetPolicies/PolicyList-result.txt} (100%)
 create mode 100644 Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt
 create mode 100644 Tests/RunCMake/TargetPolicies/PolicyList.cmake
 create mode 100644 Tests/RunCMake/TargetPolicies/RunCMakeTest.cmake
 copy Tests/{IncludeDirectories/TargetIncludeDirectories => RunCMake/TargetPolicies}/empty.cpp (100%)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list