Hello,

At the ned of this mail is a patch that adds generation of a macro for
the relaxed ("c++14") constexpr in WriteCompilerDetectionHeader.

This is intended for compilers that support c++11 constexpr (with
everything on a single return statement) like GCC-4.9 and the upcoming
MSVC, but not extended constexpr which allows for more complete
functions. This way, code bases can reap the benefits of most recent
compilers at no cost.

Best regards
Jean-Michaël Celerier


diff --git a/Modules/WriteCompilerDetectionHeader.cmake
b/Modules/WriteCompilerDetectionHeader.cmake
index a3b73bb..f7af7ec 100644
--- a/Modules/WriteCompilerDetectionHeader.cmake
+++ b/Modules/WriteCompilerDetectionHeader.cmake
@@ -144,6 +144,7 @@
 # ========================== ===================================
=================
 # ``c_restrict``              ``<PREFIX>_RESTRICT``               ``restrict``
 # ``cxx_constexpr``           ``<PREFIX>_CONSTEXPR``              ``constexpr``
+# ``cxx_relaxed_constexpr``   ``<PREFIX>_RELAXED_CONSTEXPR``      ``constexpr``
 # ``cxx_deleted_functions``   ``<PREFIX>_DELETED_FUNCTION``       ``= delete``
 # ``cxx_extern_templates``    ``<PREFIX>_EXTERN_TEMPLATE``        ``extern``
 # ``cxx_final``               ``<PREFIX>_FINAL``                  ``final``
@@ -494,6 +495,16 @@ function(write_compiler_detection_header
 #  endif
 \n")
       endif()
+      if (feature STREQUAL cxx_relaxed_constexpr)
+        set(def_value "${prefix_arg}_RELAXED_CONSTEXPR")
+        set(file_content "${file_content}
+#  if ${def_name}
+#    define ${def_value} constexpr
+#  else
+#    define ${def_value}
+#  endif
+\n")
+      endif()
       if (feature STREQUAL cxx_final)
         set(def_value "${prefix_arg}_FINAL")
         set(file_content "${file_content}
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Reply via email to