[Cmake-commits] CMake branch, next, updated. v2.8.12-4718-ga981063

Stephen Kelly steveire at gmail.com
Thu Oct 31 10:39:48 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  a981063ee9eaeb806b2a18a7e7f46597e87c740e (commit)
       via  f3b65a20e2f8a7c2b57a883f1bd9f739fe12ddb5 (commit)
       via  86d369421ad5da4a6ec3e722252647ce13bc9bd3 (commit)
       via  9efd6a7a8cb3875057fb151853eac3d98443cc28 (commit)
       via  f0fda20d84a4748c04cf2fae90f2e60e8bcf9db3 (commit)
       via  f6565bf8d1e734ca6ebda244073c3d880343fd42 (commit)
       via  983ca2cfcae149ba523c94b73c75fcd10fe1f747 (commit)
      from  dbcff3ae0d2f6fbe56f6383aa96dc579b1f99300 (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=a981063ee9eaeb806b2a18a7e7f46597e87c740e
commit a981063ee9eaeb806b2a18a7e7f46597e87c740e
Merge: dbcff3a f3b65a2
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Thu Oct 31 10:39:39 2013 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Thu Oct 31 10:39:39 2013 -0400

    Merge topic 'target_compile_features' into next
    
    f3b65a2 Base the target_compile_features command on cmTargetPropCommandBase.
    86d3694 cmTarget: Transitively evaluate compiler features.
    9efd6a7 cmTarget: Allow populating COMPILER_FEATURES using generator expressions.
    f0fda20 cmTarget: Make COMPILE_FEATURES available as a target property.
    f6565bf Add target_compile_features command.
    983ca2c Record the compilers capable of the cxx_delegating_constructors feature.


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f3b65a20e2f8a7c2b57a883f1bd9f739fe12ddb5
commit f3b65a20e2f8a7c2b57a883f1bd9f739fe12ddb5
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Wed Oct 30 21:13:44 2013 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Thu Oct 31 15:38:54 2013 +0100

    Base the target_compile_features command on cmTargetPropCommandBase.
    
    This gives us 'free' handling of IMPORTED, ALIAS, INTERFACE,
    non-compilable and missing targets.

diff --git a/Source/cmTargetCompileFeaturesCommand.cxx b/Source/cmTargetCompileFeaturesCommand.cxx
index 4217eb3..6948717 100644
--- a/Source/cmTargetCompileFeaturesCommand.cxx
+++ b/Source/cmTargetCompileFeaturesCommand.cxx
@@ -15,51 +15,50 @@ bool cmTargetCompileFeaturesCommand::InitialPass(
   std::vector<std::string> const& args,
   cmExecutionStatus &)
 {
-  if (args.size() < 3)
-    {
-      this->SetError("called with wrong number of arguments.");
-      return false;
-    }
-  cmTarget *target = this->Makefile->FindTargetToUse(args[0].c_str());
+  return this->HandleArguments(args, "COMPILE_FEATURES", NO_FLAGS);
+}
 
-  if(!target)
-    {
-    this->SetError("specified invalid target.");
-    return false;
-    }
+void cmTargetCompileFeaturesCommand
+::HandleImportedTarget(const std::string &tgt)
+{
+  cmOStringStream e;
+  e << "Cannot specify compile features for imported target \""
+    << tgt << "\".";
+  this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+}
 
-  if(target->IsImported())
-    {
-    this->SetError("may not be used with an IMPORTED target.");
-    return false;
-    }
+void cmTargetCompileFeaturesCommand
+::HandleMissingTarget(const std::string &name)
+{
+  cmOStringStream e;
+  e << "Cannot specify compile features for target \"" << name << "\" "
+       "which is not built by this project.";
+  this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+}
 
-  const bool interfaceOnly = args[1] == "INTERFACE";
-  if(args[1] != "PRIVATE" && args[1] != "PUBLIC" && !interfaceOnly)
+//----------------------------------------------------------------------------
+std::string cmTargetCompileFeaturesCommand
+::Join(const std::vector<std::string> &content)
+{
+  std::string defs;
+  std::string sep;
+  for(std::vector<std::string>::const_iterator it = content.begin();
+    it != content.end(); ++it)
     {
-    this->SetError("called with invalid arguments.");
-    return false;
+    defs += sep + *it;
+    sep = ";";
     }
+  return defs;
+}
 
-  for (size_t i = 2; i < args.size(); ++i)
+//----------------------------------------------------------------------------
+void cmTargetCompileFeaturesCommand
+::HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content,
+                                   bool, bool)
+{
+  for(std::vector<std::string>::const_iterator it = content.begin();
+    it != content.end(); ++it)
     {
-    std::string feature = args[i];
-
-    if (!interfaceOnly)
-      {
-      bool result = this->Makefile->AddRequiredTargetFeature(target,
-                                                            feature.c_str());
-
-      if (!result)
-        {
-        this->SetError("specified unknown feature.");
-        return false;
-        }
-      }
-    if (interfaceOnly || args[1] == "PUBLIC")
-      {
-      target->AppendProperty("INTERFACE_COMPILE_FEATURES", feature.c_str());
-      }
+    this->Makefile->AddRequiredTargetFeature(tgt, it->c_str());
     }
-  return true;
 }
diff --git a/Source/cmTargetCompileFeaturesCommand.h b/Source/cmTargetCompileFeaturesCommand.h
index 63beeca..9386c84 100644
--- a/Source/cmTargetCompileFeaturesCommand.h
+++ b/Source/cmTargetCompileFeaturesCommand.h
@@ -12,9 +12,9 @@
 #ifndef cmTargetCompileFeaturesCommand_h
 #define cmTargetCompileFeaturesCommand_h
 
-#include "cmCommand.h"
+#include "cmTargetPropCommandBase.h"
 
-class cmTargetCompileFeaturesCommand : public cmCommand
+class cmTargetCompileFeaturesCommand : public cmTargetPropCommandBase
 {
   virtual cmCommand* Clone()
     {
@@ -26,7 +26,16 @@ class cmTargetCompileFeaturesCommand : public cmCommand
 
   virtual const char* GetName() const { return "target_compile_features";}
 
-  cmTypeMacro(cmTargetCompileFeaturesCommand, cmCommand);
+  cmTypeMacro(cmTargetCompileFeaturesCommand, cmTargetPropCommandBase);
+
+private:
+  virtual void HandleImportedTarget(const std::string &tgt);
+  virtual void HandleMissingTarget(const std::string &name);
+
+  virtual void HandleDirectContent(cmTarget *tgt,
+                                   const std::vector<std::string> &content,
+                                   bool prepend, bool system);
+  virtual std::string Join(const std::vector<std::string> &content);
 };
 
 #endif

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=86d369421ad5da4a6ec3e722252647ce13bc9bd3
commit 86d369421ad5da4a6ec3e722252647ce13bc9bd3
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue Oct 22 01:40:47 2013 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Thu Oct 31 15:38:54 2013 +0100

    cmTarget: Transitively evaluate compiler features.
    
    Extend the interface of the target_compile_features command with
    PUBLIC and INTERFACE keywords. Populate the INTERFACE_COMPILER_FEATURES
    target property if they are set. Consume the INTERFACE_COMPILER_FEATURES
    target property from linked dependent targets to determine the final
    required compiler features and the compile flag, if needed.

diff --git a/Help/command/target_compile_features.rst b/Help/command/target_compile_features.rst
index ebd9611..e33ba4e 100644
--- a/Help/command/target_compile_features.rst
+++ b/Help/command/target_compile_features.rst
@@ -5,7 +5,7 @@ Add expected compiler features to a target.
 
 ::
 
-  target_compile_features(<target> PRIVATE <feature> [...])
+  target_compile_features(<target> <PRIVATE|PUBLIC|INTERFACE> <feature> [...])
 
 Specify compiler features required when compiling a given target.  If the
 feature is not listed in the :variable:`CMAKE_CXX_COMPILE_FEATURES` variable,
@@ -13,6 +13,12 @@ then an error will be reported by CMake.  If the use of the feature requires
 an additional compiler flag, such as --std=c++11, the flag will be added
 automatically.
 
+The INTERFACE, PUBLIC and PRIVATE keywords are required to specify the
+scope of the features.  PRIVATE and PUBLIC items will
+populate the :prop_tgt:`COMPILE_FEATURES` property of <target>.  PUBLIC and
+INTERFACE items will populate the :prop_tgt:`INTERFACE_COMPILE_FEATURES` property
+of <target>.  Repeated calls for the same <target> append items in the order called.
+
 The named <target> must have been created by a command such as
 add_executable or add_library and must not be an IMPORTED target.
 
diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx
index 92dc054..cfcaa70 100644
--- a/Source/cmGeneratorExpressionDAGChecker.cxx
+++ b/Source/cmGeneratorExpressionDAGChecker.cxx
@@ -210,3 +210,11 @@ bool cmGeneratorExpressionDAGChecker::EvaluatingCompileOptions() const
   return (strcmp(prop, "COMPILE_OPTIONS") == 0
        || strcmp(prop, "INTERFACE_COMPILE_OPTIONS") == 0 );
 }
+
+//----------------------------------------------------------------------------
+bool cmGeneratorExpressionDAGChecker::EvaluatingCompileFeatures() const
+{
+  const char *prop = this->Property.c_str();
+  return (strcmp(prop, "COMPILE_FEATURES") == 0
+       || strcmp(prop, "INTERFACE_COMPILE_FEATURES") == 0);
+}
diff --git a/Source/cmGeneratorExpressionDAGChecker.h b/Source/cmGeneratorExpressionDAGChecker.h
index c8594e7..0502430 100644
--- a/Source/cmGeneratorExpressionDAGChecker.h
+++ b/Source/cmGeneratorExpressionDAGChecker.h
@@ -20,13 +20,15 @@
   F(EvaluatingIncludeDirectories) \
   F(EvaluatingSystemIncludeDirectories) \
   F(EvaluatingCompileDefinitions) \
-  F(EvaluatingCompileOptions)
+  F(EvaluatingCompileOptions) \
+  F(EvaluatingCompileFeatures)
 
 #define CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(F) \
   F(INCLUDE_DIRECTORIES) \
   F(SYSTEM_INCLUDE_DIRECTORIES) \
   F(COMPILE_DEFINITIONS) \
-  F(COMPILE_OPTIONS)
+  F(COMPILE_OPTIONS) \
+  F(COMPILE_FEATURES)
 
 //----------------------------------------------------------------------------
 struct cmGeneratorExpressionDAGChecker
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index f091765..edbcfc6 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -140,6 +140,7 @@ public:
   };
   std::vector<TargetPropertyEntry*> IncludeDirectoriesEntries;
   std::vector<TargetPropertyEntry*> CompileOptionsEntries;
+  std::vector<TargetPropertyEntry*> CompileFeaturesEntries;
   std::vector<TargetPropertyEntry*> CompileDefinitionsEntries;
   std::vector<cmValueWithOrigin> LinkInterfacePropertyEntries;
 
@@ -148,11 +149,14 @@ public:
   std::map<std::string, std::vector<TargetPropertyEntry*> >
                                 CachedLinkInterfaceCompileOptionsEntries;
   std::map<std::string, std::vector<TargetPropertyEntry*> >
+                                CachedLinkInterfaceCompileFeaturesEntries;
+  std::map<std::string, std::vector<TargetPropertyEntry*> >
                                 CachedLinkInterfaceCompileDefinitionsEntries;
 
   std::map<std::string, bool> CacheLinkInterfaceIncludeDirectoriesDone;
   std::map<std::string, bool> CacheLinkInterfaceCompileDefinitionsDone;
   std::map<std::string, bool> CacheLinkInterfaceCompileOptionsDone;
+  std::map<std::string, bool> CacheLinkInterfaceCompileFeaturesDone;
 };
 
 //----------------------------------------------------------------------------
@@ -210,6 +214,7 @@ cmTarget::cmTarget()
   this->BuildInterfaceIncludesAppended = false;
   this->DebugIncludesDone = false;
   this->DebugCompileOptionsDone = false;
+  this->DebugCompileFeaturesDone = false;
   this->DebugCompileDefinitionsDone = false;
 }
 
@@ -2542,6 +2547,121 @@ void cmTarget::GetCompileDefinitions(std::vector<std::string> &list,
 }
 
 //----------------------------------------------------------------------------
+static void processCompileFeatures(cmTarget *tgt,
+      const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries,
+      std::vector<std::string> &options,
+      std::set<std::string> &uniqueOptions,
+      cmGeneratorExpressionDAGChecker *dagChecker,
+      const char *config, bool debugOptions)
+{
+  processCompileOptionsInternal(tgt, entries, options, uniqueOptions,
+                                dagChecker, config, debugOptions, "features");
+}
+
+//----------------------------------------------------------------------------
+void cmTarget::GetCompileFeatures(std::vector<std::string> &result,
+                                 const char *config)
+{
+  std::set<std::string> uniqueFeatures;
+  cmListFileBacktrace lfbt;
+
+  cmGeneratorExpressionDAGChecker dagChecker(lfbt,
+                                             this->GetName(),
+                                             "COMPILE_FEATURES",
+                                             0, 0);
+
+  std::vector<std::string> debugProperties;
+  const char *debugProp =
+              this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES");
+  if (debugProp)
+    {
+    cmSystemTools::ExpandListArgument(debugProp, debugProperties);
+    }
+
+  bool debugFeatures = !this->DebugCompileFeaturesDone
+                    && std::find(debugProperties.begin(),
+                                 debugProperties.end(),
+                                 "COMPILE_FEATURES")
+                        != debugProperties.end();
+
+  if (this->Makefile->IsGeneratingBuildSystem())
+    {
+    this->DebugCompileFeaturesDone = true;
+    }
+
+  processCompileFeatures(this,
+                            this->Internal->CompileFeaturesEntries,
+                            result,
+                            uniqueFeatures,
+                            &dagChecker,
+                            config,
+                            debugFeatures);
+
+  std::string configString = config ? config : "";
+  if (!this->Internal->CacheLinkInterfaceCompileFeaturesDone[configString])
+    {
+
+    for (std::vector<cmValueWithOrigin>::const_iterator
+        it = this->Internal->LinkInterfacePropertyEntries.begin(),
+        end = this->Internal->LinkInterfacePropertyEntries.end();
+        it != end; ++it)
+      {
+      if (!cmGeneratorExpression::IsValidTargetName(it->Value)
+          && cmGeneratorExpression::Find(it->Value) == std::string::npos)
+        {
+        continue;
+        }
+      {
+      cmGeneratorExpression ge(lfbt);
+      cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
+                                                        ge.Parse(it->Value);
+      std::string targetResult = cge->Evaluate(this->Makefile, config,
+                                        false, this, 0, 0);
+      if (!this->Makefile->FindTargetToUse(targetResult.c_str()))
+        {
+        continue;
+        }
+      }
+      std::string featureGenex = "$<TARGET_PROPERTY:" +
+                              it->Value + ",INTERFACE_COMPILE_FEATURES>";
+      if (cmGeneratorExpression::Find(it->Value) != std::string::npos)
+        {
+        // Because it->Value is a generator expression, ensure that it
+        // evaluates to the non-empty string before being used in the
+        // TARGET_PROPERTY expression.
+        featureGenex = "$<$<BOOL:" + it->Value + ">:" + featureGenex + ">";
+        }
+      cmGeneratorExpression ge(it->Backtrace);
+      cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(
+                                                                featureGenex);
+
+      this->Internal
+        ->CachedLinkInterfaceCompileFeaturesEntries[configString].push_back(
+                        new cmTargetInternals::TargetPropertyEntry(cge,
+                                                              it->Value));
+      }
+    }
+
+  processCompileFeatures(this,
+    this->Internal->CachedLinkInterfaceCompileFeaturesEntries[configString],
+                            result,
+                            uniqueFeatures,
+                            &dagChecker,
+                            config,
+                            debugFeatures);
+
+  if (!this->Makefile->IsGeneratingBuildSystem())
+    {
+    deleteAndClear(this->Internal->CachedLinkInterfaceCompileFeaturesEntries);
+    }
+  else
+    {
+    this->Internal->CacheLinkInterfaceCompileFeaturesDone[configString]
+                                                                      = true;
+    }
+}
+
+//----------------------------------------------------------------------------
 void cmTarget::MaybeInvalidatePropertyCache(const char* prop)
 {
   // Wipe out maps caching information affected by this property.
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 9d62f5f..7663d38 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -530,6 +530,8 @@ public:
 
   void GetCompileOptions(std::vector<std::string> &result,
                          const char *config);
+  void GetCompileFeatures(std::vector<std::string> &result,
+                           const char *config);
 
   bool IsNullImpliedByLinkLibraries(const std::string &p);
   bool IsLinkInterfaceDependentBoolProperty(const std::string &p,
@@ -688,6 +690,7 @@ private:
   bool IsImportedTarget;
   bool DebugIncludesDone;
   bool DebugCompileOptionsDone;
+  bool DebugCompileFeaturesDone;
   bool DebugCompileDefinitionsDone;
   mutable std::set<std::string> LinkImplicitNullProperties;
   bool BuildInterfaceIncludesAppended;
diff --git a/Source/cmTargetCompileFeaturesCommand.cxx b/Source/cmTargetCompileFeaturesCommand.cxx
index 7004865..4217eb3 100644
--- a/Source/cmTargetCompileFeaturesCommand.cxx
+++ b/Source/cmTargetCompileFeaturesCommand.cxx
@@ -34,7 +34,8 @@ bool cmTargetCompileFeaturesCommand::InitialPass(
     return false;
     }
 
-  if(args[1] != "PRIVATE")
+  const bool interfaceOnly = args[1] == "INTERFACE";
+  if(args[1] != "PRIVATE" && args[1] != "PUBLIC" && !interfaceOnly)
     {
     this->SetError("called with invalid arguments.");
     return false;
@@ -44,13 +45,20 @@ bool cmTargetCompileFeaturesCommand::InitialPass(
     {
     std::string feature = args[i];
 
-    bool result = this->Makefile->AddRequiredTargetFeature(target,
-                                                          feature.c_str());
+    if (!interfaceOnly)
+      {
+      bool result = this->Makefile->AddRequiredTargetFeature(target,
+                                                            feature.c_str());
 
-    if (!result)
+      if (!result)
+        {
+        this->SetError("specified unknown feature.");
+        return false;
+        }
+      }
+    if (interfaceOnly || args[1] == "PUBLIC")
       {
-      this->SetError("specified unknown feature.");
-      return false;
+      target->AppendProperty("INTERFACE_COMPILE_FEATURES", feature.c_str());
       }
     }
   return true;
diff --git a/Tests/CMakeCommands/target_compile_features/CMakeLists.txt b/Tests/CMakeCommands/target_compile_features/CMakeLists.txt
index 73e22e0..3d10f24 100644
--- a/Tests/CMakeCommands/target_compile_features/CMakeLists.txt
+++ b/Tests/CMakeCommands/target_compile_features/CMakeLists.txt
@@ -11,3 +11,11 @@ add_executable(target_compile_features main.cpp)
 target_compile_features(target_compile_features
   PRIVATE cxx_delegating_constructors
 )
+
+add_library(lib_delegating_constructors lib_delegating_constructors.cpp)
+target_compile_features(lib_delegating_constructors
+  PUBLIC cxx_delegating_constructors
+)
+
+add_executable(lib_user lib_user.cpp)
+target_link_libraries(lib_user lib_delegating_constructors)
diff --git a/Tests/CMakeCommands/target_compiler_features/lib_delegating_constructors.cpp b/Tests/CMakeCommands/target_compiler_features/lib_delegating_constructors.cpp
new file mode 100644
index 0000000..e597acd
--- /dev/null
+++ b/Tests/CMakeCommands/target_compiler_features/lib_delegating_constructors.cpp
@@ -0,0 +1,8 @@
+
+#include "lib_delegating_constructors.h"
+
+Foo::Foo(int i)
+  : m_i(i)
+{
+
+}
diff --git a/Tests/CMakeCommands/target_compiler_features/lib_delegating_constructors.h b/Tests/CMakeCommands/target_compiler_features/lib_delegating_constructors.h
new file mode 100644
index 0000000..75be701
--- /dev/null
+++ b/Tests/CMakeCommands/target_compiler_features/lib_delegating_constructors.h
@@ -0,0 +1,17 @@
+
+#include <cstring>
+
+class Foo
+{
+public:
+  Foo(int i);
+
+  Foo(const char *a)
+    : Foo(strlen(a))
+  {
+
+  }
+
+private:
+  int m_i;
+};
diff --git a/Tests/CMakeCommands/target_compiler_features/lib_user.cpp b/Tests/CMakeCommands/target_compiler_features/lib_user.cpp
new file mode 100644
index 0000000..83ad51e
--- /dev/null
+++ b/Tests/CMakeCommands/target_compiler_features/lib_user.cpp
@@ -0,0 +1,27 @@
+
+#include "lib_delegating_constructors.h"
+
+class Bar
+{
+  Bar(int i)
+    :m_i(i)
+  {
+
+  }
+
+  Bar(const char *a)
+    : Bar(strlen(a))
+  {
+
+  }
+
+private:
+  int m_i;
+};
+
+int main(int argc, char **argv)
+{
+  Foo f("hello");
+  Foo b("world");
+  return 0;
+}

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9efd6a7a8cb3875057fb151853eac3d98443cc28
commit 9efd6a7a8cb3875057fb151853eac3d98443cc28
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue Oct 22 15:05:49 2013 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Thu Oct 31 15:38:54 2013 +0100

    cmTarget: Allow populating COMPILER_FEATURES using generator expressions.

diff --git a/Help/command/target_compile_features.rst b/Help/command/target_compile_features.rst
index aa438b2..ebd9611 100644
--- a/Help/command/target_compile_features.rst
+++ b/Help/command/target_compile_features.rst
@@ -15,3 +15,8 @@ automatically.
 
 The named <target> must have been created by a command such as
 add_executable or add_library and must not be an IMPORTED target.
+
+Arguments to target_compile_features may use "generator expressions"
+with the syntax "$<...>".
+See the :manual:`cmake-generator-expressions(7)` manual for available
+expressions.
diff --git a/Help/prop_tgt/COMPILE_FEATURES.rst b/Help/prop_tgt/COMPILE_FEATURES.rst
index b2c6145..3ef743c 100644
--- a/Help/prop_tgt/COMPILE_FEATURES.rst
+++ b/Help/prop_tgt/COMPILE_FEATURES.rst
@@ -5,3 +5,7 @@ Compiler features enabled for this target.
 
 The list of features in this property are a subset of the features listed
 in the :variable:`CMAKE_CXX_COMPILE_FEATURES` variable.
+
+Contents of COMPILE_FEATURES may use "generator expressions" with the
+syntax "$<...>".  See the :manual:`cmake-generator-expressions(7)` manual for
+available expressions.
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 5e06c5e..2542f71 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -4453,6 +4453,11 @@ static const char * const CXX_STANDARDS[] = {
 bool cmMakefile::
 AddRequiredTargetFeature(cmTarget *target, const char *feature) const
 {
+  if (cmGeneratorExpression::Find(feature) != std::string::npos)
+    {
+    target->AppendProperty("COMPILE_FEATURES", feature);
+    return true;
+    }
   bool isCxxFeature = std::find_if(cmArrayBegin(CXX_FEATURES) + 1,
               cmArrayEnd(CXX_FEATURES), cmStrCmp(feature))
               != cmArrayEnd(CXX_FEATURES);

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f0fda20d84a4748c04cf2fae90f2e60e8bcf9db3
commit f0fda20d84a4748c04cf2fae90f2e60e8bcf9db3
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue Oct 22 14:58:21 2013 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Thu Oct 31 15:38:53 2013 +0100

    cmTarget: Make COMPILE_FEATURES available as a target property.

diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst
index f7663d7..79081c6 100644
--- a/Help/manual/cmake-properties.7.rst
+++ b/Help/manual/cmake-properties.7.rst
@@ -88,6 +88,7 @@ Properties on Targets
    /prop_tgt/COMPILE_DEFINITIONS
    /prop_tgt/COMPILE_FLAGS
    /prop_tgt/COMPILE_OPTIONS
+   /prop_tgt/COMPILE_FEATURES
    /prop_tgt/CONFIG_OUTPUT_NAME
    /prop_tgt/CONFIG_POSTFIX
    /prop_tgt/CXX_STANDARD
diff --git a/Help/prop_tgt/COMPILE_FEATURES.rst b/Help/prop_tgt/COMPILE_FEATURES.rst
new file mode 100644
index 0000000..b2c6145
--- /dev/null
+++ b/Help/prop_tgt/COMPILE_FEATURES.rst
@@ -0,0 +1,7 @@
+COMPILE_FEATURES
+----------------
+
+Compiler features enabled for this target.
+
+The list of features in this property are a subset of the features listed
+in the :variable:`CMAKE_CXX_COMPILE_FEATURES` variable.
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 1c73583..5e06c5e 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -4484,6 +4484,8 @@ AddRequiredTargetFeature(cmTarget *target, const char *feature) const
     return false;
     }
 
+  target->AppendProperty("COMPILE_FEATURES", feature);
+
   bool need98 = true;
   bool need11 = false;
   bool needExt = false;
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 1f5cb85..f091765 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -187,6 +187,7 @@ cmTargetInternals::~cmTargetInternals()
 {
   deleteAndClear(this->CachedLinkInterfaceIncludeDirectoriesEntries);
   deleteAndClear(this->CachedLinkInterfaceCompileOptionsEntries);
+  deleteAndClear(this->CachedLinkInterfaceCompileFeaturesEntries);
   deleteAndClear(this->CachedLinkInterfaceCompileDefinitionsEntries);
 }
 
@@ -1722,6 +1723,17 @@ void cmTarget::SetProperty(const char* prop, const char* value)
                           new cmTargetInternals::TargetPropertyEntry(cge));
     return;
     }
+  if(strcmp(prop,"COMPILE_FEATURES") == 0)
+    {
+    cmListFileBacktrace lfbt;
+    this->Makefile->GetBacktrace(lfbt);
+    cmGeneratorExpression ge(lfbt);
+    deleteAndClear(this->Internal->CompileFeaturesEntries);
+    cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
+    this->Internal->CompileFeaturesEntries.push_back(
+                          new cmTargetInternals::TargetPropertyEntry(cge));
+    return;
+    }
   if(strcmp(prop,"COMPILE_DEFINITIONS") == 0)
     {
     cmListFileBacktrace lfbt;
@@ -1787,6 +1799,15 @@ void cmTarget::AppendProperty(const char* prop, const char* value,
               new cmTargetInternals::TargetPropertyEntry(ge.Parse(value)));
     return;
     }
+  if(strcmp(prop,"COMPILE_FEATURES") == 0)
+    {
+    cmListFileBacktrace lfbt;
+    this->Makefile->GetBacktrace(lfbt);
+    cmGeneratorExpression ge(lfbt);
+    this->Internal->CompileFeaturesEntries.push_back(
+              new cmTargetInternals::TargetPropertyEntry(ge.Parse(value)));
+    return;
+    }
   if(strcmp(prop,"COMPILE_DEFINITIONS") == 0)
     {
     cmListFileBacktrace lfbt;
@@ -2381,6 +2402,13 @@ void cmTarget::GetCompileOptions(std::vector<std::string> &result,
     {
     this->Internal->CacheLinkInterfaceCompileOptionsDone[configString] = true;
     }
+  std::vector<std::string> features;
+  this->GetCompileFeatures(features, config);
+  for(std::vector<std::string>::const_iterator it = features.begin();
+      it != features.end(); ++it)
+    {
+    this->Makefile->AddRequiredTargetFeature(this, it->c_str());
+    }
 }
 
 //----------------------------------------------------------------------------
@@ -2968,6 +2996,24 @@ const char *cmTarget::GetProperty(const char* prop,
       }
     return output.c_str();
     }
+  if(strcmp(prop,"COMPILE_FEATURES") == 0)
+    {
+    static std::string output;
+    output = "";
+    std::string sep;
+    typedef cmTargetInternals::TargetPropertyEntry
+                                TargetPropertyEntry;
+    for (std::vector<TargetPropertyEntry*>::const_iterator
+        it = this->Internal->CompileFeaturesEntries.begin(),
+        end = this->Internal->CompileFeaturesEntries.end();
+        it != end; ++it)
+      {
+      output += sep;
+      output += (*it)->ge->GetInput();
+      sep = ";";
+      }
+    return output.c_str();
+    }
   if(strcmp(prop,"COMPILE_DEFINITIONS") == 0)
     {
     static std::string output;
@@ -6217,6 +6263,7 @@ cmTargetInternalPointer::~cmTargetInternalPointer()
 {
   deleteAndClear(this->Pointer->IncludeDirectoriesEntries);
   deleteAndClear(this->Pointer->CompileOptionsEntries);
+  deleteAndClear(this->Pointer->CompileFeaturesEntries);
   deleteAndClear(this->Pointer->CompileDefinitionsEntries);
   delete this->Pointer;
 }

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f6565bf8d1e734ca6ebda244073c3d880343fd42
commit f6565bf8d1e734ca6ebda244073c3d880343fd42
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Oct 13 14:25:08 2013 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Thu Oct 31 15:38:53 2013 +0100

    Add target_compile_features command.

diff --git a/Help/command/target_compile_features.rst b/Help/command/target_compile_features.rst
new file mode 100644
index 0000000..aa438b2
--- /dev/null
+++ b/Help/command/target_compile_features.rst
@@ -0,0 +1,17 @@
+target_compile_features
+-----------------------
+
+Add expected compiler features to a target.
+
+::
+
+  target_compile_features(<target> PRIVATE <feature> [...])
+
+Specify compiler features required when compiling a given target.  If the
+feature is not listed in the :variable:`CMAKE_CXX_COMPILE_FEATURES` variable,
+then an error will be reported by CMake.  If the use of the feature requires
+an additional compiler flag, such as --std=c++11, the flag will be added
+automatically.
+
+The named <target> must have been created by a command such as
+add_executable or add_library and must not be an IMPORTED target.
diff --git a/Help/manual/cmake-commands.7.rst b/Help/manual/cmake-commands.7.rst
index 71d7375..c199259 100644
--- a/Help/manual/cmake-commands.7.rst
+++ b/Help/manual/cmake-commands.7.rst
@@ -87,6 +87,7 @@ These commands may be used freely in CMake projects.
    /command/source_group
    /command/string
    /command/target_compile_definitions
+   /command/target_compile_features
    /command/target_compile_options
    /command/target_include_directories
    /command/target_link_libraries
diff --git a/Help/variable/CMAKE_CXX_COMPILE_FEATURES.rst b/Help/variable/CMAKE_CXX_COMPILE_FEATURES.rst
index 6be0124..386f5c0 100644
--- a/Help/variable/CMAKE_CXX_COMPILE_FEATURES.rst
+++ b/Help/variable/CMAKE_CXX_COMPILE_FEATURES.rst
@@ -6,3 +6,6 @@ List of features known to the C++ compiler
 These features are known to be available for use with the C++ compiler. This
 list is a subset of the features listed in the :variable:`CMAKE_CXX_KNOWN_FEATURES`
 variable.
+
+The features listed here may be used with the :command:`target_compile_features`
+command.
diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx
index 1e2a85c..8f89fd9 100644
--- a/Source/cmCommands.cxx
+++ b/Source/cmCommands.cxx
@@ -32,6 +32,7 @@
 #include "cmSubdirDependsCommand.cxx"
 #include "cmTargetCompileDefinitionsCommand.cxx"
 #include "cmTargetCompileOptionsCommand.cxx"
+#include "cmTargetCompileFeaturesCommand.cxx"
 #include "cmTargetIncludeDirectoriesCommand.cxx"
 #include "cmTargetPropCommandBase.cxx"
 #include "cmUseMangledMesaCommand.cxx"
@@ -77,6 +78,7 @@ void GetPredefinedCommands(std::list<cmCommand*>&
   commands.push_back(new cmTargetIncludeDirectoriesCommand);
   commands.push_back(new cmTargetCompileDefinitionsCommand);
   commands.push_back(new cmTargetCompileOptionsCommand);
+  commands.push_back(new cmTargetCompileFeaturesCommand);
   commands.push_back(new cmUseMangledMesaCommand);
   commands.push_back(new cmUtilitySourceCommand);
   commands.push_back(new cmVariableRequiresCommand);
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 103d44d..1c73583 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -4437,3 +4437,138 @@ void cmMakefile::RecordPolicies(cmPolicies::PolicyMap& pm)
     pm[pid] = this->GetPolicyStatus(pid);
     }
 }
+
+#define FEATURE_STRING(F) , #F
+
+static const char * const CXX_FEATURES[] = {
+  0
+  FOR_EACH_CXX_FEATURE(FEATURE_STRING)
+};
+
+static const char * const CXX_STANDARDS[] = {
+    "98"
+  , "11"
+};
+
+bool cmMakefile::
+AddRequiredTargetFeature(cmTarget *target, const char *feature) const
+{
+  bool isCxxFeature = std::find_if(cmArrayBegin(CXX_FEATURES) + 1,
+              cmArrayEnd(CXX_FEATURES), cmStrCmp(feature))
+              != cmArrayEnd(CXX_FEATURES);
+  if (!isCxxFeature)
+    {
+    return false;
+    }
+
+  const char* featuresKnown =
+    this->GetDefinition("CMAKE_CXX_COMPILE_FEATURES");
+
+  if (!featuresKnown)
+    {
+    // We know of no features for the compiler at all.
+    return true;
+    }
+
+  std::vector<std::string> availableFeatures;
+  cmSystemTools::ExpandListArgument(featuresKnown, availableFeatures);
+  if (std::find(availableFeatures.begin(),
+                availableFeatures.end(),
+                feature) == availableFeatures.end())
+    {
+    cmOStringStream e;
+    e << "The compiler feature \"" << feature
+      << "\" is not known to compiler \""
+      << this->GetDefinition("CMAKE_CXX_COMPILER_ID") << "\".";
+    this->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+    return false;
+    }
+
+  bool need98 = true;
+  bool need11 = false;
+  bool needExt = false;
+
+  if (const char *prop98 =
+                        this->GetDefinition("CMAKE_CXX98_COMPILE_FEATURES"))
+    {
+    std::vector<std::string> props;
+    cmSystemTools::ExpandListArgument(prop98, props);
+    need98 = std::find(props.begin(), props.end(), feature) != props.end();
+    }
+  if (const char *prop11 =
+          this->GetDefinition("CMAKE_CXX11_COMPILE_FEATURES"))
+    {
+    std::vector<std::string> props;
+    cmSystemTools::ExpandListArgument(prop11, props);
+    need11 = std::find(props.begin(), props.end(), feature) != props.end();
+    }
+
+  if (const char *prop98ext =
+          this->GetDefinition("CMAKE_CXX98_COMPILER_EXTENSIONS"))
+    {
+    std::vector<std::string> props;
+    cmSystemTools::ExpandListArgument(prop98ext, props);
+    needExt = std::find(props.begin(), props.end(), feature) != props.end();
+    }
+  if (const char *prop11ext =
+          this->GetDefinition("CMAKE_CXX11_COMPILER_EXTENSIONS"))
+    {
+    std::vector<std::string> props;
+    cmSystemTools::ExpandListArgument(prop11ext, props);
+    bool need11Ext = std::find(props.begin(), props.end(), feature)
+                      != props.end();
+    need11 = need11Ext;
+    needExt = needExt || need11Ext;
+    }
+
+  const char *existingStandard = target->GetProperty("CXX_STANDARD");
+  if (existingStandard)
+    {
+    if (std::find_if(cmArrayBegin(CXX_STANDARDS), cmArrayEnd(CXX_STANDARDS),
+                  cmStrCmp(existingStandard)) == cmArrayEnd(CXX_STANDARDS))
+      {
+      cmOStringStream e;
+      e << "The CXX_STANDARD property on target \"" << target->GetName()
+        << "\" contained an invalid value: \"" << existingStandard << "\".";
+      this->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+      return false;
+      }
+    }
+  const char * const *existingIt = existingStandard
+                                    ? std::find_if(cmArrayBegin(CXX_STANDARDS),
+                                      cmArrayEnd(CXX_STANDARDS),
+                                      cmStrCmp(existingStandard))
+                                    : cmArrayEnd(CXX_STANDARDS);
+
+  bool set11 = need11 && !existingStandard;
+  bool set98 = need98 && !existingStandard;
+  if (existingStandard && existingIt <
+                                    std::find_if(cmArrayBegin(CXX_STANDARDS),
+                                      cmArrayEnd(CXX_STANDARDS),
+                                      cmStrCmp("11")))
+    {
+    set11 = true;
+    }
+  else if(existingStandard && existingIt <
+                                    std::find_if(cmArrayBegin(CXX_STANDARDS),
+                                      cmArrayEnd(CXX_STANDARDS),
+                                      cmStrCmp("98")))
+    {
+    set98 = true;
+    }
+
+  if (set11)
+    {
+    target->SetProperty("CXX_STANDARD", "11");
+    }
+  else if (set98)
+    {
+    target->SetProperty("CXX_STANDARD", "98");
+    }
+  bool existingExt = target->GetPropertyAsBool("CXX_EXTENSIONS");
+  if (needExt && !existingExt)
+    {
+    target->SetProperty("CXX_EXTENSIONS", "1");
+    }
+  return true;
+}
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 76958ca..4aeffdf 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -883,6 +883,8 @@ public:
   std::set<cmStdString> const & GetSystemIncludeDirectories() const
     { return this->SystemIncludeDirectories; }
 
+  bool AddRequiredTargetFeature(cmTarget *target, const char *feature) const;
+
 protected:
   // add link libraries and directories to the target
   void AddGlobalLinkInformation(const char* name, cmTarget& target);
diff --git a/Source/cmTargetCompileFeaturesCommand.cxx b/Source/cmTargetCompileFeaturesCommand.cxx
new file mode 100644
index 0000000..7004865
--- /dev/null
+++ b/Source/cmTargetCompileFeaturesCommand.cxx
@@ -0,0 +1,57 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2013 Stephen Kelly <steveire at gmail.com>
+
+  Distributed under the OSI-approved BSD License (the "License");
+  see accompanying file Copyright.txt for details.
+
+  This software is distributed WITHOUT ANY WARRANTY; without even the
+  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+  See the License for more information.
+============================================================================*/
+#include "cmTargetCompileFeaturesCommand.h"
+
+bool cmTargetCompileFeaturesCommand::InitialPass(
+  std::vector<std::string> const& args,
+  cmExecutionStatus &)
+{
+  if (args.size() < 3)
+    {
+      this->SetError("called with wrong number of arguments.");
+      return false;
+    }
+  cmTarget *target = this->Makefile->FindTargetToUse(args[0].c_str());
+
+  if(!target)
+    {
+    this->SetError("specified invalid target.");
+    return false;
+    }
+
+  if(target->IsImported())
+    {
+    this->SetError("may not be used with an IMPORTED target.");
+    return false;
+    }
+
+  if(args[1] != "PRIVATE")
+    {
+    this->SetError("called with invalid arguments.");
+    return false;
+    }
+
+  for (size_t i = 2; i < args.size(); ++i)
+    {
+    std::string feature = args[i];
+
+    bool result = this->Makefile->AddRequiredTargetFeature(target,
+                                                          feature.c_str());
+
+    if (!result)
+      {
+      this->SetError("specified unknown feature.");
+      return false;
+      }
+    }
+  return true;
+}
diff --git a/Source/cmTargetCompileFeaturesCommand.h b/Source/cmTargetCompileFeaturesCommand.h
new file mode 100644
index 0000000..63beeca
--- /dev/null
+++ b/Source/cmTargetCompileFeaturesCommand.h
@@ -0,0 +1,32 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2013 Stephen Kelly <steveire at gmail.com>
+
+  Distributed under the OSI-approved BSD License (the "License");
+  see accompanying file Copyright.txt for details.
+
+  This software is distributed WITHOUT ANY WARRANTY; without even the
+  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+  See the License for more information.
+============================================================================*/
+#ifndef cmTargetCompileFeaturesCommand_h
+#define cmTargetCompileFeaturesCommand_h
+
+#include "cmCommand.h"
+
+class cmTargetCompileFeaturesCommand : public cmCommand
+{
+  virtual cmCommand* Clone()
+    {
+    return new cmTargetCompileFeaturesCommand;
+    }
+
+  virtual bool InitialPass(std::vector<std::string> const& args,
+                           cmExecutionStatus &status);
+
+  virtual const char* GetName() const { return "target_compile_features";}
+
+  cmTypeMacro(cmTargetCompileFeaturesCommand, cmCommand);
+};
+
+#endif
diff --git a/Tests/CMakeCommands/target_compile_features/CMakeLists.txt b/Tests/CMakeCommands/target_compile_features/CMakeLists.txt
new file mode 100644
index 0000000..73e22e0
--- /dev/null
+++ b/Tests/CMakeCommands/target_compile_features/CMakeLists.txt
@@ -0,0 +1,13 @@
+cmake_minimum_required(VERSION 2.8)
+
+project(target_compile_features)
+
+if (NOT ";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";cxx_delegating_constructors;")
+  add_executable(target_compile_features dummy.cpp)
+  return()
+endif()
+
+add_executable(target_compile_features main.cpp)
+target_compile_features(target_compile_features
+  PRIVATE cxx_delegating_constructors
+)
diff --git a/Tests/CMakeCommands/target_compile_features/dummy.cpp b/Tests/CMakeCommands/target_compile_features/dummy.cpp
new file mode 100644
index 0000000..341aaaf
--- /dev/null
+++ b/Tests/CMakeCommands/target_compile_features/dummy.cpp
@@ -0,0 +1,5 @@
+
+int main(int, char **)
+{
+  return 0;
+}
diff --git a/Tests/CMakeCommands/target_compile_features/main.cpp b/Tests/CMakeCommands/target_compile_features/main.cpp
new file mode 100644
index 0000000..77671b0
--- /dev/null
+++ b/Tests/CMakeCommands/target_compile_features/main.cpp
@@ -0,0 +1,25 @@
+
+#include <cstring>
+
+class Foo
+{
+  Foo(int i)
+    :m_i(i)
+  {
+
+  }
+
+  Foo(const char *a)
+    : Foo(strlen(a))
+  {
+
+  }
+
+private:
+  int m_i;
+};
+
+int main(int, char **)
+{
+  return 0;
+}
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index e85d835..772b87d 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -2082,6 +2082,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
   ADD_TEST_MACRO(CMakeCommands.target_include_directories target_include_directories)
   ADD_TEST_MACRO(CMakeCommands.target_compile_definitions target_compile_definitions)
   ADD_TEST_MACRO(CMakeCommands.target_compile_options target_compile_options)
+  ADD_TEST_MACRO(CMakeCommands.target_compile_features target_compile_features)
 
   configure_file(
     "${CMake_SOURCE_DIR}/Tests/CTestTestCrash/test.cmake.in"

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=983ca2cfcae149ba523c94b73c75fcd10fe1f747
commit 983ca2cfcae149ba523c94b73c75fcd10fe1f747
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Thu Oct 17 11:47:29 2013 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Thu Oct 31 15:38:53 2013 +0100

    Record the compilers capable of the cxx_delegating_constructors feature.

diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst
index 00f55d0..7936ca7 100644
--- a/Help/manual/cmake-variables.7.rst
+++ b/Help/manual/cmake-variables.7.rst
@@ -207,6 +207,8 @@ Variables for Languages
 
 .. toctree::
    /variable/CMAKE_COMPILER_IS_GNULANG
+   /variable/CMAKE_CXX_COMPILE_FEATURES
+   /variable/CMAKE_CXX_KNOWN_FEATURES
    /variable/CMAKE_CXX_STANDARD
    /variable/CMAKE_Fortran_MODDIR_DEFAULT
    /variable/CMAKE_Fortran_MODDIR_FLAG
diff --git a/Help/variable/CMAKE_CXX_COMPILE_FEATURES.rst b/Help/variable/CMAKE_CXX_COMPILE_FEATURES.rst
new file mode 100644
index 0000000..6be0124
--- /dev/null
+++ b/Help/variable/CMAKE_CXX_COMPILE_FEATURES.rst
@@ -0,0 +1,8 @@
+CMAKE_CXX_COMPILE_FEATURES
+--------------------------
+
+List of features known to the C++ compiler
+
+These features are known to be available for use with the C++ compiler. This
+list is a subset of the features listed in the :variable:`CMAKE_CXX_KNOWN_FEATURES`
+variable.
diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst
new file mode 100644
index 0000000..effaf6f
--- /dev/null
+++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst
@@ -0,0 +1,15 @@
+CMAKE_CXX_KNOWN_FEATURES
+------------------------
+
+List of C++ features known to this version of CMake.
+
+The features listed in this variable may be known to be available to the C++
+compiler.  If the feature is available with the C++ compiler, it will be
+listed in the :variable:`CMAKE_CXX_COMPILE_FEATURES` variable.
+
+The features known to this version of CMake are:
+
+cxx_delegating_constructors
+  Delegating constructors, as defined in N1986_.
+
+.. _N1986: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1986.pdf
diff --git a/Modules/Compiler/Clang-CXX-FeatureTests.cmake b/Modules/Compiler/Clang-CXX-FeatureTests.cmake
new file mode 100644
index 0000000..b71b127
--- /dev/null
+++ b/Modules/Compiler/Clang-CXX-FeatureTests.cmake
@@ -0,0 +1,7 @@
+
+set(testable_features
+  cxx_delegating_constructors
+)
+foreach(feature ${testable_features})
+  set(_cmake_feature_test_${feature} "__has_extension(${feature})")
+endforeach()
diff --git a/Modules/Compiler/Clang-CXX.cmake b/Modules/Compiler/Clang-CXX.cmake
index 049b8ea..69b795f 100644
--- a/Modules/Compiler/Clang-CXX.cmake
+++ b/Modules/Compiler/Clang-CXX.cmake
@@ -5,15 +5,33 @@ if(NOT CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
   set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden")
 endif()
 
+set(CMAKE_CXX11_COMPILE_FEATURES)
+
+include("${CMAKE_ROOT}/Modules/Internal/FeatureTesting.cmake")
+
+macro(_get_clang_features std_version list)
+  record_compiler_features(CXX "-std=${std_version}" ${list})
+endmacro()
+
 if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 2.1)
   set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98")
   set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98")
 
   set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++0x")
   set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++0x")
+
+  _get_clang_features(c++0x CMAKE_CXX11_COMPILE_FEATURES)
 endif()
 
 if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.1)
   set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11")
   set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11")
+
+  _get_clang_features(c++11 CMAKE_CXX11_COMPILE_FEATURES)
 endif()
+
+unset(testable_features)
+
+set(CMAKE_CXX_COMPILE_FEATURES
+  ${CMAKE_CXX11_COMPILE_FEATURES}
+)
diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake
new file mode 100644
index 0000000..7da0563
--- /dev/null
+++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake
@@ -0,0 +1,2 @@
+
+set(_cmake_feature_test_cxx_delegating_constructors "(__GNUC__ * 100 + __GNUC_MINOR__) >= 407")
diff --git a/Modules/Compiler/GNU-CXX.cmake b/Modules/Compiler/GNU-CXX.cmake
index dbbca78..b2db909 100644
--- a/Modules/Compiler/GNU-CXX.cmake
+++ b/Modules/Compiler/GNU-CXX.cmake
@@ -11,6 +11,14 @@ else()
   endif()
 endif()
 
+set(CMAKE_CXX11_COMPILE_FEATURES)
+
+include("${CMAKE_ROOT}/Modules/Internal/FeatureTesting.cmake")
+
+macro(_get_gcc_features std_version list)
+  record_compiler_features(CXX "-std=${std_version}" ${list})
+endmacro()
+
 # Appropriate version?
 if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.3)
   set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98")
@@ -20,7 +28,15 @@ endif()
 if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
   set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11")
   set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11")
+
+  _get_gcc_features(c++11 CMAKE_CXX11_COMPILE_FEATURES)
 elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.3)
   set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++0x")
   set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++0x")
+
+  _get_gcc_features(c++0x CMAKE_CXX11_COMPILE_FEATURES)
 endif()
+
+set(CMAKE_CXX_COMPILE_FEATURES
+  ${CMAKE_CXX11_COMPILE_FEATURES}
+)
diff --git a/Modules/Compiler/GNU.cmake b/Modules/Compiler/GNU.cmake
index 504704d..0eb64be 100644
--- a/Modules/Compiler/GNU.cmake
+++ b/Modules/Compiler/GNU.cmake
@@ -51,6 +51,7 @@ macro(__compiler_gnu lang)
   set(CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "-O2 -g -DNDEBUG")
   set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")
   set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>")
+  set(_CMAKE_${lang}_CREATE_OBJECT_FILE "${CMAKE_${lang}_COMPILER};<FLAGS>;-c;<SOURCE>")
   if(NOT APPLE)
     set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ")
   endif()
diff --git a/Modules/Compiler/Intel-CXX-FeatureTests.cmake b/Modules/Compiler/Intel-CXX-FeatureTests.cmake
new file mode 100644
index 0000000..ab90206
--- /dev/null
+++ b/Modules/Compiler/Intel-CXX-FeatureTests.cmake
@@ -0,0 +1,2 @@
+
+set(_cmake_feature_test_cxx_delegating_constructors "__INTEL_COMPILER >= 1400")
diff --git a/Modules/Compiler/Intel-CXX.cmake b/Modules/Compiler/Intel-CXX.cmake
index 4d11556..869249c 100644
--- a/Modules/Compiler/Intel-CXX.cmake
+++ b/Modules/Compiler/Intel-CXX.cmake
@@ -12,12 +12,18 @@ endif()
 
 set(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE "<CMAKE_CXX_COMPILER> <DEFINES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")
 set(CMAKE_CXX_CREATE_ASSEMBLY_SOURCE "<CMAKE_CXX_COMPILER> <DEFINES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>")
+set(_CMAKE_CXX_CREATE_OBJECT_FILE "${CMAKE_CXX_COMPILER};<FLAGS>;-c;<SOURCE>")
+
+set(CMAKE_CXX11_COMPILE_FEATURES)
+
+include("${CMAKE_ROOT}/Modules/Internal/FeatureTesting.cmake")
 
 if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11.1)
   if (CMAKE_CXX_SIMULATE_ID STREQUAL MSVC)
     set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "/Qstd=c++0x")
   else()
     set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++0x")
+    record_compiler_features(CXX "-std=c++0x" CMAKE_CXX11_COMPILE_FEATURES)
     # TODO: Does intel support GNU extensions and -std=gnu++0x etc?
   endif()
 endif()
@@ -27,5 +33,10 @@ if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13)
     set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "/Qstd=c++11")
   else()
     set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11")
+    record_compiler_features(CXX "-std=c++11" CMAKE_CXX11_COMPILE_FEATURES)
   endif()
 endif()
+
+set(CMAKE_CXX_COMPILE_FEATURES
+  ${CMAKE_CXX11_COMPILE_FEATURES}
+)
diff --git a/Modules/Internal/FeatureTesting.cmake b/Modules/Internal/FeatureTesting.cmake
new file mode 100644
index 0000000..3df4f4f
--- /dev/null
+++ b/Modules/Internal/FeatureTesting.cmake
@@ -0,0 +1,43 @@
+
+macro(record_compiler_features lang compile_flags feature_list)
+  include("${CMAKE_ROOT}/Modules/Compiler/${CMAKE_${lang}_COMPILER_ID}-${lang}-FeatureTests.cmake" OPTIONAL)
+
+  string(TOLOWER ${lang} lang_lc)
+  file(REMOVE "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests${CMAKE_${lang}_OUTPUT_EXTENSION}")
+  file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/feature_tests.${lang_lc}" "
+  extern const char features[] = {\n")
+  foreach(feature ${CMAKE_${lang}_KNOWN_FEATURES})
+    set(_define_check "\n\"0\"\n")
+    if (_cmake_feature_test_${feature})
+      set(_define_check "#if ${_cmake_feature_test_${feature}}\n\"1\"\n#else${_define_check}#endif\n")
+    endif()
+    file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/feature_tests.${lang_lc}" "\"${lang}_FEATURE:\"\n${_define_check}\"${feature}\\n\"\n")
+  endforeach()
+  file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/feature_tests.${lang_lc}" "\n};\n")
+
+  string(REPLACE "<FLAGS>" "${compile_flags}" _compile_object_command "${_CMAKE_${lang}_CREATE_OBJECT_FILE}" )
+  string(REPLACE "<SOURCE>" "${CMAKE_CURRENT_BINARY_DIR}/feature_tests.${lang_lc}" _compile_object_command "${_compile_object_command}" )
+  execute_process(COMMAND ${_compile_object_command}
+    WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/CMakeFiles"
+    ERROR_VARIABLE _error
+    OUTPUT_VARIABLE _output
+    RESULT_VARIABLE _result
+  )
+  # We need to capture these when running the process so that the output does
+  # not leak and confuse unit tests. Clear the variables so they do not leak
+  # to user CMake code either.
+  unset(_error)
+  unset(_output)
+  if (_result EQUAL 0 AND EXISTS "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests${CMAKE_${lang}_OUTPUT_EXTENSION}")
+    file(STRINGS "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests${CMAKE_${lang}_OUTPUT_EXTENSION}"
+      features REGEX "${lang}_FEATURE:.*")
+    foreach(info ${features})
+      string(REPLACE "${lang}_FEATURE:" "" info ${info})
+      string(SUBSTRING ${info} 0 1 has_feature)
+      if(has_feature)
+        string(REGEX REPLACE "^1" "" feature ${info})
+        list(APPEND ${feature_list} ${feature})
+      endif()
+    endforeach()
+  endif()
+endmacro()
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index c18a7eb..103d44d 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -41,6 +41,9 @@
 #include <ctype.h> // for isspace
 #include <assert.h>
 
+#define FOR_EACH_CXX_FEATURE(F) \
+  F(cxx_delegating_constructors)
+
 class cmMakefile::Internals
 {
 public:
@@ -2409,6 +2412,19 @@ const char* cmMakefile::GetDefinition(const char* name) const
     {
     this->Internal->VarUsageStack.top().insert(name);
     }
+  if (strcmp(name, "CMAKE_CXX_KNOWN_FEATURES") == 0)
+    {
+#define STRING_LIST_ELEMENT(F) ";" #F
+    return FOR_EACH_CXX_FEATURE(STRING_LIST_ELEMENT) + 1;
+#undef STRING_LIST_ELEMENT
+    }
+#define PP_FEATURE_NAME(F) \
+  if (strcmp(name, "CMAKE_PP_NAME_" #F) == 0) \
+    { \
+    return ("COMPILER_" + cmSystemTools::UpperCase(#F)).c_str(); \
+    }
+  FOR_EACH_CXX_FEATURE(PP_FEATURE_NAME)
+#undef PP_FEATURE_NAME
   const char* def = this->Internal->VarStack.top().Get(name);
   if(!def)
     {

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

Summary of changes:


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list