[Cmake-commits] CMake branch, next, updated. v2.8.12-4570-gf450854

Brad King brad.king at kitware.com
Mon Oct 28 08:47:38 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  f4508546740e98335cd817220707d4f876ee0d66 (commit)
       via  f81281d3eca351e844086ea2523683ccc856c127 (commit)
       via  30f7e101a948190d1ff94ad4860c9d404d8be247 (commit)
       via  c6ae84b781e7f1c025ec8d49ad08d3b6463ba7ec (commit)
       via  2570fde52a6fc240efae446cd2570716e9024996 (commit)
       via  c0abb89ede108d8418855c655b8065c35d026863 (commit)
       via  200f8e5b4b1fa1d1273ebae0a0a779848d35e97a (commit)
       via  021e27b8fab744336d591d737645fb4b0807d81f (commit)
       via  f824c0dac4c409644337096895fae7d4e7483095 (commit)
       via  7ea06dcb17eeac063fd4d844ee200c4d095d83f6 (commit)
      from  e784958a3a098b0f379caa4022141128d1bf084b (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=f4508546740e98335cd817220707d4f876ee0d66
commit f4508546740e98335cd817220707d4f876ee0d66
Merge: e784958 f81281d
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Mon Oct 28 08:47:22 2013 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Mon Oct 28 08:47:22 2013 -0400

    Merge topic 'target_compiler_features' into next
    
    f81281d Add a variable for the compiler command to compile a source file.
    30f7e10 Add the WriteCompilerDetectionHeader module.
    c6ae84b Transitively evaluate compiler features.
    2570fde Allow populating compiler_features using generator expressions.
    c0abb89 Make COMPILER_FEATURES available as a target property.
    200f8e5 Add target_compiler_features command.
    021e27b Record the compilers capable of the cxx_delegating_constructors feature.
    f824c0d Add CXX_STANDARD and CXX_EXTENSION target properties.
    7ea06dc Add some COMPILE_OPTIONS for specifying C++ dialect.


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f81281d3eca351e844086ea2523683ccc856c127
commit f81281d3eca351e844086ea2523683ccc856c127
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Thu Oct 24 16:57:16 2013 +0200
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Oct 28 08:46:00 2013 -0400

    Add a variable for the compiler command to compile a source file.
    
    Use the variable in CxxFeatureTesting.cmake.

diff --git a/Modules/Compiler/CxxFeatureTesting.cmake b/Modules/Compiler/CxxFeatureTesting.cmake
index 97a9b0e..5529814 100644
--- a/Modules/Compiler/CxxFeatureTesting.cmake
+++ b/Modules/Compiler/CxxFeatureTesting.cmake
@@ -13,7 +13,9 @@ macro(record_cxx_compiler_features compile_flags feature_list)
   endforeach()
   file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/feature_tests.cxx" "\n};\n")
 
-  execute_process(COMMAND "${CMAKE_CXX_COMPILER}" ${compile_flags} "-c" "${CMAKE_CURRENT_BINARY_DIR}/feature_tests.cxx"
+  string(REPLACE "<FLAGS>" "${compile_flags}" _compile_object_command "${_CMAKE_CXX_CREATE_OBJECT_FILE}" )
+  string(REPLACE "<SOURCE>" "${CMAKE_CURRENT_BINARY_DIR}/feature_tests.cxx" _compile_object_command "${_compile_object_command}" )
+  execute_process(COMMAND ${_compile_object_command}
     WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/CMakeFiles"
     ERROR_VARIABLE _error
     OUTPUT_VARIABLE _output
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.cmake b/Modules/Compiler/Intel-CXX.cmake
index 1eda76e..58c264a 100644
--- a/Modules/Compiler/Intel-CXX.cmake
+++ b/Modules/Compiler/Intel-CXX.cmake
@@ -12,6 +12,7 @@ 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_COMPILER_FEATURES)
 
diff --git a/Modules/Compiler/XL-CXX.cmake b/Modules/Compiler/XL-CXX.cmake
index 706b789..31bae0a 100644
--- a/Modules/Compiler/XL-CXX.cmake
+++ b/Modules/Compiler/XL-CXX.cmake
@@ -9,6 +9,7 @@ set(CMAKE_CXX_FLAGS_INIT "-qthreaded -qhalt=e")
 
 set(CMAKE_CXX_COMPILE_OBJECT
   "<CMAKE_CXX_COMPILER> -+ <DEFINES> <FLAGS> -o <OBJECT> -c <SOURCE>")
+set(_CMAKE_CXX_CREATE_OBJECT_FILE "${CMAKE_CXX_COMPILER};<FLAGS>;-c;<SOURCE>")
 
 set(CMAKE_CXX11_COMPILER_FEATURES)
 

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=30f7e101a948190d1ff94ad4860c9d404d8be247
commit 30f7e101a948190d1ff94ad4860c9d404d8be247
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Mon Oct 21 16:59:40 2013 +0200
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Oct 28 08:45:59 2013 -0400

    Add the WriteCompilerDetectionHeader module.
    
    Provide a function to write a portable header to detect compiler
    features.

diff --git a/Modules/Compiler/Clang-features.cmake b/Modules/Compiler/Clang-features.cmake
index 074e5a1..012502d 100644
--- a/Modules/Compiler/Clang-features.cmake
+++ b/Modules/Compiler/Clang-features.cmake
@@ -1,4 +1,6 @@
 
+set(compiler_test_macro __clang__)
+
 set(testable_features
   cxx_delegating_constructors
 )
diff --git a/Modules/Compiler/GNU-features.cmake b/Modules/Compiler/GNU-features.cmake
index bb63250..169a6a9 100644
--- a/Modules/Compiler/GNU-features.cmake
+++ b/Modules/Compiler/GNU-features.cmake
@@ -1,2 +1,4 @@
 
+set(compiler_test_macro __GNUC__)
+
 set(feature_test_cxx_delegating_constructors "(__GNUC__ * 100 + __GNUC_MINOR__) >= 407")
diff --git a/Modules/Compiler/Intel-features.cmake b/Modules/Compiler/Intel-features.cmake
index 07676a0..b074912 100644
--- a/Modules/Compiler/Intel-features.cmake
+++ b/Modules/Compiler/Intel-features.cmake
@@ -1,2 +1,4 @@
 
+set(compiler_test_macro __INTEL_COMPILER)
+
 set(feature_test_cxx_delegating_constructors "__INTEL_COMPILER >= 1400")
diff --git a/Modules/Compiler/XL-features.cmake b/Modules/Compiler/XL-features.cmake
index 64dcb2c..cfbaa3c 100644
--- a/Modules/Compiler/XL-features.cmake
+++ b/Modules/Compiler/XL-features.cmake
@@ -1,2 +1,4 @@
 
+set(compiler_test_macro __IBMCPP__)
+
 set(feature_test_cxx_delegating_constructors "__IBMCPP__ >= 1110")
diff --git a/Modules/WriteCompilerDetectionHeader.cmake b/Modules/WriteCompilerDetectionHeader.cmake
new file mode 100644
index 0000000..4fadbb1
--- /dev/null
+++ b/Modules/WriteCompilerDetectionHeader.cmake
@@ -0,0 +1,89 @@
+
+#=============================================================================
+# 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.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+#  License text for the above reference.)
+
+include(${CMAKE_CURRENT_LIST_DIR}/CMakeParseArguments.cmake)
+
+function(_load_compiler_variables CompilerId)
+  include("${CMAKE_ROOT}/Modules/Compiler/${CompilerId}-features.cmake" OPTIONAL)
+  if (NOT compiler_test_macro)
+    message(FATAL_ERROR "Compiler ${CompilerId} does not define compiler_test_macro")
+  endif()
+  foreach(feature ${ARGN})
+    set(x ${feature_tests_${feature}})
+    if (feature_test_${feature})
+      list(APPEND x "(defined (${compiler_test_macro}) && ${feature_test_${feature}})")
+      set(feature_tests_${feature} ${x} PARENT_SCOPE)
+    endif()
+  endforeach()
+endfunction()
+
+function(write_compiler_detection_header
+    file_keyword file_arg
+    prefix_keyword prefix_arg
+    )
+  if (NOT file_keyword STREQUAL FILE)
+    message(FATAL_ERROR "Wrong parameters for function.")
+  endif()
+  if (NOT prefix_keyword STREQUAL PREFIX)
+    message(FATAL_ERROR "Wrong parameters for function.")
+  endif()
+  set(options)
+  set(oneValueArgs VERSION)
+  set(multiValueArgs COMPILERS FEATURES)
+  cmake_parse_arguments(_WCD "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+
+  if(_WCD_UNPARSED_ARGUMENTS)
+    message(FATAL_ERROR "Unparsed arguments: ${_WCD_UNPARSED_ARGUMENTS}")
+  endif()
+
+  if(NOT _WCD_VERSION)
+    set(_WCD_VERSION ${CMAKE_MINIMUM_REQUIRED_VERSION})
+  endif()
+#   if (_WCD_VERSION VERSION_LESS 3.0.0) # Version which introduced this function
+#   if (_WCD_VERSION VERSION_LESS 2.8.12.20131023)
+#     message(FATAL_ERROR "VERSION parameter too low.")
+#   endif()
+
+  file(WRITE ${file_arg} "
+// This is a generated file. Do not edit!
+
+#ifndef ${prefix_arg}_COMPILER_DETECTION_H
+#define ${prefix_arg}_COMPILER_DETECTION_H
+")
+
+  foreach(ordered_compiler
+      # Order is relevant here. We need to list the compilers which pretend to
+      # be GNU/MSVC before the actual GNU/MSVC compiler.
+      XL
+      Intel
+      Clang
+      GNU
+      )
+    list(FIND _WCD_COMPILERS ${ordered_compiler} idx)
+    if (NOT idx EQUAL -1)
+      _load_compiler_variables(${ordered_compiler} ${_WCD_FEATURES})
+    endif()
+  endforeach()
+
+  foreach(feature ${_WCD_FEATURES})
+    set(_define_check "\n#define ${prefix_arg}_${CMAKE_PP_NAME_${feature}} 0\n")
+    if (feature_tests_${feature})
+      string(REPLACE ";" " \\\n    || " feature_tests_${feature} "${feature_tests_${feature}}")
+      set(_define_check "\n#if ${feature_tests_${feature}}\n#define ${prefix_arg}_${CMAKE_PP_NAME_${feature}} 1\n#else${_define_check}#endif\n")
+    endif()
+    file(APPEND "${file_arg}" "${_define_check}")
+  endforeach()
+
+  file(APPEND ${file_arg} "\n#endif\n")
+endfunction()

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c6ae84b781e7f1c025ec8d49ad08d3b6463ba7ec
commit c6ae84b781e7f1c025ec8d49ad08d3b6463ba7ec
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue Oct 22 01:40:47 2013 +0200
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Oct 28 08:45:59 2013 -0400

    Transitively evaluate compiler features.
    
    Extend the interface of the target_compiler_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_compiler_features.rst b/Help/command/target_compiler_features.rst
index 1b37112..ade0310 100644
--- a/Help/command/target_compiler_features.rst
+++ b/Help/command/target_compiler_features.rst
@@ -5,7 +5,7 @@ Add expected compiler features to a target.
 
 ::
 
-  target_compiler_features(<target> PRIVATE <feature> [...])
+  target_compiler_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_COMPILER_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:`COMPILER_FEATURES` property of <target>.  PUBLIC and
+INTERFACE items will populate the :prop_tgt:`INTERFACE_COMPILER_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..d139092 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::EvaluatingCompilerFeatures() const
+{
+  const char *prop = this->Property.c_str();
+  return (strcmp(prop, "COMPILER_FEATURES") == 0
+       || strcmp(prop, "INTERFACE_COMPILER_FEATURES") == 0);
+}
diff --git a/Source/cmGeneratorExpressionDAGChecker.h b/Source/cmGeneratorExpressionDAGChecker.h
index 0b7ef02..3f75a45 100644
--- a/Source/cmGeneratorExpressionDAGChecker.h
+++ b/Source/cmGeneratorExpressionDAGChecker.h
@@ -20,13 +20,15 @@
   F(EvaluatingIncludeDirectories) \
   F(EvaluatingSystemIncludeDirectories) \
   F(EvaluatingCompileDefinitions) \
-  F(EvaluatingCompileOptions)
+  F(EvaluatingCompileOptions) \
+  F(EvaluatingCompilerFeatures)
 
 #define CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(F) \
   F(INTERFACE_INCLUDE_DIRECTORIES) \
   F(INTERFACE_SYSTEM_INCLUDE_DIRECTORIES) \
   F(INTERFACE_COMPILE_DEFINITIONS) \
-  F(INTERFACE_COMPILE_OPTIONS)
+  F(INTERFACE_COMPILE_OPTIONS) \
+  F(INTERFACE_COMPILER_FEATURES)
 
 //----------------------------------------------------------------------------
 struct cmGeneratorExpressionDAGChecker
diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx
index f92c18e..74c6c97 100644
--- a/Source/cmGeneratorExpressionEvaluator.cxx
+++ b/Source/cmGeneratorExpressionEvaluator.cxx
@@ -913,6 +913,11 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
       {
       interfacePropertyName = "INTERFACE_COMPILE_OPTIONS";
       }
+    else if (propertyName == "INTERFACE_COMPILER_FEATURES"
+        || propertyName == "COMPILER_FEATURES")
+      {
+      interfacePropertyName = "INTERFACE_COMPILER_FEATURES";
+      }
 
     cmTarget *headTarget = context->HeadTarget ? context->HeadTarget : target;
 
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 829d96b..0ad4753 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*> CompilerFeaturesEntries;
   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*> >
+                                CachedLinkInterfaceCompilerFeaturesEntries;
+  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> CacheLinkInterfaceCompilerFeaturesDone;
 };
 
 //----------------------------------------------------------------------------
@@ -210,6 +214,7 @@ cmTarget::cmTarget()
   this->BuildInterfaceIncludesAppended = false;
   this->DebugIncludesDone = false;
   this->DebugCompileOptionsDone = false;
+  this->DebugCompilerFeaturesDone = false;
   this->DebugCompileDefinitionsDone = false;
 }
 
@@ -2538,6 +2543,121 @@ void cmTarget::GetCompileDefinitions(std::vector<std::string> &list,
 }
 
 //----------------------------------------------------------------------------
+static void processCompilerFeatures(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::GetCompilerFeatures(std::vector<std::string> &result,
+                                 const char *config)
+{
+  std::set<std::string> uniqueFeatures;
+  cmListFileBacktrace lfbt;
+
+  cmGeneratorExpressionDAGChecker dagChecker(lfbt,
+                                             this->GetName(),
+                                             "COMPILER_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->DebugCompilerFeaturesDone
+                    && std::find(debugProperties.begin(),
+                                 debugProperties.end(),
+                                 "COMPILER_FEATURES")
+                        != debugProperties.end();
+
+  if (this->Makefile->IsGeneratingBuildSystem())
+    {
+    this->DebugCompilerFeaturesDone = true;
+    }
+
+  processCompilerFeatures(this,
+                            this->Internal->CompilerFeaturesEntries,
+                            result,
+                            uniqueFeatures,
+                            &dagChecker,
+                            config,
+                            debugFeatures);
+
+  std::string configString = config ? config : "";
+  if (!this->Internal->CacheLinkInterfaceCompilerFeaturesDone[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_COMPILER_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
+        ->CachedLinkInterfaceCompilerFeaturesEntries[configString].push_back(
+                        new cmTargetInternals::TargetPropertyEntry(cge,
+                                                              it->Value));
+      }
+    }
+
+  processCompilerFeatures(this,
+    this->Internal->CachedLinkInterfaceCompilerFeaturesEntries[configString],
+                            result,
+                            uniqueFeatures,
+                            &dagChecker,
+                            config,
+                            debugFeatures);
+
+  if (!this->Makefile->IsGeneratingBuildSystem())
+    {
+    deleteAndClear(this->Internal->CachedLinkInterfaceCompilerFeaturesEntries);
+    }
+  else
+    {
+    this->Internal->CacheLinkInterfaceCompilerFeaturesDone[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..c25fa57 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 GetCompilerFeatures(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 DebugCompilerFeaturesDone;
   bool DebugCompileDefinitionsDone;
   mutable std::set<std::string> LinkImplicitNullProperties;
   bool BuildInterfaceIncludesAppended;
diff --git a/Source/cmTargetCompilerFeaturesCommand.cxx b/Source/cmTargetCompilerFeaturesCommand.cxx
index eb9d0e3..7a77aac 100644
--- a/Source/cmTargetCompilerFeaturesCommand.cxx
+++ b/Source/cmTargetCompilerFeaturesCommand.cxx
@@ -34,7 +34,8 @@ bool cmTargetCompilerFeaturesCommand::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 cmTargetCompilerFeaturesCommand::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_COMPILER_FEATURES", feature.c_str());
       }
     }
   return true;
diff --git a/Tests/CMakeCommands/target_compiler_features/CMakeLists.txt b/Tests/CMakeCommands/target_compiler_features/CMakeLists.txt
index 4a7cb5f..d643107 100644
--- a/Tests/CMakeCommands/target_compiler_features/CMakeLists.txt
+++ b/Tests/CMakeCommands/target_compiler_features/CMakeLists.txt
@@ -11,3 +11,11 @@ add_executable(target_compiler_features main.cpp)
 target_compiler_features(target_compiler_features
   PRIVATE cxx_delegating_constructors
 )
+
+add_library(lib_delegating_constructors lib_delegating_constructors.cpp)
+target_compiler_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=2570fde52a6fc240efae446cd2570716e9024996
commit 2570fde52a6fc240efae446cd2570716e9024996
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue Oct 22 15:05:49 2013 +0200
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Oct 28 08:45:59 2013 -0400

    Allow populating compiler_features using generator expressions.

diff --git a/Help/command/target_compiler_features.rst b/Help/command/target_compiler_features.rst
index 7ae82b8..1b37112 100644
--- a/Help/command/target_compiler_features.rst
+++ b/Help/command/target_compiler_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_compiler_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/COMPILER_FEATURES.rst b/Help/prop_tgt/COMPILER_FEATURES.rst
index ceebe06..38c49e2 100644
--- a/Help/prop_tgt/COMPILER_FEATURES.rst
+++ b/Help/prop_tgt/COMPILER_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_COMPILER_FEATURES` variable.
+
+Contents of COMPILER_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 32a6890..18132b8 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -4441,6 +4441,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("COMPILER_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=c0abb89ede108d8418855c655b8065c35d026863
commit c0abb89ede108d8418855c655b8065c35d026863
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue Oct 22 14:58:21 2013 +0200
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Oct 28 08:45:59 2013 -0400

    Make COMPILER_FEATURES available as a target property.

diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst
index c1fef71..6754fb0 100644
--- a/Help/manual/cmake-properties.7.rst
+++ b/Help/manual/cmake-properties.7.rst
@@ -83,6 +83,7 @@ Properties on Targets
    /prop_tgt/COMPILE_DEFINITIONS
    /prop_tgt/COMPILE_FLAGS
    /prop_tgt/COMPILE_OPTIONS
+   /prop_tgt/COMPILER_FEATURES
    /prop_tgt/CONFIG_OUTPUT_NAME
    /prop_tgt/CONFIG_POSTFIX
    /prop_tgt/CXX_STANDARD
diff --git a/Help/prop_tgt/COMPILER_FEATURES.rst b/Help/prop_tgt/COMPILER_FEATURES.rst
new file mode 100644
index 0000000..ceebe06
--- /dev/null
+++ b/Help/prop_tgt/COMPILER_FEATURES.rst
@@ -0,0 +1,7 @@
+COMPILER_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_COMPILER_FEATURES` variable.
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 4acb5a3..32a6890 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -4471,6 +4471,8 @@ AddRequiredTargetFeature(cmTarget *target, const char *feature) const
     return false;
     }
 
+  target->AppendProperty("COMPILER_FEATURES", feature);
+
   bool need98 = true;
   bool need11 = false;
   bool needExt = false;
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 4f58700..829d96b 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -187,6 +187,7 @@ cmTargetInternals::~cmTargetInternals()
 {
   deleteAndClear(this->CachedLinkInterfaceIncludeDirectoriesEntries);
   deleteAndClear(this->CachedLinkInterfaceCompileOptionsEntries);
+  deleteAndClear(this->CachedLinkInterfaceCompilerFeaturesEntries);
   deleteAndClear(this->CachedLinkInterfaceCompileDefinitionsEntries);
 }
 
@@ -1718,6 +1719,17 @@ void cmTarget::SetProperty(const char* prop, const char* value)
                           new cmTargetInternals::TargetPropertyEntry(cge));
     return;
     }
+  if(strcmp(prop,"COMPILER_FEATURES") == 0)
+    {
+    cmListFileBacktrace lfbt;
+    this->Makefile->GetBacktrace(lfbt);
+    cmGeneratorExpression ge(lfbt);
+    deleteAndClear(this->Internal->CompilerFeaturesEntries);
+    cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
+    this->Internal->CompilerFeaturesEntries.push_back(
+                          new cmTargetInternals::TargetPropertyEntry(cge));
+    return;
+    }
   if(strcmp(prop,"COMPILE_DEFINITIONS") == 0)
     {
     cmListFileBacktrace lfbt;
@@ -1783,6 +1795,15 @@ void cmTarget::AppendProperty(const char* prop, const char* value,
               new cmTargetInternals::TargetPropertyEntry(ge.Parse(value)));
     return;
     }
+  if(strcmp(prop,"COMPILER_FEATURES") == 0)
+    {
+    cmListFileBacktrace lfbt;
+    this->Makefile->GetBacktrace(lfbt);
+    cmGeneratorExpression ge(lfbt);
+    this->Internal->CompilerFeaturesEntries.push_back(
+              new cmTargetInternals::TargetPropertyEntry(ge.Parse(value)));
+    return;
+    }
   if(strcmp(prop,"COMPILE_DEFINITIONS") == 0)
     {
     cmListFileBacktrace lfbt;
@@ -2377,6 +2398,13 @@ void cmTarget::GetCompileOptions(std::vector<std::string> &result,
     {
     this->Internal->CacheLinkInterfaceCompileOptionsDone[configString] = true;
     }
+  std::vector<std::string> features;
+  this->GetCompilerFeatures(features, config);
+  for(std::vector<std::string>::const_iterator it = features.begin();
+      it != features.end(); ++it)
+    {
+    this->Makefile->AddRequiredTargetFeature(this, it->c_str());
+    }
 }
 
 //----------------------------------------------------------------------------
@@ -2964,6 +2992,24 @@ const char *cmTarget::GetProperty(const char* prop,
       }
     return output.c_str();
     }
+  if(strcmp(prop,"COMPILER_FEATURES") == 0)
+    {
+    static std::string output;
+    output = "";
+    std::string sep;
+    typedef cmTargetInternals::TargetPropertyEntry
+                                TargetPropertyEntry;
+    for (std::vector<TargetPropertyEntry*>::const_iterator
+        it = this->Internal->CompilerFeaturesEntries.begin(),
+        end = this->Internal->CompilerFeaturesEntries.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;
@@ -6213,6 +6259,7 @@ cmTargetInternalPointer::~cmTargetInternalPointer()
 {
   deleteAndClear(this->Pointer->IncludeDirectoriesEntries);
   deleteAndClear(this->Pointer->CompileOptionsEntries);
+  deleteAndClear(this->Pointer->CompilerFeaturesEntries);
   deleteAndClear(this->Pointer->CompileDefinitionsEntries);
   delete this->Pointer;
 }

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=200f8e5b4b1fa1d1273ebae0a0a779848d35e97a
commit 200f8e5b4b1fa1d1273ebae0a0a779848d35e97a
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Oct 13 14:25:08 2013 +0200
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Oct 28 08:45:59 2013 -0400

    Add target_compiler_features command.

diff --git a/Help/command/target_compiler_features.rst b/Help/command/target_compiler_features.rst
new file mode 100644
index 0000000..7ae82b8
--- /dev/null
+++ b/Help/command/target_compiler_features.rst
@@ -0,0 +1,17 @@
+target_compiler_features
+------------------------
+
+Add expected compiler features to a target.
+
+::
+
+  target_compiler_features(<target> PRIVATE <feature> [...])
+
+Specify compiler features required when compiling a given target.  If the
+feature is not listed in the :variable:`CMAKE_CXX_COMPILER_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..0484739 100644
--- a/Help/manual/cmake-commands.7.rst
+++ b/Help/manual/cmake-commands.7.rst
@@ -88,6 +88,7 @@ These commands may be used freely in CMake projects.
    /command/string
    /command/target_compile_definitions
    /command/target_compile_options
+   /command/target_compiler_features
    /command/target_include_directories
    /command/target_link_libraries
    /command/try_compile
diff --git a/Help/variable/CMAKE_CXX_COMPILER_FEATURES.rst b/Help/variable/CMAKE_CXX_COMPILER_FEATURES.rst
index 4423deb..dbe7bd8 100644
--- a/Help/variable/CMAKE_CXX_COMPILER_FEATURES.rst
+++ b/Help/variable/CMAKE_CXX_COMPILER_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_compiler_features`
+command.
diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx
index 1e2a85c..cd0d723 100644
--- a/Source/cmCommands.cxx
+++ b/Source/cmCommands.cxx
@@ -32,6 +32,7 @@
 #include "cmSubdirDependsCommand.cxx"
 #include "cmTargetCompileDefinitionsCommand.cxx"
 #include "cmTargetCompileOptionsCommand.cxx"
+#include "cmTargetCompilerFeaturesCommand.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 cmTargetCompilerFeaturesCommand);
   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 d92b7ad..4acb5a3 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -4425,3 +4425,137 @@ 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_COMPILER_FEATURES");
+
+  if (!featuresKnown)
+    {
+    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;
+    }
+
+  std::vector<std::string> availableFeatures;
+  cmSystemTools::ExpandListArgument(featuresKnown, availableFeatures);
+  if (std::find(availableFeatures.begin(),
+                availableFeatures.end(),
+                feature) == availableFeatures.end())
+    {
+    return false;
+    }
+
+  bool need98 = true;
+  bool need11 = false;
+  bool needExt = false;
+
+  if (const char *prop98 =
+                        this->GetDefinition("CMAKE_CXX98_COMPILER_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_COMPILER_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 918c8bf..d5c3d20 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -880,6 +880,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/cmTargetCompilerFeaturesCommand.cxx b/Source/cmTargetCompilerFeaturesCommand.cxx
new file mode 100644
index 0000000..eb9d0e3
--- /dev/null
+++ b/Source/cmTargetCompilerFeaturesCommand.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 "cmTargetCompilerFeaturesCommand.h"
+
+bool cmTargetCompilerFeaturesCommand::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/cmTargetCompilerFeaturesCommand.h b/Source/cmTargetCompilerFeaturesCommand.h
new file mode 100644
index 0000000..c20c8ea
--- /dev/null
+++ b/Source/cmTargetCompilerFeaturesCommand.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 cmTargetCompilerFeaturesCommand : public cmCommand
+{
+  virtual cmCommand* Clone()
+    {
+    return new cmTargetCompilerFeaturesCommand;
+    }
+
+  virtual bool InitialPass(std::vector<std::string> const& args,
+                           cmExecutionStatus &status);
+
+  virtual const char* GetName() const { return "target_compiler_features";}
+
+  cmTypeMacro(cmTargetCompilerFeaturesCommand, cmCommand);
+};
+
+#endif
diff --git a/Tests/CMakeCommands/target_compiler_features/CMakeLists.txt b/Tests/CMakeCommands/target_compiler_features/CMakeLists.txt
new file mode 100644
index 0000000..4a7cb5f
--- /dev/null
+++ b/Tests/CMakeCommands/target_compiler_features/CMakeLists.txt
@@ -0,0 +1,13 @@
+cmake_minimum_required(VERSION 2.8)
+
+project(target_compiler_features)
+
+if (NOT ";${CMAKE_CXX_COMPILER_FEATURES};" MATCHES ";cxx_delegating_constructors;")
+  add_executable(target_compiler_features dummy.cpp)
+  return()
+endif()
+
+add_executable(target_compiler_features main.cpp)
+target_compiler_features(target_compiler_features
+  PRIVATE cxx_delegating_constructors
+)
diff --git a/Tests/CMakeCommands/target_compiler_features/dummy.cpp b/Tests/CMakeCommands/target_compiler_features/dummy.cpp
new file mode 100644
index 0000000..341aaaf
--- /dev/null
+++ b/Tests/CMakeCommands/target_compiler_features/dummy.cpp
@@ -0,0 +1,5 @@
+
+int main(int, char **)
+{
+  return 0;
+}
diff --git a/Tests/CMakeCommands/target_compiler_features/main.cpp b/Tests/CMakeCommands/target_compiler_features/main.cpp
new file mode 100644
index 0000000..77671b0
--- /dev/null
+++ b/Tests/CMakeCommands/target_compiler_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 d1d1268..aa35dee 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -2073,6 +2073,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_compiler_features target_compiler_features)
 
   configure_file(
     "${CMake_SOURCE_DIR}/Tests/CTestTestCrash/test.cmake.in"

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=021e27b8fab744336d591d737645fb4b0807d81f
commit 021e27b8fab744336d591d737645fb4b0807d81f
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Thu Oct 17 11:47:29 2013 +0200
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Oct 28 08:45:58 2013 -0400

    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 912fafa..95dd365 100644
--- a/Help/manual/cmake-variables.7.rst
+++ b/Help/manual/cmake-variables.7.rst
@@ -203,6 +203,8 @@ Variables for Languages
 
 .. toctree::
    /variable/CMAKE_COMPILER_IS_GNULANG
+   /variable/CMAKE_CXX_COMPILER_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_COMPILER_FEATURES.rst b/Help/variable/CMAKE_CXX_COMPILER_FEATURES.rst
new file mode 100644
index 0000000..4423deb
--- /dev/null
+++ b/Help/variable/CMAKE_CXX_COMPILER_FEATURES.rst
@@ -0,0 +1,8 @@
+CMAKE_CXX_COMPILER_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..4062e18
--- /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_COMPILER_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.cmake b/Modules/Compiler/Clang-CXX.cmake
index 049b8ea..2b320ca 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_COMPILER_FEATURES)
+
+include("${CMAKE_ROOT}/Modules/Compiler/CxxFeatureTesting.cmake")
+
+macro(_get_clang_features std_version list)
+  record_cxx_compiler_features("-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_COMPILER_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_COMPILER_FEATURES)
 endif()
+
+unset(testable_features)
+
+set(CMAKE_CXX_COMPILER_FEATURES
+  ${CMAKE_CXX11_COMPILER_FEATURES}
+)
diff --git a/Modules/Compiler/Clang-features.cmake b/Modules/Compiler/Clang-features.cmake
new file mode 100644
index 0000000..074e5a1
--- /dev/null
+++ b/Modules/Compiler/Clang-features.cmake
@@ -0,0 +1,7 @@
+
+set(testable_features
+  cxx_delegating_constructors
+)
+foreach(feature ${testable_features})
+  set(feature_test_${feature} "__has_extension(${feature})")
+endforeach()
diff --git a/Modules/Compiler/CxxFeatureTesting.cmake b/Modules/Compiler/CxxFeatureTesting.cmake
new file mode 100644
index 0000000..97a9b0e
--- /dev/null
+++ b/Modules/Compiler/CxxFeatureTesting.cmake
@@ -0,0 +1,38 @@
+
+include("${CMAKE_ROOT}/Modules/Compiler/${CMAKE_COMPILER_ID}-features.cmake" OPTIONAL)
+
+macro(record_cxx_compiler_features compile_flags feature_list)
+  file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/feature_tests.cxx" "
+  extern const char features[] = {\n")
+  foreach(feature ${CMAKE_CXX_KNOWN_FEATURES})
+    set(_define_check "\n\"0\"\n")
+    if (feature_test_${feature})
+      set(_define_check "#if ${feature_test_${feature}}\n\"1\"\n#else${_define_check}#endif\n")
+    endif()
+    file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/feature_tests.cxx" "\"CXX_FEATURE:\"\n${_define_check}\"${feature}\\n\"\n")
+  endforeach()
+  file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/feature_tests.cxx" "\n};\n")
+
+  execute_process(COMMAND "${CMAKE_CXX_COMPILER}" ${compile_flags} "-c" "${CMAKE_CURRENT_BINARY_DIR}/feature_tests.cxx"
+    WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/CMakeFiles"
+    ERROR_VARIABLE _error
+    OUTPUT_VARIABLE _output
+  )
+  # 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 (EXISTS "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests${CMAKE_CXX_OUTPUT_EXTENSION}")
+    file(STRINGS "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests${CMAKE_CXX_OUTPUT_EXTENSION}"
+      features REGEX "CXX_FEATURE:.*")
+    foreach(info ${features})
+      string(REPLACE "CXX_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/Modules/Compiler/GNU-CXX.cmake b/Modules/Compiler/GNU-CXX.cmake
index dbbca78..d60d60d 100644
--- a/Modules/Compiler/GNU-CXX.cmake
+++ b/Modules/Compiler/GNU-CXX.cmake
@@ -11,6 +11,14 @@ else()
   endif()
 endif()
 
+set(CMAKE_CXX11_COMPILER_FEATURES)
+
+include("${CMAKE_ROOT}/Modules/Compiler/CxxFeatureTesting.cmake")
+
+macro(_get_gcc_features std_version list)
+  record_cxx_compiler_features("-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_COMPILER_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_COMPILER_FEATURES)
 endif()
+
+set(CMAKE_CXX_COMPILER_FEATURES
+  ${CMAKE_CXX11_COMPILER_FEATURES}
+)
diff --git a/Modules/Compiler/GNU-features.cmake b/Modules/Compiler/GNU-features.cmake
new file mode 100644
index 0000000..bb63250
--- /dev/null
+++ b/Modules/Compiler/GNU-features.cmake
@@ -0,0 +1,2 @@
+
+set(feature_test_cxx_delegating_constructors "(__GNUC__ * 100 + __GNUC_MINOR__) >= 407")
diff --git a/Modules/Compiler/Intel-CXX.cmake b/Modules/Compiler/Intel-CXX.cmake
index 4d11556..1eda76e 100644
--- a/Modules/Compiler/Intel-CXX.cmake
+++ b/Modules/Compiler/Intel-CXX.cmake
@@ -13,11 +13,16 @@ 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_CXX11_COMPILER_FEATURES)
+
+include("${CMAKE_ROOT}/Modules/Compiler/CxxFeatureTesting.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_cxx_compiler_features("-std=c++0x" CMAKE_CXX11_COMPILER_FEATURES)
     # TODO: Does intel support GNU extensions and -std=gnu++0x etc?
   endif()
 endif()
@@ -27,5 +32,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_cxx_compiler_features("-std=c++11" CMAKE_CXX11_COMPILER_FEATURES)
   endif()
 endif()
+
+set(CMAKE_CXX_COMPILER_FEATURES
+  ${CMAKE_CXX11_COMPILER_FEATURES}
+)
diff --git a/Modules/Compiler/Intel-features.cmake b/Modules/Compiler/Intel-features.cmake
new file mode 100644
index 0000000..07676a0
--- /dev/null
+++ b/Modules/Compiler/Intel-features.cmake
@@ -0,0 +1,2 @@
+
+set(feature_test_cxx_delegating_constructors "__INTEL_COMPILER >= 1400")
diff --git a/Modules/Compiler/XL-CXX.cmake b/Modules/Compiler/XL-CXX.cmake
index a07a059..706b789 100644
--- a/Modules/Compiler/XL-CXX.cmake
+++ b/Modules/Compiler/XL-CXX.cmake
@@ -10,6 +10,16 @@ set(CMAKE_CXX_FLAGS_INIT "-qthreaded -qhalt=e")
 set(CMAKE_CXX_COMPILE_OBJECT
   "<CMAKE_CXX_COMPILER> -+ <DEFINES> <FLAGS> -o <OBJECT> -c <SOURCE>")
 
+set(CMAKE_CXX11_COMPILER_FEATURES)
+
+include("${CMAKE_ROOT}/Modules/Compiler/CxxFeatureTesting.cmake")
+
 if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10.1)
    set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-qlanglvl=extended0x")
+   record_cxx_compiler_features("-qlanglvl=extended0x" CMAKE_CXX11_COMPILER_FEATURES)
 endif()
+
+
+set(CMAKE_CXX_COMPILER_FEATURES
+  ${CMAKE_CXX11_COMPILER_FEATURES}
+)
diff --git a/Modules/Compiler/XL-features.cmake b/Modules/Compiler/XL-features.cmake
new file mode 100644
index 0000000..64dcb2c
--- /dev/null
+++ b/Modules/Compiler/XL-features.cmake
@@ -0,0 +1,2 @@
+
+set(feature_test_cxx_delegating_constructors "__IBMCPP__ >= 1110")
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index ade4252..d92b7ad 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)
     {

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f824c0dac4c409644337096895fae7d4e7483095
commit f824c0dac4c409644337096895fae7d4e7483095
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Oct 13 02:00:24 2013 +0200
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Oct 28 08:45:58 2013 -0400

    Add CXX_STANDARD and CXX_EXTENSION target properties.
    
    These are used to determine whether to add -std=c++11, -std=gnu++11
    etc flags on the compile line.

diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst
index 658da20..c1fef71 100644
--- a/Help/manual/cmake-properties.7.rst
+++ b/Help/manual/cmake-properties.7.rst
@@ -85,6 +85,8 @@ Properties on Targets
    /prop_tgt/COMPILE_OPTIONS
    /prop_tgt/CONFIG_OUTPUT_NAME
    /prop_tgt/CONFIG_POSTFIX
+   /prop_tgt/CXX_STANDARD
+   /prop_tgt/CXX_EXTENSIONS
    /prop_tgt/DEBUG_POSTFIX
    /prop_tgt/DEFINE_SYMBOL
    /prop_tgt/EchoString
diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst
index 2311ac8..912fafa 100644
--- a/Help/manual/cmake-variables.7.rst
+++ b/Help/manual/cmake-variables.7.rst
@@ -203,6 +203,7 @@ Variables for Languages
 
 .. toctree::
    /variable/CMAKE_COMPILER_IS_GNULANG
+   /variable/CMAKE_CXX_STANDARD
    /variable/CMAKE_Fortran_MODDIR_DEFAULT
    /variable/CMAKE_Fortran_MODDIR_FLAG
    /variable/CMAKE_Fortran_MODOUT_FLAG
diff --git a/Help/prop_tgt/CXX_EXTENSIONS.rst b/Help/prop_tgt/CXX_EXTENSIONS.rst
new file mode 100644
index 0000000..329e2c9
--- /dev/null
+++ b/Help/prop_tgt/CXX_EXTENSIONS.rst
@@ -0,0 +1,8 @@
+CXX_EXTENSIONS
+--------------
+
+Boolean specifying whether compiler specific extensions are requested.
+
+This property specifies whether compiler specific extensions should be
+used.  For some compilers, this results in adding a flag such as -std=gnu++11
+instead of -std=c++11 to the compile line.
diff --git a/Help/prop_tgt/CXX_STANDARD.rst b/Help/prop_tgt/CXX_STANDARD.rst
new file mode 100644
index 0000000..c3cd486
--- /dev/null
+++ b/Help/prop_tgt/CXX_STANDARD.rst
@@ -0,0 +1,13 @@
+CXX_STANDARD
+------------
+
+The C++ standard whose features are required to build this target.
+
+This property specifies the C++ standard whose features are required
+to build this target.  For some compilers, this results in adding a
+flag such as -std=c++11 to the compile line.
+
+Supported values are 98 and 11.
+
+This property is initialized by the value of the :variable:`CMAKE_CXX_STANDARD`
+variable if it is set when a target is created.
diff --git a/Help/variable/CMAKE_CXX_STANDARD.rst b/Help/variable/CMAKE_CXX_STANDARD.rst
new file mode 100644
index 0000000..87c00c8
--- /dev/null
+++ b/Help/variable/CMAKE_CXX_STANDARD.rst
@@ -0,0 +1,8 @@
+CMAKE_CXX_STANDARD
+------------------
+
+Default value for CXX_STANDARD property of targets.
+
+This variable is used to initialize the :prop_tgt:`CXX_STANDARD`
+property on all targets.  See that target property for additional
+information.
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index edf80e6..f343a9e 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -1384,6 +1384,7 @@ void cmLocalGenerator::AddCompileOptions(
       this->AppendFlagEscape(flags, i->c_str());
       }
     }
+  this->AddCompilerRequirementFlag(flags, target, lang);
 }
 
 //----------------------------------------------------------------------------
@@ -2063,6 +2064,36 @@ void cmLocalGenerator::AddSharedFlags(std::string& flags,
     }
 }
 
+//----------------------------------------------------------------------------
+void cmLocalGenerator::
+AddCompilerRequirementFlag(std::string &flags, cmTarget* target,
+                           const char *lang)
+{
+  if (!lang)
+    {
+    return;
+    }
+  std::string l(lang);
+  std::string stdProp = l + "_STANDARD";
+  const char *standard = target->GetProperty(stdProp.c_str());
+  if (!standard)
+    {
+    return;
+    }
+  std::string extProp = l + "_EXTENSIONS";
+  bool ext = target->GetPropertyAsBool(extProp.c_str());
+  std::string type = ext ? "EXTENSION" : "STANDARD";
+
+  std::string compile_option =
+            "CMAKE_" + l + std::string(standard)
+                     + "_" + type + "_COMPILE_OPTION";
+  if (const char *opt =
+                target->GetMakefile()->GetDefinition(compile_option.c_str()))
+    {
+    this->AppendFlags(flags, opt);
+    }
+}
+
 static void AddVisibilityCompileOption(std::string &flags, cmTarget* target,
                                        cmLocalGenerator *lg, const char *lang)
 {
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 21700e9..4a307f7 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -147,6 +147,8 @@ public:
                                 const char *lang);
   void AddConfigVariableFlags(std::string& flags, const char* var,
                               const char* config);
+  void AddCompilerRequirementFlag(std::string &flags, cmTarget* target,
+                                  const char *lang);
   ///! Append flags to a string.
   virtual void AppendFlags(std::string& flags, const char* newFlags);
   virtual void AppendFlagEscape(std::string& flags, const char* rawFlag);
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index ea0b504..4f58700 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -281,6 +281,7 @@ void cmTarget::SetMakefile(cmMakefile* mf)
   this->SetPropertyDefault("MACOSX_BUNDLE", 0);
   this->SetPropertyDefault("MACOSX_RPATH", 0);
   this->SetPropertyDefault("NO_SYSTEM_FROM_IMPORTED", 0);
+  this->SetPropertyDefault("CXX_STANDARD", 0);
 
 
   // Collect the set of configuration types.
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 5ffd9d7..d1d1268 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -247,6 +247,12 @@ if(BUILD_TESTING)
   ADD_TEST_MACRO(CompatibleInterface CompatibleInterface)
   ADD_TEST_MACRO(AliasTarget AliasTarget)
   ADD_TEST_MACRO(InterfaceLibrary InterfaceLibrary)
+  if((CMAKE_CXX_COMPILER_ID STREQUAL GNU
+        AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.6)
+      OR (CMAKE_CXX_COMPILER_ID STREQUAL Clang
+        AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 2.9))
+    ADD_TEST_MACRO(CxxDialect CxxDialect)
+  endif()
   set_tests_properties(EmptyLibrary PROPERTIES
     PASS_REGULAR_EXPRESSION "CMake Error: CMake can not determine linker language for target: test")
   ADD_TEST_MACRO(CrossCompile CrossCompile)
diff --git a/Tests/CxxDialect/CMakeLists.txt b/Tests/CxxDialect/CMakeLists.txt
new file mode 100644
index 0000000..c55f838
--- /dev/null
+++ b/Tests/CxxDialect/CMakeLists.txt
@@ -0,0 +1,12 @@
+project(CxxDialect)
+
+add_executable(use_typeof use_typeof.cxx)
+set_property(TARGET use_typeof PROPERTY CXX_STANDARD 98)
+set_property(TARGET use_typeof PROPERTY CXX_EXTENSIONS TRUE)
+
+add_executable(use_constexpr use_constexpr.cxx)
+set_property(TARGET use_constexpr PROPERTY CXX_STANDARD 11)
+
+add_executable(CxxDialect use_constexpr_and_typeof.cxx)
+set_property(TARGET CxxDialect PROPERTY CXX_STANDARD 11)
+set_property(TARGET CxxDialect PROPERTY CXX_EXTENSIONS TRUE)
diff --git a/Tests/CxxDialect/use_constexpr.cxx b/Tests/CxxDialect/use_constexpr.cxx
new file mode 100644
index 0000000..30ccc4c
--- /dev/null
+++ b/Tests/CxxDialect/use_constexpr.cxx
@@ -0,0 +1,10 @@
+
+constexpr int foo()
+{
+  return 0;
+}
+
+int main(int argc, char**)
+{
+  return foo();
+}
diff --git a/Tests/CxxDialect/use_constexpr_and_typeof.cxx b/Tests/CxxDialect/use_constexpr_and_typeof.cxx
new file mode 100644
index 0000000..af217b6
--- /dev/null
+++ b/Tests/CxxDialect/use_constexpr_and_typeof.cxx
@@ -0,0 +1,11 @@
+
+constexpr int foo()
+{
+  return 0;
+}
+
+int main(int argc, char**)
+{
+  typeof(argc) ret = foo();
+  return ret;
+}
diff --git a/Tests/CxxDialect/use_typeof.cxx b/Tests/CxxDialect/use_typeof.cxx
new file mode 100644
index 0000000..dabb61f
--- /dev/null
+++ b/Tests/CxxDialect/use_typeof.cxx
@@ -0,0 +1,6 @@
+
+int main(int argc, char**)
+{
+  typeof(argc) ret = 0;
+  return ret;
+}

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7ea06dcb17eeac063fd4d844ee200c4d095d83f6
commit 7ea06dcb17eeac063fd4d844ee200c4d095d83f6
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Oct 13 01:26:16 2013 +0200
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Oct 28 08:45:58 2013 -0400

    Add some COMPILE_OPTIONS for specifying C++ dialect.
    
    These are compiler-specific, compiler version specific, extension specific
    and standard version specific.

diff --git a/Modules/Compiler/Clang-CXX.cmake b/Modules/Compiler/Clang-CXX.cmake
index 0372e18..049b8ea 100644
--- a/Modules/Compiler/Clang-CXX.cmake
+++ b/Modules/Compiler/Clang-CXX.cmake
@@ -4,3 +4,16 @@ __compiler_clang(CXX)
 if(NOT CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
   set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden")
 endif()
+
+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")
+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")
+endif()
diff --git a/Modules/Compiler/GNU-CXX.cmake b/Modules/Compiler/GNU-CXX.cmake
index 33d6093..dbbca78 100644
--- a/Modules/Compiler/GNU-CXX.cmake
+++ b/Modules/Compiler/GNU-CXX.cmake
@@ -10,3 +10,17 @@ else()
     set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden")
   endif()
 endif()
+
+# Appropriate version?
+if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.3)
+  set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98")
+  set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98")
+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")
+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")
+endif()
diff --git a/Modules/Compiler/Intel-CXX.cmake b/Modules/Compiler/Intel-CXX.cmake
index 35bb3ec..4d11556 100644
--- a/Modules/Compiler/Intel-CXX.cmake
+++ b/Modules/Compiler/Intel-CXX.cmake
@@ -12,3 +12,20 @@ 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>")
+
+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")
+    # TODO: Does intel support GNU extensions and -std=gnu++0x etc?
+  endif()
+endif()
+
+if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13)
+  if (CMAKE_CXX_SIMULATE_ID STREQUAL MSVC)
+    set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "/Qstd=c++11")
+  else()
+    set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11")
+  endif()
+endif()
diff --git a/Modules/Compiler/XL-CXX.cmake b/Modules/Compiler/XL-CXX.cmake
index 6c842cd..a07a059 100644
--- a/Modules/Compiler/XL-CXX.cmake
+++ b/Modules/Compiler/XL-CXX.cmake
@@ -9,3 +9,7 @@ set(CMAKE_CXX_FLAGS_INIT "-qthreaded -qhalt=e")
 
 set(CMAKE_CXX_COMPILE_OBJECT
   "<CMAKE_CXX_COMPILER> -+ <DEFINES> <FLAGS> -o <OBJECT> -c <SOURCE>")
+
+if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10.1)
+   set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-qlanglvl=extended0x")
+endif()

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

Summary of changes:


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list