[Cmake-commits] CMake branch, master, updated. v3.11.0-408-g3201e4c

Kitware Robot kwrobot at kitware.com
Wed Apr 4 11:25:03 EDT 2018


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, master has been updated
       via  3201e4c156fcf79a7c29a73430e72b1bcd43cedc (commit)
       via  49ea1bb243e8e2995bb3012a0b0ca226db845e3e (commit)
       via  b1aa90f057985d51773dadfe9e69bac45b061a50 (commit)
       via  6425ceb46cdb44396922819dcc56f919214cd85d (commit)
       via  f38d05023125803d42a6535dfc11c6de4041e28d (commit)
       via  b11e2c80b1e45fc12151c8392707d88b508191ca (commit)
       via  1d2c9d8c6d5ae93bd57e3dc8f1b54c54c3422644 (commit)
       via  ccc38fa509301a135e68542f9965f3ea9f0547b7 (commit)
       via  719b24c87244ac612cfdc85da0e75140b87df673 (commit)
       via  9a736158150852e9d011fabc0f4a33ce039be6fc (commit)
       via  65203ce407f589a6ba148baf64b07ada09205030 (commit)
       via  14a86c9ea7efae1b3acb01bc79f2f1f5ef23c5f1 (commit)
      from  8496d11ef8a5c4a14a13c7df5e7f214028c35f5c (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=3201e4c156fcf79a7c29a73430e72b1bcd43cedc
commit 3201e4c156fcf79a7c29a73430e72b1bcd43cedc
Merge: 49ea1bb b1aa90f
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Apr 4 11:22:23 2018 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Wed Apr 4 11:22:23 2018 -0400

    Merge branch 'release-3.11'


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=49ea1bb243e8e2995bb3012a0b0ca226db845e3e
commit 49ea1bb243e8e2995bb3012a0b0ca226db845e3e
Merge: 6425ceb b11e2c8
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Apr 4 15:21:48 2018 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Wed Apr 4 11:21:54 2018 -0400

    Merge topic 'autogen-protect-cmsys-calls'
    
    b11e2c80b1 Autogen: Print moc/uic/rcc output to stdout
    1d2c9d8c6d Autogen: Use std::istreambuf_iterator for file so string reading
    ccc38fa509 Autogen: Protected calls to cmFilePathChecksum
    719b24c872 Autogen: Protected calls to cmQtAutoGen::SubDirPrefix
    9a73615815 Autogen: Protected calls to cmSystemTools::GetFilenameWithoutLastExtension
    65203ce407 Autogen: Protected calls to cmSystemTools::Split/JoinPath
    14a86c9ea7 Autogen: Protected calls to cmSystemTools::CollapseCombinedPath
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !1918


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6425ceb46cdb44396922819dcc56f919214cd85d
commit 6425ceb46cdb44396922819dcc56f919214cd85d
Merge: 8496d11 f38d050
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Apr 4 15:16:38 2018 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Wed Apr 4 11:16:50 2018 -0400

    Merge topic 'wcdh-bare-features'
    
    f38d050231 WCDH: introduce BARE_FEATURES
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !1869


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f38d05023125803d42a6535dfc11c6de4041e28d
commit f38d05023125803d42a6535dfc11c6de4041e28d
Author:     Rolf Eike Beer <eike at sf-mail.de>
AuthorDate: Mon Mar 19 21:42:25 2018 +0100
Commit:     Rolf Eike Beer <eike at sf-mail.de>
CommitDate: Tue Apr 3 20:56:28 2018 +0200

    WCDH: introduce BARE_FEATURES
    
    This allows defining compat versions of some C/C++ features with the name of the
    keyword itself, so all code can look as if it was written for the new language
    standard.

diff --git a/Help/release/dev/wcdh-raw-features.rst b/Help/release/dev/wcdh-raw-features.rst
new file mode 100644
index 0000000..bdc7b62
--- /dev/null
+++ b/Help/release/dev/wcdh-raw-features.rst
@@ -0,0 +1,6 @@
+wcdh-raw-features
+-----------------
+
+* The :module:`WriteCompilerDetectionHeader` module now supports the
+  ``BARE_FEATURES`` argument which allows to add a compatibility define for
+  the exact keyword of a new language feature.
diff --git a/Modules/WriteCompilerDetectionHeader.cmake b/Modules/WriteCompilerDetectionHeader.cmake
index 675df84..3718e9d 100644
--- a/Modules/WriteCompilerDetectionHeader.cmake
+++ b/Modules/WriteCompilerDetectionHeader.cmake
@@ -17,6 +17,7 @@
 #              [OUTPUT_FILES_VAR <output_files_var> OUTPUT_DIR <output_dir>]
 #              COMPILERS <compiler> [...]
 #              FEATURES <feature> [...]
+#              [BARE_FEATURES <feature> [...]]
 #              [VERSION <version>]
 #              [PROLOG <prolog>]
 #              [EPILOG <epilog>]
@@ -83,10 +84,14 @@
 # See the :manual:`cmake-compile-features(7)` manual for information on
 # compile features.
 #
+# ``BARE_FEATURES`` will define the compatibility macros with the name used in
+# newer versions of the language standard, so the code can use the new feature
+# name unconditionally.
+#
 # ``ALLOW_UNKNOWN_COMPILERS`` and ``ALLOW_UNKNOWN_COMPILER_VERSIONS`` cause
 # the module to generate conditions that treat unknown compilers as simply
 # lacking all features.  Without these options the default behavior is to
-# generate a ``#error`` for unknown compilers.
+# generate a ``#error`` for unknown compilers and versions.
 #
 # Feature Test Macros
 # ===================
@@ -148,20 +153,24 @@
 # ``ClimbingStats_CONSTEXPR`` macro will expand to ``constexpr``
 # if ``cxx_constexpr`` is supported.
 #
-# The following features generate corresponding symbol defines:
+# If ``BARE_FEATURES cxx_final`` was given as argument the ``final`` keyword
+# will be defined for old compilers, too.
+#
+# The following features generate corresponding symbol defines and if they
+# are available as ``BARE_FEATURES``:
 #
-# ========================== =================================== =================
-#         Feature                          Define                      Symbol
-# ========================== =================================== =================
-# ``c_restrict``              ``<PREFIX>_RESTRICT``               ``restrict``
-# ``cxx_constexpr``           ``<PREFIX>_CONSTEXPR``              ``constexpr``
+# ========================== =================================== ================= ======
+#         Feature                          Define                      Symbol       bare
+# ========================== =================================== ================= ======
+# ``c_restrict``              ``<PREFIX>_RESTRICT``               ``restrict``      yes
+# ``cxx_constexpr``           ``<PREFIX>_CONSTEXPR``              ``constexpr``     yes
 # ``cxx_deleted_functions``   ``<PREFIX>_DELETED_FUNCTION``       ``= delete``
 # ``cxx_extern_templates``    ``<PREFIX>_EXTERN_TEMPLATE``        ``extern``
-# ``cxx_final``               ``<PREFIX>_FINAL``                  ``final``
-# ``cxx_noexcept``            ``<PREFIX>_NOEXCEPT``               ``noexcept``
+# ``cxx_final``               ``<PREFIX>_FINAL``                  ``final``         yes
+# ``cxx_noexcept``            ``<PREFIX>_NOEXCEPT``               ``noexcept``      yes
 # ``cxx_noexcept``            ``<PREFIX>_NOEXCEPT_EXPR(X)``       ``noexcept(X)``
-# ``cxx_override``            ``<PREFIX>_OVERRIDE``               ``override``
-# ========================== =================================== =================
+# ``cxx_override``            ``<PREFIX>_OVERRIDE``               ``override``      yes
+# ========================== =================================== ================= ======
 #
 # Compatibility Implementation Macros
 # ===================================
@@ -195,18 +204,18 @@
 # decorator or a compiler-specific decorator such as ``__alignof__``
 # used by GNU compilers.
 #
-# ============================= ================================ =====================
-#           Feature                          Define                     Symbol
-# ============================= ================================ =====================
+# ============================= ================================ ===================== ======
+#           Feature                          Define                     Symbol          bare
+# ============================= ================================ ===================== ======
 # ``cxx_alignas``                ``<PREFIX>_ALIGNAS``             ``alignas``
 # ``cxx_alignof``                ``<PREFIX>_ALIGNOF``             ``alignof``
-# ``cxx_nullptr``                ``<PREFIX>_NULLPTR``             ``nullptr``
+# ``cxx_nullptr``                ``<PREFIX>_NULLPTR``             ``nullptr``           yes
 # ``cxx_static_assert``          ``<PREFIX>_STATIC_ASSERT``       ``static_assert``
 # ``cxx_static_assert``          ``<PREFIX>_STATIC_ASSERT_MSG``   ``static_assert``
 # ``cxx_attribute_deprecated``   ``<PREFIX>_DEPRECATED``          ``[[deprecated]]``
 # ``cxx_attribute_deprecated``   ``<PREFIX>_DEPRECATED_MSG``      ``[[deprecated]]``
 # ``cxx_thread_local``           ``<PREFIX>_THREAD_LOCAL``        ``thread_local``
-# ============================= ================================ =====================
+# ============================= ================================ ===================== ======
 #
 # A use-case which arises with such deprecation macros is the deprecation
 # of an entire library.  In that case, all public API in the library may
@@ -252,6 +261,37 @@ macro(_simpledefine FEATURE_NAME FEATURE_TESTNAME FEATURE_STRING FEATURE_DEFAULT
   endif()
 endmacro()
 
+macro(_simplebaredefine FEATURE_NAME FEATURE_STRING FEATURE_DEFAULT_STRING)
+  if (feature STREQUAL "${FEATURE_NAME}")
+        string(APPEND file_content "
+#  if !(defined(${def_name}) && ${def_name})
+#    define ${FEATURE_STRING} ${FEATURE_DEFAULT_STRING}
+#  endif
+\n")
+  endif()
+endmacro()
+
+function(_check_feature_lists C_FEATURE_VAR CXX_FEATURE_VAR)
+  foreach(feature ${ARGN})
+    if (feature MATCHES "^c_std_")
+      # ignored
+    elseif (feature MATCHES "^cxx_std_")
+      # ignored
+    elseif (feature MATCHES "^cxx_")
+      list(APPEND _langs CXX)
+      list(APPEND ${CXX_FEATURE_VAR} ${feature})
+    elseif (feature MATCHES "^c_")
+      list(APPEND _langs C)
+      list(APPEND ${C_FEATURE_VAR} ${feature})
+    else()
+      message(FATAL_ERROR "Unsupported feature ${feature}.")
+    endif()
+  endforeach()
+  set(${C_FEATURE_VAR} ${${C_FEATURE_VAR}} PARENT_SCOPE)
+  set(${CXX_FEATURE_VAR} ${${CXX_FEATURE_VAR}} PARENT_SCOPE)
+  set(_langs ${_langs} PARENT_SCOPE)
+endfunction()
+
 function(write_compiler_detection_header
     file_keyword file_arg
     prefix_keyword prefix_arg
@@ -264,13 +304,13 @@ function(write_compiler_detection_header
   endif()
   set(options ALLOW_UNKNOWN_COMPILERS ALLOW_UNKNOWN_COMPILER_VERSIONS)
   set(oneValueArgs VERSION EPILOG PROLOG OUTPUT_FILES_VAR OUTPUT_DIR)
-  set(multiValueArgs COMPILERS FEATURES)
+  set(multiValueArgs COMPILERS FEATURES BARE_FEATURES)
   cmake_parse_arguments(_WCD "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
 
   if (NOT _WCD_COMPILERS)
     message(FATAL_ERROR "Invalid arguments.  write_compiler_detection_header requires at least one compiler.")
   endif()
-  if (NOT _WCD_FEATURES)
+  if (NOT _WCD_FEATURES AND NOT _WCD_BARE_FEATURES)
     message(FATAL_ERROR "Invalid arguments.  write_compiler_detection_header requires at least one feature.")
   endif()
 
@@ -377,21 +417,8 @@ function(write_compiler_detection_header
     )\n")
   endif()
 
-  foreach(feature ${_WCD_FEATURES})
-    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_")
-      list(APPEND _langs C)
-      list(APPEND C_features ${feature})
-    else()
-      message(FATAL_ERROR "Unsupported feature ${feature}.")
-    endif()
-  endforeach()
+  _check_feature_lists(C_features CXX_features ${_WCD_FEATURES})
+  _check_feature_lists(C_bare_features CXX_bare_features ${_WCD_BARE_FEATURES})
   list(REMOVE_DUPLICATES _langs)
 
   if(_WCD_OUTPUT_FILES_VAR)
@@ -606,6 +633,29 @@ template<> struct ${prefix_arg}StaticAssert<true>{};
       endif()
     endforeach()
 
+    foreach(feature ${${_lang}_bare_features})
+      string(TOUPPER ${feature} feature_upper)
+      set(feature_PP "COMPILER_${feature_upper}")
+      set(def_name ${prefix_arg}_${feature_PP})
+      _simplebaredefine(c_restrict restrict "")
+      _simplebaredefine(cxx_constexpr constexpr "")
+      _simplebaredefine(cxx_final final "")
+      _simplebaredefine(cxx_override override "")
+      if (feature STREQUAL cxx_nullptr)
+        set(def_value "nullptr")
+        string(APPEND file_content "
+#  if !(defined(${def_name}) && ${def_name})
+#    if ${prefix_arg}_COMPILER_IS_GNU
+#      define ${def_value} __null
+#    else
+#      define ${def_value} 0
+#    endif
+#  endif
+\n")
+      endif()
+      _simplebaredefine(cxx_noexcept noexcept "")
+    endforeach()
+
     string(APPEND file_content "#endif\n")
 
   endforeach()
diff --git a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt
index 52d4613..45bb229 100644
--- a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt
+++ b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt
@@ -190,7 +190,7 @@ write_compiler_detection_header(
   ALLOW_UNKNOWN_COMPILERS
 )
 
-# intentionally abuse the TEST_NULLPR variable: this will only work
+# intentionally abuse the TEST_NULLPTR variable: this will only work
 # with the fallback code.
 check_cxx_source_compiles("#include \"${CMAKE_CURRENT_BINARY_DIR}/test_compiler_detection_allow_unknown.h\"
 int main() {\n int i = TEST_NULLPTR;\n return 0; }\n"
@@ -199,3 +199,16 @@ int main() {\n int i = TEST_NULLPTR;\n return 0; }\n"
 if (NOT file_include_works_allow_unknown)
   message(SEND_ERROR "Inclusion of ${CMAKE_CURRENT_BINARY_DIR}/test_compiler_detection_allow_unknown.h was expected to work, but did not.")
 endif()
+
+# test for BARE_FEATURES
+
+write_compiler_detection_header(
+  FILE "${CMAKE_CURRENT_BINARY_DIR}/test_compiler_detection_bare_features.h"
+  PREFIX TEST
+  COMPILERS GNU Clang AppleClang MSVC SunPro Intel
+  VERSION 3.1
+  BARE_FEATURES cxx_nullptr cxx_override cxx_noexcept cxx_final
+)
+
+add_executable(WriteCompilerDetectionHeaderBareFeatures main_bare.cpp)
+set_property(TARGET WriteCompilerDetectionHeaderBareFeatures PROPERTY CXX_STANDARD 11)
diff --git a/Tests/Module/WriteCompilerDetectionHeader/main_bare.cpp b/Tests/Module/WriteCompilerDetectionHeader/main_bare.cpp
new file mode 100644
index 0000000..6954318
--- /dev/null
+++ b/Tests/Module/WriteCompilerDetectionHeader/main_bare.cpp
@@ -0,0 +1,23 @@
+#include "test_compiler_detection_bare_features.h"
+
+class base
+{
+public:
+  virtual ~base() {}
+  virtual void baz() = 0;
+};
+
+class foo final
+{
+public:
+  virtual ~foo() {}
+  char* bar;
+  void baz() noexcept override { bar = nullptr; }
+};
+
+int main()
+{
+  foo f;
+
+  return 0;
+}
diff --git a/Tests/RunCMake/WriteCompilerDetectionHeader/InvalidFeature-stderr.txt b/Tests/RunCMake/WriteCompilerDetectionHeader/InvalidFeature-stderr.txt
index 0445744..f444992 100644
--- a/Tests/RunCMake/WriteCompilerDetectionHeader/InvalidFeature-stderr.txt
+++ b/Tests/RunCMake/WriteCompilerDetectionHeader/InvalidFeature-stderr.txt
@@ -1,5 +1,6 @@
 CMake Error at .*Modules/WriteCompilerDetectionHeader.cmake:[0-9]+ \(message\):
   Unsupported feature not_a_feature.
 Call Stack \(most recent call first\):
+  .*Modules/WriteCompilerDetectionHeader.cmake:[0-9]+ \(_check_feature_lists\)
   InvalidFeature.cmake:4 \(write_compiler_detection_header\)
   CMakeLists.txt:3 \(include\)

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

Summary of changes:
 Help/release/dev/wcdh-raw-features.rst             |    6 +
 Modules/WriteCompilerDetectionHeader.cmake         |  116 ++++++++++++++------
 Source/cmQtAutoGenerator.cxx                       |  111 +++++++++++++++----
 Source/cmQtAutoGenerator.h                         |   38 ++++++-
 Source/cmQtAutoGeneratorMocUic.cxx                 |   52 +++++----
 Source/cmQtAutoGeneratorMocUic.h                   |    2 -
 Source/cmQtAutoGeneratorRcc.cxx                    |    8 +-
 .../WriteCompilerDetectionHeader/CMakeLists.txt    |   15 ++-
 .../WriteCompilerDetectionHeader/main_bare.cpp     |   23 ++++
 .../InvalidFeature-stderr.txt                      |    1 +
 10 files changed, 290 insertions(+), 82 deletions(-)
 create mode 100644 Help/release/dev/wcdh-raw-features.rst
 create mode 100644 Tests/Module/WriteCompilerDetectionHeader/main_bare.cpp


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list