[Cmake-commits] CMake branch, next, updated. v3.7.0-rc2-852-g3a0b88c

Brad King brad.king at kitware.com
Tue Nov 1 09:55:44 EDT 2016


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  3a0b88c121e39bf66e55c5e0e5f126fd0290ab4f (commit)
       via  bb290d80b397e2eba99982548b790c127bbcf4f5 (commit)
       via  468f1d46ea0b184c13589dbddd2c48709696fa51 (commit)
       via  f2e4518a2794b278c8a3308a0f708f3977564589 (commit)
       via  79d1906aefd527c10e488523aaf5a7ebc38463f4 (commit)
       via  916c507c53546f4bacb236749934d2f53d85e48d (commit)
      from  15da528a4f90e497d8ecd3592e0c19e6aed4307f (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 -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3a0b88c121e39bf66e55c5e0e5f126fd0290ab4f
commit 3a0b88c121e39bf66e55c5e0e5f126fd0290ab4f
Merge: 15da528 bb290d8
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Nov 1 09:55:43 2016 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Tue Nov 1 09:55:43 2016 -0400

    Merge topic 'compile-features-for-language-standards' into next
    
    bb290d80 Help: Document language standard meta-features
    468f1d46 Features: Test cycle diagnostic with language standard meta-feature
    f2e4518a Features: Test feature propagation with language standard meta-feature
    79d1906a WCDH: Ignore language standard meta-features
    916c507c Features: Add meta-features requesting awareness of a particular standard


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bb290d80b397e2eba99982548b790c127bbcf4f5
commit bb290d80b397e2eba99982548b790c127bbcf4f5
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Fri Oct 28 09:31:48 2016 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Fri Oct 28 10:01:56 2016 -0400

    Help: Document language standard meta-features

diff --git a/Help/manual/cmake-compile-features.7.rst b/Help/manual/cmake-compile-features.7.rst
index 7289e61..6018f6c 100644
--- a/Help/manual/cmake-compile-features.7.rst
+++ b/Help/manual/cmake-compile-features.7.rst
@@ -84,6 +84,33 @@ Feature requirements are evaluated transitively by consuming the link
 implementation.  See :manual:`cmake-buildsystem(7)` for more on
 transitive behavior of build properties and usage requirements.
 
+Requiring Language Standards
+----------------------------
+
+In projects that use a large number of commonly available features from
+a particular language standard (e.g. C++ 11) one may specify a
+meta-feature (e.g. ``cxx_std_11``) that requires use of a compiler mode
+aware of that standard.  This is simpler than specifying all the
+features individually, but does not guarantee the existence of any
+particular feature.  Diagnosis of use of unsupported features will be
+delayed until compile time.
+
+For example, if C++ 11 features are used extensively in a project's
+header files, then clients must use a compiler mode aware of C++ 11
+or above.  This can be requested with the code:
+
+.. code-block:: cmake
+
+  target_compile_features(mylib PUBLIC cxx_std_11)
+
+In this example, CMake will ensure the compiler is invoked in a mode
+that is aware of C++ 11 (or above), adding flags such as
+``-std=gnu++11`` if necessary.  This applies to sources within ``mylib``
+as well as any dependents (that may include headers from ``mylib``).
+
+Availability of Compiler Extensions
+-----------------------------------
+
 Because the :prop_tgt:`CXX_EXTENSIONS` target property is ``ON`` by default,
 CMake uses extended variants of language dialects by default, such as
 ``-std=gnu++11`` instead of ``-std=c++11``.  That target property may be
diff --git a/Help/release/dev/compile-features-for-language-standards.rst b/Help/release/dev/compile-features-for-language-standards.rst
new file mode 100644
index 0000000..20473b7
--- /dev/null
+++ b/Help/release/dev/compile-features-for-language-standards.rst
@@ -0,0 +1,7 @@
+compile-features-for-language-standards
+---------------------------------------
+
+* The :manual:`Compile Features <cmake-compile-features(7)>` functionality
+  now offers meta-features that request compiler modes for specific language
+  standard levels.  See :prop_gbl:`CMAKE_C_KNOWN_FEATURES` and
+  :prop_gbl:`CMAKE_CXX_KNOWN_FEATURES`.

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=468f1d46ea0b184c13589dbddd2c48709696fa51
commit 468f1d46ea0b184c13589dbddd2c48709696fa51
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Fri Oct 28 09:43:34 2016 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Fri Oct 28 10:01:55 2016 -0400

    Features: Test cycle diagnostic with language standard meta-feature
    
    The `cxx_static_assert` feature may be available in C++ 98 mode of some
    compilers or not available at all in others.  Intstead of using an
    individual feature to test cyclic requirement of a feature requiring
    C++ 11, use the `std_cxx_11` meta-feature that has exactly this meaning.

diff --git a/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycle.cmake b/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycle.cmake
index 09594bd..2d14a9e 100644
--- a/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycle.cmake
+++ b/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycle.cmake
@@ -3,13 +3,13 @@ add_library(empty1 empty.cpp)
 
 add_library(empty2 INTERFACE)
 add_library(empty3 INTERFACE)
-target_compile_features(empty3 INTERFACE cxx_static_assert)
+target_compile_features(empty3 INTERFACE cxx_std_11)
 
 target_link_libraries(empty1
   # When starting, $<COMPILE_FEATURES:cxx_auto_type> is '0', so 'freeze' the
   # CXX_STANDARD at 98 during computation.
   $<$<COMPILE_FEATURES:cxx_auto_type>:empty2>
-  # This would add cxx_static_assert, but that would require CXX_STANDARD = 11,
+  # This would add cxx_std_11, but that would require CXX_STANDARD = 11,
   # which is not allowed after freeze.  Report an error.
   empty3
 )
diff --git a/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycleSolved.cmake b/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycleSolved.cmake
index bbcf4e0..a04dcec 100644
--- a/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycleSolved.cmake
+++ b/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycleSolved.cmake
@@ -3,7 +3,7 @@ add_library(empty1 empty.cpp)
 
 add_library(empty2 INTERFACE)
 add_library(empty3 INTERFACE)
-target_compile_features(empty3 INTERFACE cxx_static_assert)
+target_compile_features(empty3 INTERFACE cxx_std_11)
 
 target_link_libraries(empty1
   $<$<COMPILE_FEATURES:cxx_nullptr>:empty2>

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f2e4518a2794b278c8a3308a0f708f3977564589
commit f2e4518a2794b278c8a3308a0f708f3977564589
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Fri Oct 28 09:41:30 2016 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Fri Oct 28 10:01:55 2016 -0400

    Features: Test feature propagation with language standard meta-feature
    
    The `cxx_static_assert` feature may be available in C++ 98 mode of some
    compilers or not available at all in others.  Intstead of using an
    individual feature to test propagation of a feature requiring C++ 11,
    use the `std_cxx_11` meta-feature that has exactly this meaning.

diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt
index 9986de0..9f61186 100644
--- a/Tests/CompileFeatures/CMakeLists.txt
+++ b/Tests/CompileFeatures/CMakeLists.txt
@@ -398,7 +398,7 @@ if (CMAKE_CXX_COMPILE_FEATURES)
   )
 
   add_executable(CompileFeaturesGenex2 genex_test.cpp)
-  target_compile_features(CompileFeaturesGenex2 PRIVATE cxx_static_assert)
+  target_compile_features(CompileFeaturesGenex2 PRIVATE cxx_std_11)
   target_compile_definitions(CompileFeaturesGenex2 PRIVATE
     HAVE_OVERRIDE_CONTROL=$<COMPILE_FEATURES:cxx_final,cxx_override>
     HAVE_AUTO_TYPE=$<COMPILE_FEATURES:cxx_auto_type>
@@ -407,10 +407,10 @@ if (CMAKE_CXX_COMPILE_FEATURES)
     HAVE_INHERITING_CONSTRUCTORS_AND_FINAL=$<COMPILE_FEATURES:cxx_inheriting_constructors,cxx_final>
   )
 
-  add_library(static_assert_iface INTERFACE)
-  target_compile_features(static_assert_iface INTERFACE cxx_static_assert)
+  add_library(std_11_iface INTERFACE)
+  target_compile_features(std_11_iface INTERFACE cxx_std_11)
   add_executable(CompileFeaturesGenex3 genex_test.cpp)
-  target_link_libraries(CompileFeaturesGenex3 PRIVATE static_assert_iface)
+  target_link_libraries(CompileFeaturesGenex3 PRIVATE std_11_iface)
   target_compile_definitions(CompileFeaturesGenex3 PRIVATE
     HAVE_OVERRIDE_CONTROL=$<COMPILE_FEATURES:cxx_final,cxx_override>
     HAVE_AUTO_TYPE=$<COMPILE_FEATURES:cxx_auto_type>

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=79d1906aefd527c10e488523aaf5a7ebc38463f4
commit 79d1906aefd527c10e488523aaf5a7ebc38463f4
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Oct 26 16:26:22 2016 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Fri Oct 28 10:01:54 2016 -0400

    WCDH: Ignore language standard meta-features
    
    The `{c,cxx}_std_*` features are meant for use with
    `target_compile_features` but do not make sense for use with
    WriteCompilerDetectionHeader.  Filter them out of any requested list.

diff --git a/Modules/WriteCompilerDetectionHeader.cmake b/Modules/WriteCompilerDetectionHeader.cmake
index 82e8fba..a390f4b 100644
--- a/Modules/WriteCompilerDetectionHeader.cmake
+++ b/Modules/WriteCompilerDetectionHeader.cmake
@@ -76,6 +76,7 @@
 # Available features in this version of CMake are listed in the
 # :prop_gbl:`CMAKE_C_KNOWN_FEATURES` and
 # :prop_gbl:`CMAKE_CXX_KNOWN_FEATURES` global properties.
+# The ``{c,cxx}_std_*`` meta-features are ignored if requested.
 #
 # See the :manual:`cmake-compile-features(7)` manual for information on
 # compile features.
@@ -358,7 +359,11 @@ function(write_compiler_detection_header
   endif()
 
   foreach(feature ${_WCD_FEATURES})
-    if (feature MATCHES "^cxx_")
+    if (feature MATCHES "^c_std_")
+      # ignored
+    elseif (feature MATCHES "^cxx_std_")
+      # ignored
+    elseif (feature MATCHES "^cxx_")
       list(APPEND _langs CXX)
       list(APPEND CXX_features ${feature})
     elseif (feature MATCHES "^c_")

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=916c507c53546f4bacb236749934d2f53d85e48d
commit 916c507c53546f4bacb236749934d2f53d85e48d
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Oct 26 16:11:01 2016 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Fri Oct 28 10:01:54 2016 -0400

    Features: Add meta-features requesting awareness of a particular standard
    
    A common use case of `target_compile_features` is simply to specify that
    the compiler should be run in a mode that is aware of e.g. C++11.  Some
    projects simply specify a particular C++11-only feature to request this.
    Provide a first-class way to do this by naming features after the
    corresponding language standard.  Record them as always available in
    exactly the corresponding standard level so that requesting them always
    ensures that standard (or higher) is used.

diff --git a/Help/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.rst
index e8f4d2a..00a5104 100644
--- a/Help/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.rst
+++ b/Help/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.rst
@@ -14,6 +14,15 @@ compile features and a list of supported compilers.
 
 The features known to this version of CMake are:
 
+``cxx_std_98``
+  Compiler mode is aware of C++ 98.
+
+``cxx_std_11``
+  Compiler mode is aware of C++ 11.
+
+``cxx_std_14``
+  Compiler mode is aware of C++ 14.
+
 ``cxx_aggregate_default_initializers``
   Aggregate default initializers, as defined in N3605_.
 
diff --git a/Help/prop_gbl/CMAKE_C_KNOWN_FEATURES.rst b/Help/prop_gbl/CMAKE_C_KNOWN_FEATURES.rst
index a08af00..3707fef 100644
--- a/Help/prop_gbl/CMAKE_C_KNOWN_FEATURES.rst
+++ b/Help/prop_gbl/CMAKE_C_KNOWN_FEATURES.rst
@@ -13,6 +13,15 @@ compile features and a list of supported compilers.
 
 The features known to this version of CMake are:
 
+``c_std_90``
+  Compiler mode is aware of C 90.
+
+``c_std_99``
+  Compiler mode is aware of C 99.
+
+``c_std_11``
+  Compiler mode is aware of C 11.
+
 ``c_function_prototypes``
   Function prototypes, as defined in ``ISO/IEC 9899:1990``.
 
diff --git a/Modules/CMakeDetermineCompileFeatures.cmake b/Modules/CMakeDetermineCompileFeatures.cmake
index 5ca72cc..ea51847 100644
--- a/Modules/CMakeDetermineCompileFeatures.cmake
+++ b/Modules/CMakeDetermineCompileFeatures.cmake
@@ -7,9 +7,9 @@ function(cmake_determine_compile_features lang)
   if(lang STREQUAL C AND COMMAND cmake_record_c_compile_features)
     message(STATUS "Detecting ${lang} compile features")
 
-    set(CMAKE_C90_COMPILE_FEATURES)
-    set(CMAKE_C99_COMPILE_FEATURES)
-    set(CMAKE_C11_COMPILE_FEATURES)
+    set(CMAKE_C90_COMPILE_FEATURES c_std_90)
+    set(CMAKE_C99_COMPILE_FEATURES c_std_99)
+    set(CMAKE_C11_COMPILE_FEATURES c_std_11)
 
     include("${CMAKE_ROOT}/Modules/Internal/FeatureTesting.cmake")
 
@@ -27,7 +27,13 @@ function(cmake_determine_compile_features lang)
       list(REMOVE_ITEM CMAKE_C99_COMPILE_FEATURES ${CMAKE_C90_COMPILE_FEATURES})
     endif()
 
-    if(NOT CMAKE_C_COMPILE_FEATURES)
+    if(CMAKE_C_COMPILE_FEATURES)
+      list(INSERT CMAKE_C_COMPILE_FEATURES 0
+        c_std_90
+        c_std_99
+        c_std_11
+        )
+    else()
       set(CMAKE_C_COMPILE_FEATURES
         ${CMAKE_C90_COMPILE_FEATURES}
         ${CMAKE_C99_COMPILE_FEATURES}
@@ -45,9 +51,9 @@ function(cmake_determine_compile_features lang)
   elseif(lang STREQUAL CXX AND COMMAND cmake_record_cxx_compile_features)
     message(STATUS "Detecting ${lang} compile features")
 
-    set(CMAKE_CXX98_COMPILE_FEATURES)
-    set(CMAKE_CXX11_COMPILE_FEATURES)
-    set(CMAKE_CXX14_COMPILE_FEATURES)
+    set(CMAKE_CXX98_COMPILE_FEATURES cxx_std_98)
+    set(CMAKE_CXX11_COMPILE_FEATURES cxx_std_11)
+    set(CMAKE_CXX14_COMPILE_FEATURES cxx_std_14)
 
     include("${CMAKE_ROOT}/Modules/Internal/FeatureTesting.cmake")
 
@@ -65,7 +71,13 @@ function(cmake_determine_compile_features lang)
       list(REMOVE_ITEM CMAKE_CXX11_COMPILE_FEATURES ${CMAKE_CXX98_COMPILE_FEATURES})
     endif()
 
-    if(NOT CMAKE_CXX_COMPILE_FEATURES)
+    if(CMAKE_CXX_COMPILE_FEATURES)
+      list(INSERT CMAKE_CXX_COMPILE_FEATURES 0
+        cxx_std_98
+        cxx_std_11
+        cxx_std_14
+        )
+    else()
       set(CMAKE_CXX_COMPILE_FEATURES
         ${CMAKE_CXX98_COMPILE_FEATURES}
         ${CMAKE_CXX11_COMPILE_FEATURES}
diff --git a/Source/cmake.h b/Source/cmake.h
index cd00c61..6e8d9c8 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -535,12 +535,18 @@ private:
   }
 
 #define FOR_EACH_C_FEATURE(F)                                                 \
+  F(c_std_90)                                                                 \
+  F(c_std_99)                                                                 \
+  F(c_std_11)                                                                 \
   F(c_function_prototypes)                                                    \
   F(c_restrict)                                                               \
   F(c_static_assert)                                                          \
   F(c_variadic_macros)
 
 #define FOR_EACH_CXX_FEATURE(F)                                               \
+  F(cxx_std_98)                                                               \
+  F(cxx_std_11)                                                               \
+  F(cxx_std_14)                                                               \
   F(cxx_aggregate_default_initializers)                                       \
   F(cxx_alias_templates)                                                      \
   F(cxx_alignas)                                                              \
diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt
index 9f08523..9986de0 100644
--- a/Tests/CompileFeatures/CMakeLists.txt
+++ b/Tests/CompileFeatures/CMakeLists.txt
@@ -23,10 +23,12 @@ macro(run_test feature lang)
 endmacro()
 
 get_property(c_features GLOBAL PROPERTY CMAKE_C_KNOWN_FEATURES)
+list(REMOVE_ITEM c_features c_std_90 c_std_99 c_std_11)
 foreach(feature ${c_features})
   run_test(${feature} C)
 endforeach()
 get_property(cxx_features GLOBAL PROPERTY CMAKE_CXX_KNOWN_FEATURES)
+list(REMOVE_ITEM cxx_features cxx_std_98 cxx_std_11 cxx_std_14)
 foreach(feature ${cxx_features})
   run_test(${feature} CXX)
 endforeach()

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

Summary of changes:
 Help/manual/cmake-compile-features.7.rst           |   27 +++++++++++++++++++
 Help/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.rst         |    9 +++++++
 Help/prop_gbl/CMAKE_C_KNOWN_FEATURES.rst           |    9 +++++++
 .../compile-features-for-language-standards.rst    |    7 +++++
 Modules/CMakeDetermineCompileFeatures.cmake        |   28 ++++++++++++++------
 Modules/WriteCompilerDetectionHeader.cmake         |    7 ++++-
 Source/cmake.h                                     |    6 +++++
 Tests/CompileFeatures/CMakeLists.txt               |   10 ++++---
 .../LinkImplementationFeatureCycle.cmake           |    4 +--
 .../LinkImplementationFeatureCycleSolved.cmake     |    2 +-
 10 files changed, 93 insertions(+), 16 deletions(-)
 create mode 100644 Help/release/dev/compile-features-for-language-standards.rst


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list