From a60027a642f887179513496ef61552db44829652 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 12 Jan 2015 21:43:48 +0100 Subject: [PATCH 01/13] Features: Ensure appropriate return value from feature test macros. GNU-CXX already has complex logic and sets the _result to 0 before tests which may set it to something else. Change the other modules to be consistent with that. --- Modules/Compiler/AppleClang-C.cmake | 3 +-- Modules/Compiler/AppleClang-CXX.cmake | 3 +-- Modules/Compiler/Clang-C.cmake | 3 +-- Modules/Compiler/Clang-CXX.cmake | 3 +-- Modules/Compiler/GNU-C.cmake | 3 +-- Modules/Compiler/GNU-CXX.cmake | 2 -- 6 files changed, 5 insertions(+), 12 deletions(-) diff --git a/Modules/Compiler/AppleClang-C.cmake b/Modules/Compiler/AppleClang-C.cmake index 06657455d9..16f420fe93 100644 --- a/Modules/Compiler/AppleClang-C.cmake +++ b/Modules/Compiler/AppleClang-C.cmake @@ -19,6 +19,7 @@ macro(cmake_record_c_compile_features) record_compiler_features(C "${std_version}" ${list}) endmacro() + set(_result 0) if (UNIX AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.0) _get_appleclang_features(${CMAKE_C11_STANDARD_COMPILE_OPTION} CMAKE_C11_COMPILE_FEATURES) if (_result EQUAL 0) @@ -27,7 +28,5 @@ macro(cmake_record_c_compile_features) if (_result EQUAL 0) _get_appleclang_features(${CMAKE_C90_STANDARD_COMPILE_OPTION} CMAKE_C90_COMPILE_FEATURES) endif() - else() - set(_result 0) endif() endmacro() diff --git a/Modules/Compiler/AppleClang-CXX.cmake b/Modules/Compiler/AppleClang-CXX.cmake index a5086230ed..978c382e2e 100644 --- a/Modules/Compiler/AppleClang-CXX.cmake +++ b/Modules/Compiler/AppleClang-CXX.cmake @@ -26,6 +26,7 @@ macro(cmake_record_cxx_compile_features) record_compiler_features(CXX "${std_version}" ${list}) endmacro() + set(_result 0) if (UNIX AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.0) set(_result 0) if(CMAKE_CXX14_STANDARD_COMPILE_OPTION) @@ -37,7 +38,5 @@ macro(cmake_record_cxx_compile_features) if (_result EQUAL 0) _get_appleclang_features(${CMAKE_CXX98_STANDARD_COMPILE_OPTION} CMAKE_CXX98_COMPILE_FEATURES) endif() - else() - set(_result 0) endif() endmacro() diff --git a/Modules/Compiler/Clang-C.cmake b/Modules/Compiler/Clang-C.cmake index ebd5c43123..548d0a5960 100644 --- a/Modules/Compiler/Clang-C.cmake +++ b/Modules/Compiler/Clang-C.cmake @@ -28,6 +28,7 @@ macro(cmake_record_c_compile_features) record_compiler_features(C "${std_version}" ${list}) endmacro() + set(_result 0) if (UNIX AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4) _get_clang_features(${CMAKE_C11_STANDARD_COMPILE_OPTION} CMAKE_C11_COMPILE_FEATURES) if (_result EQUAL 0) @@ -36,7 +37,5 @@ macro(cmake_record_c_compile_features) if (_result EQUAL 0) _get_clang_features(${CMAKE_C90_STANDARD_COMPILE_OPTION} CMAKE_C90_COMPILE_FEATURES) endif() - else() - set(_result 0) endif() endmacro() diff --git a/Modules/Compiler/Clang-CXX.cmake b/Modules/Compiler/Clang-CXX.cmake index 6fe0b56782..e07eacee38 100644 --- a/Modules/Compiler/Clang-CXX.cmake +++ b/Modules/Compiler/Clang-CXX.cmake @@ -38,6 +38,7 @@ macro(cmake_record_cxx_compile_features) record_compiler_features(CXX "${std_version}" ${list}) endmacro() + set(_result 0) if (UNIX AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4) _get_clang_features(${CMAKE_CXX14_STANDARD_COMPILE_OPTION} CMAKE_CXX14_COMPILE_FEATURES) if (_result EQUAL 0) @@ -46,7 +47,5 @@ macro(cmake_record_cxx_compile_features) if (_result EQUAL 0) _get_clang_features(${CMAKE_CXX98_STANDARD_COMPILE_OPTION} CMAKE_CXX98_COMPILE_FEATURES) endif() - else() - set(_result 0) endif() endmacro() diff --git a/Modules/Compiler/GNU-C.cmake b/Modules/Compiler/GNU-C.cmake index db9089de28..3404d225ff 100644 --- a/Modules/Compiler/GNU-C.cmake +++ b/Modules/Compiler/GNU-C.cmake @@ -23,6 +23,7 @@ macro(cmake_record_c_compile_features) record_compiler_features(C "${std_version}" ${list}) endmacro() + set(_result 0) if (UNIX AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7) _get_gcc_features(${CMAKE_C11_STANDARD_COMPILE_OPTION} CMAKE_C11_COMPILE_FEATURES) if (_result EQUAL 0) @@ -31,7 +32,5 @@ macro(cmake_record_c_compile_features) if (_result EQUAL 0) _get_gcc_features(${CMAKE_C90_STANDARD_COMPILE_OPTION} CMAKE_C90_COMPILE_FEATURES) endif() - else() - set(_result 0) endif() endmacro() diff --git a/Modules/Compiler/GNU-CXX.cmake b/Modules/Compiler/GNU-CXX.cmake index 4a26963d9f..6ade85a1fd 100644 --- a/Modules/Compiler/GNU-CXX.cmake +++ b/Modules/Compiler/GNU-CXX.cmake @@ -49,7 +49,5 @@ macro(cmake_record_cxx_compile_features) if (_result EQUAL 0) _get_gcc_features(${CMAKE_CXX98_STANDARD_COMPILE_OPTION} CMAKE_CXX98_COMPILE_FEATURES) endif() - else() - set(_result 0) endif() endmacro() From 1f4649e62f6394a6e9af67486e4c41f3e286de47 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 9 Jan 2015 20:18:24 +0100 Subject: [PATCH 02/13] Features: Update the default_dialect test for old GNU-like compilers. Prior to GNU 4.7, GNU defined __cplusplus incorrectly, and defined __GXX_EXPERIMENTAL_CXX0X__ in C++11 mode. --- Tests/CompileFeatures/default_dialect.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/CompileFeatures/default_dialect.cpp b/Tests/CompileFeatures/default_dialect.cpp index 8d97926fec..a2ca268a40 100644 --- a/Tests/CompileFeatures/default_dialect.cpp +++ b/Tests/CompileFeatures/default_dialect.cpp @@ -14,7 +14,7 @@ Outputter<__cplusplus> o; # if !DEFAULT_CXX98 # error Buildsystem error # endif -# if __cplusplus != 199711L +# if __cplusplus != 199711L && __cplusplus != 1 && !defined(__GXX_EXPERIMENTAL_CXX0X__) Outputter<__cplusplus> o; # endif #endif From 1532b9214f79517fe74dc674939601c75f4af300 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 11 Jan 2015 15:55:09 +0100 Subject: [PATCH 03/13] Features: Make cxx_noexcept available from GNU 4.6. As listed in the reference document. --- Modules/Compiler/GNU-CXX-FeatureTests.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index 6de06dd6b6..03b53e1444 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -46,7 +46,6 @@ set(_cmake_feature_test_cxx_alias_templates "${GNU47_CXX11}") set(_cmake_feature_test_cxx_delegating_constructors "${GNU47_CXX11}") set(_cmake_feature_test_cxx_extended_friend_declarations "${GNU47_CXX11}") set(_cmake_feature_test_cxx_final "${GNU47_CXX11}") -set(_cmake_feature_test_cxx_noexcept "${GNU47_CXX11}") set(_cmake_feature_test_cxx_nonstatic_member_init "${GNU47_CXX11}") set(_cmake_feature_test_cxx_override "${GNU47_CXX11}") set(_cmake_feature_test_cxx_user_literals "${GNU47_CXX11}") @@ -60,6 +59,7 @@ set(GNU46_CXX11 "${_cmake_oldestSupported} && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_constexpr "${GNU46_CXX11}") set(_cmake_feature_test_cxx_defaulted_move_initializers "${GNU46_CXX11}") set(_cmake_feature_test_cxx_enum_forward_declarations "${GNU46_CXX11}") +set(_cmake_feature_test_cxx_noexcept "${GNU46_CXX11}") set(_cmake_feature_test_cxx_nullptr "${GNU46_CXX11}") set(_cmake_feature_test_cxx_range_for "${GNU46_CXX11}") set(_cmake_feature_test_cxx_unrestricted_unions "${GNU46_CXX11}") From bfc995cc3b8834281ee86ea2ed248b041d5ad1be Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 11 Jan 2015 16:14:26 +0100 Subject: [PATCH 04/13] Features: Remove wrong content from else() condition. As this is not elseif(), the content has no effect. Rather than changing it to an elseif(), remove the conditional content. All versions of GNU prior to 5.0 default to C90/89. Clang-C.cmake has a similar code block which correctly uses elseif() for setting the default C dialect to C99. That may have been updated from a C90 default at some point, so leave the version condition there in place for now. --- Modules/Compiler/GNU-C.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Compiler/GNU-C.cmake b/Modules/Compiler/GNU-C.cmake index 3404d225ff..8b4788030c 100644 --- a/Modules/Compiler/GNU-C.cmake +++ b/Modules/Compiler/GNU-C.cmake @@ -14,7 +14,7 @@ endif() if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0) set(CMAKE_C_STANDARD_DEFAULT 11) -else(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7) +else() set(CMAKE_C_STANDARD_DEFAULT 90) endif() From 6e909035af73d3ee0ca3e5adef39b4541f0c8be9 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 11 Jan 2015 16:09:50 +0100 Subject: [PATCH 05/13] Features: Record C/CXX dialect flags for GNU 4.6. This release was prior to standardization of C11/CXX11. --- Modules/Compiler/GNU-C.cmake | 7 ++++++- Modules/Compiler/GNU-CXX.cmake | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Modules/Compiler/GNU-C.cmake b/Modules/Compiler/GNU-C.cmake index 8b4788030c..8faf4e45cd 100644 --- a/Modules/Compiler/GNU-C.cmake +++ b/Modules/Compiler/GNU-C.cmake @@ -1,15 +1,20 @@ include(Compiler/GNU) __compiler_gnu(C) -if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7) +if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.6) set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c90") set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu90") set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99") set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=gnu99") +endif() +if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7) set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11") set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11") +elseif (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.6) + set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c1x") + set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu1x") endif() if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0) diff --git a/Modules/Compiler/GNU-CXX.cmake b/Modules/Compiler/GNU-CXX.cmake index 6ade85a1fd..c03cc4b18a 100644 --- a/Modules/Compiler/GNU-CXX.cmake +++ b/Modules/Compiler/GNU-CXX.cmake @@ -11,7 +11,7 @@ else() endif() endif() -if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7) +if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.6) # Supported since 4.3 set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98") set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98") @@ -20,7 +20,10 @@ 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.6) # 4.3 supports 0x variants + 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 4.9) From 222ec86f7d9ae838d2e460b89985c797c7c90373 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 11 Jan 2015 16:20:03 +0100 Subject: [PATCH 06/13] Features: Test an old value of __STDC_VERSION__ for GNU < 4.7 compatibility. --- Modules/Compiler/GNU-C-FeatureTests.cmake | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Modules/Compiler/GNU-C-FeatureTests.cmake b/Modules/Compiler/GNU-C-FeatureTests.cmake index dfaeebf05d..ddac0e830a 100644 --- a/Modules/Compiler/GNU-C-FeatureTests.cmake +++ b/Modules/Compiler/GNU-C-FeatureTests.cmake @@ -1,7 +1,12 @@ set(_cmake_oldestSupported "(__GNUC__ * 100 + __GNUC_MINOR__) >= 407") -set(GNU46_C11 "${_cmake_oldestSupported} && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L") +# GNU 4.7 correctly sets __STDC_VERSION__ to 201112L, but GNU 4.6 sets it +# to 201000L. As the former is strictly greater than the latter, test only +# for the latter. If in the future CMake learns about a C feature which was +# introduced with GNU 4.7, that should test for the correct version, similar +# to the distinction between __cplusplus and __GXX_EXPERIMENTAL_CXX0X__ tests. +set(GNU46_C11 "${_cmake_oldestSupported} && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201000L") set(_cmake_feature_test_c_static_assert "${GNU46_C11}") # Since 4.4 at least: set(GNU44_C99 "${_cmake_oldestSupported} && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L") From 462c630b8a6d832dd37562fcd7b00a75e1ec6e82 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 11 Jan 2015 16:23:34 +0100 Subject: [PATCH 07/13] Features: Don't test __cplusplus value for CXX98 on GNU. The macro is defined to 1 for GNU 4.6, and such a test is only useful for features in language dialects newer than the default (CXX98 for GNU currently). Test only that it has a truthy value. --- Modules/Compiler/GNU-CXX-FeatureTests.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index 03b53e1444..8f812da880 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -102,4 +102,4 @@ set(_cmake_feature_test_cxx_extern_templates "${_cmake_oldestSupported} && __cpl # TODO: Should be supported forever? set(_cmake_feature_test_cxx_func_identifier "${_cmake_oldestSupported} && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_variadic_macros "${_cmake_oldestSupported} && __cplusplus >= 201103L") -set(_cmake_feature_test_cxx_template_template_parameters "${_cmake_oldestSupported} && __cplusplus >= 199711L") +set(_cmake_feature_test_cxx_template_template_parameters "${_cmake_oldestSupported} && __cplusplus") From 938bd94eb0b34e1b5be12dcceaab641efc8a7e43 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 11 Jan 2015 16:22:24 +0100 Subject: [PATCH 08/13] Features: Test __GXX_EXPERIMENTAL_CXX0X__ macro for GNU < 4.7 compatibility. --- Modules/Compiler/GNU-CXX-FeatureTests.cmake | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index 8f812da880..3c6c663e98 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -54,8 +54,13 @@ set(_cmake_feature_test_cxx_user_literals "${GNU47_CXX11}") # support -std=c++11. Prior to that, support for C++11 features is technically # experiemental and possibly incomplete (see for example the note below about # cxx_variadic_template_template_parameters) +# GNU does not define __cplusplus correctly before version 4.7. +# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=1773 +# __GXX_EXPERIMENTAL_CXX0X__ is defined in prior versions, but may not be +# defined in the future. +set(GNU_CXX0X_DEFINED "(__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__))") # TODO: Should be supported by GNU 4.6 -set(GNU46_CXX11 "${_cmake_oldestSupported} && __cplusplus >= 201103L") +set(GNU46_CXX11 "${_cmake_oldestSupported} && ${GNU_CXX0X_DEFINED}") set(_cmake_feature_test_cxx_constexpr "${GNU46_CXX11}") set(_cmake_feature_test_cxx_defaulted_move_initializers "${GNU46_CXX11}") set(_cmake_feature_test_cxx_enum_forward_declarations "${GNU46_CXX11}") @@ -64,13 +69,13 @@ set(_cmake_feature_test_cxx_nullptr "${GNU46_CXX11}") set(_cmake_feature_test_cxx_range_for "${GNU46_CXX11}") set(_cmake_feature_test_cxx_unrestricted_unions "${GNU46_CXX11}") # TODO: Should be supported by GNU 4.5 -set(GNU45_CXX11 "${_cmake_oldestSupported} && __cplusplus >= 201103L") +set(GNU45_CXX11 "${_cmake_oldestSupported} && ${GNU_CXX0X_DEFINED}") set(_cmake_feature_test_cxx_explicit_conversions "${GNU45_CXX11}") set(_cmake_feature_test_cxx_lambdas "${GNU45_CXX11}") set(_cmake_feature_test_cxx_local_type_template_args "${GNU45_CXX11}") set(_cmake_feature_test_cxx_raw_string_literals "${GNU45_CXX11}") # TODO: Should be supported by GNU 4.4 -set(GNU44_CXX11 "${_cmake_oldestSupported} && __cplusplus >= 201103L") +set(GNU44_CXX11 "${_cmake_oldestSupported} && ${GNU_CXX0X_DEFINED}") set(_cmake_feature_test_cxx_auto_type "${GNU44_CXX11}") set(_cmake_feature_test_cxx_defaulted_functions "${GNU44_CXX11}") set(_cmake_feature_test_cxx_deleted_functions "${GNU44_CXX11}") @@ -90,7 +95,7 @@ set(_cmake_feature_test_cxx_variadic_templates "${GNU44_CXX11}") # templates capability in CMake. See # http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2555.pdf # TODO: Should be supported by GNU 4.3 -set(GNU43_CXX11 "${_cmake_oldestSupported} && __cplusplus >= 201103L") +set(GNU43_CXX11 "${_cmake_oldestSupported} && ${GNU_CXX0X_DEFINED}") set(_cmake_feature_test_cxx_decltype "${GNU43_CXX11}") set(_cmake_feature_test_cxx_default_function_template_args "${GNU43_CXX11}") set(_cmake_feature_test_cxx_long_long_type "${GNU43_CXX11}") @@ -98,8 +103,8 @@ set(_cmake_feature_test_cxx_right_angle_brackets "${GNU43_CXX11}") set(_cmake_feature_test_cxx_rvalue_references "${GNU43_CXX11}") set(_cmake_feature_test_cxx_static_assert "${GNU43_CXX11}") # TODO: Should be supported since GNU 3.4? -set(_cmake_feature_test_cxx_extern_templates "${_cmake_oldestSupported} && __cplusplus >= 201103L") +set(_cmake_feature_test_cxx_extern_templates "${_cmake_oldestSupported} && ${GNU_CXX0X_DEFINED}") # TODO: Should be supported forever? -set(_cmake_feature_test_cxx_func_identifier "${_cmake_oldestSupported} && __cplusplus >= 201103L") -set(_cmake_feature_test_cxx_variadic_macros "${_cmake_oldestSupported} && __cplusplus >= 201103L") +set(_cmake_feature_test_cxx_func_identifier "${_cmake_oldestSupported} && ${GNU_CXX0X_DEFINED}") +set(_cmake_feature_test_cxx_variadic_macros "${_cmake_oldestSupported} && ${GNU_CXX0X_DEFINED}") set(_cmake_feature_test_cxx_template_template_parameters "${_cmake_oldestSupported} && __cplusplus") From 0798d1e5b0a09564b127ae7d26d8c1ea1bc9adad Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 11 Jan 2015 18:43:31 +0100 Subject: [PATCH 09/13] Features: Extend the generalized_initializers test for GNU < 4.7. That compiler requires a different initializer_list constructor, so update the test to match. --- Tests/CompileFeatures/cxx_generalized_initializers.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Tests/CompileFeatures/cxx_generalized_initializers.cpp b/Tests/CompileFeatures/cxx_generalized_initializers.cpp index 8013ef5c2d..7bf356b63d 100644 --- a/Tests/CompileFeatures/cxx_generalized_initializers.cpp +++ b/Tests/CompileFeatures/cxx_generalized_initializers.cpp @@ -8,6 +8,7 @@ namespace std { const _E* __begin_; size_t __size_; + initializer_list(const int*, long unsigned int) {} }; } From 1f19ac4da5af812891be305721f3e3b7eed62cc3 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 11 Jan 2015 18:44:49 +0100 Subject: [PATCH 10/13] Features: Adjust cxx_variadic_templates unit test for GNU < 4.7. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The unit test for this fails with GNU 4.6: Building CXX object CMakeFiles/test_cxx_variadic_templates.dir/cxx_variadic_templates.cpp.o CompileFeatures/cxx_variadic_templates.cpp: In static member function ‘static int Interface::accumulate()’: CompileFeatures/cxx_variadic_templates.cpp:18:31: sorry, unimplemented: cannot expand ‘Is ...’ into a fixed-length argument list CMakeFiles/test_cxx_variadic_templates.dir/build.make:54: recipe for target 'CMakeFiles/test_cxx_variadic_templates.dir/cxx_variadic_templates.cpp.o' failed The workaround is to use a specialization: http://stackoverflow.com/questions/1989552 http://stackoverflow.com/questions/11297376 --- Tests/CompileFeatures/cxx_variadic_templates.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/CompileFeatures/cxx_variadic_templates.cpp b/Tests/CompileFeatures/cxx_variadic_templates.cpp index 1d5a7061b6..a80e157e6d 100644 --- a/Tests/CompileFeatures/cxx_variadic_templates.cpp +++ b/Tests/CompileFeatures/cxx_variadic_templates.cpp @@ -1,4 +1,4 @@ -template +template struct Interface; template @@ -11,7 +11,7 @@ struct Interface }; template -struct Interface +struct Interface { static int accumulate() { From f13a2eb118d8b152a897e09fdcf43793f8e1bcca Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 15 Jan 2015 23:53:23 +0100 Subject: [PATCH 11/13] Features: Adjust the RunCMake test to use more-common features. --- .../CompileFeatures/LinkImplementationFeatureCycle.cmake | 6 +++--- .../LinkImplementationFeatureCycleSolved.cmake | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycle.cmake b/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycle.cmake index 9d56bc0982..d2c95ec126 100644 --- a/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycle.cmake +++ b/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycle.cmake @@ -3,12 +3,12 @@ add_library(empty1 empty.cpp) add_library(empty2 INTERFACE) add_library(empty3 INTERFACE) -target_compile_features(empty3 INTERFACE cxx_constexpr) +target_compile_features(empty3 INTERFACE cxx_static_assert) target_link_libraries(empty1 - # When starting, $ is '0', so 'freeze' the + # When starting, $ is '0', so 'freeze' the # CXX_STANDARD at 98 during computation. - $<$:empty2> + $<$:empty2> # This would add cxx_constexpr, 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 0df548b7ef..bbcf4e00a2 100644 --- a/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycleSolved.cmake +++ b/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycleSolved.cmake @@ -3,12 +3,12 @@ add_library(empty1 empty.cpp) add_library(empty2 INTERFACE) add_library(empty3 INTERFACE) -target_compile_features(empty3 INTERFACE cxx_constexpr) +target_compile_features(empty3 INTERFACE cxx_static_assert) target_link_libraries(empty1 - $<$:empty2> + $<$:empty2> empty3 ) # This, or populating the COMPILE_FEATURES property with a feature in the -# same standard as cxx_final, solves the cycle above. +# same standard as cxx_nullptr, solves the cycle above. set_property(TARGET empty1 PROPERTY CXX_STANDARD 11) From b15c008fac22720ccd793b18c235046bc84ecc86 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 10 Jan 2015 20:05:54 +0100 Subject: [PATCH 12/13] Features: Record for GNU 4.6. Adjust the CompileFeatures genex_test for the expectation of the OVERRIDE_CONTROL feature group. --- Modules/Compiler/GNU-C-FeatureTests.cmake | 4 ++-- Modules/Compiler/GNU-C.cmake | 2 +- Modules/Compiler/GNU-CXX-FeatureTests.cmake | 4 ++-- Modules/Compiler/GNU-CXX.cmake | 2 +- Tests/CompileFeatures/CMakeLists.txt | 8 ++++++-- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Modules/Compiler/GNU-C-FeatureTests.cmake b/Modules/Compiler/GNU-C-FeatureTests.cmake index ddac0e830a..7e840aa43a 100644 --- a/Modules/Compiler/GNU-C-FeatureTests.cmake +++ b/Modules/Compiler/GNU-C-FeatureTests.cmake @@ -1,12 +1,12 @@ -set(_cmake_oldestSupported "(__GNUC__ * 100 + __GNUC_MINOR__) >= 407") +set(_cmake_oldestSupported "(__GNUC__ * 100 + __GNUC_MINOR__) >= 406") # GNU 4.7 correctly sets __STDC_VERSION__ to 201112L, but GNU 4.6 sets it # to 201000L. As the former is strictly greater than the latter, test only # for the latter. If in the future CMake learns about a C feature which was # introduced with GNU 4.7, that should test for the correct version, similar # to the distinction between __cplusplus and __GXX_EXPERIMENTAL_CXX0X__ tests. -set(GNU46_C11 "${_cmake_oldestSupported} && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201000L") +set(GNU46_C11 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201000L") set(_cmake_feature_test_c_static_assert "${GNU46_C11}") # Since 4.4 at least: set(GNU44_C99 "${_cmake_oldestSupported} && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L") diff --git a/Modules/Compiler/GNU-C.cmake b/Modules/Compiler/GNU-C.cmake index 8faf4e45cd..d5e747da40 100644 --- a/Modules/Compiler/GNU-C.cmake +++ b/Modules/Compiler/GNU-C.cmake @@ -29,7 +29,7 @@ macro(cmake_record_c_compile_features) endmacro() set(_result 0) - if (UNIX AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7) + if (UNIX AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.6) _get_gcc_features(${CMAKE_C11_STANDARD_COMPILE_OPTION} CMAKE_C11_COMPILE_FEATURES) if (_result EQUAL 0) _get_gcc_features(${CMAKE_C99_STANDARD_COMPILE_OPTION} CMAKE_C99_COMPILE_FEATURES) diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index 3c6c663e98..267d65875a 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -2,7 +2,7 @@ # Reference: http://gcc.gnu.org/projects/cxx0x.html # http://gcc.gnu.org/projects/cxx1y.html -set(_cmake_oldestSupported "(__GNUC__ * 100 + __GNUC_MINOR__) >= 407") +set(_cmake_oldestSupported "(__GNUC__ * 100 + __GNUC_MINOR__) >= 406") set(GNU50_CXX14 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 500 && __cplusplus >= 201402L") set(_cmake_feature_test_cxx_variable_templates "${GNU50_CXX14}") @@ -60,7 +60,7 @@ set(_cmake_feature_test_cxx_user_literals "${GNU47_CXX11}") # defined in the future. set(GNU_CXX0X_DEFINED "(__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__))") # TODO: Should be supported by GNU 4.6 -set(GNU46_CXX11 "${_cmake_oldestSupported} && ${GNU_CXX0X_DEFINED}") +set(GNU46_CXX11 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && ${GNU_CXX0X_DEFINED}") set(_cmake_feature_test_cxx_constexpr "${GNU46_CXX11}") set(_cmake_feature_test_cxx_defaulted_move_initializers "${GNU46_CXX11}") set(_cmake_feature_test_cxx_enum_forward_declarations "${GNU46_CXX11}") diff --git a/Modules/Compiler/GNU-CXX.cmake b/Modules/Compiler/GNU-CXX.cmake index c03cc4b18a..eeada868d5 100644 --- a/Modules/Compiler/GNU-CXX.cmake +++ b/Modules/Compiler/GNU-CXX.cmake @@ -45,7 +45,7 @@ macro(cmake_record_cxx_compile_features) if (UNIX AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8) _get_gcc_features(${CMAKE_CXX14_STANDARD_COMPILE_OPTION} CMAKE_CXX14_COMPILE_FEATURES) endif() - if (UNIX AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7) + if (UNIX AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.6) if (_result EQUAL 0) _get_gcc_features(${CMAKE_CXX11_STANDARD_COMPILE_OPTION} CMAKE_CXX11_COMPILE_FEATURES) endif() diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt index 5ca1eb7660..106f29c0cb 100644 --- a/Tests/CompileFeatures/CMakeLists.txt +++ b/Tests/CompileFeatures/CMakeLists.txt @@ -142,23 +142,24 @@ if (CMAKE_CXX_COMPILE_FEATURES) add_executable(IfaceCompileFeatures main.cpp) target_link_libraries(IfaceCompileFeatures iface) - add_definitions(-DEXPECT_OVERRIDE_CONTROL=1) - if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8) add_definitions( + -DEXPECT_OVERRIDE_CONTROL=1 -DEXPECT_INHERITING_CONSTRUCTORS=1 -DEXPECT_FINAL=1 -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=1 ) elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7) add_definitions( + -DEXPECT_OVERRIDE_CONTROL=1 -DEXPECT_INHERITING_CONSTRUCTORS=0 -DEXPECT_FINAL=1 -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=0 ) else() add_definitions( + -DEXPECT_OVERRIDE_CONTROL=0 -DEXPECT_INHERITING_CONSTRUCTORS=0 -DEXPECT_FINAL=0 -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=0 @@ -166,6 +167,7 @@ if (CMAKE_CXX_COMPILE_FEATURES) endif() elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") add_definitions( + -DEXPECT_OVERRIDE_CONTROL=1 -DEXPECT_INHERITING_CONSTRUCTORS=1 -DEXPECT_FINAL=1 -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=1 @@ -173,12 +175,14 @@ if (CMAKE_CXX_COMPILE_FEATURES) elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) add_definitions( + -DEXPECT_OVERRIDE_CONTROL=1 -DEXPECT_INHERITING_CONSTRUCTORS=1 -DEXPECT_FINAL=1 -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=1 ) else() add_definitions( + -DEXPECT_OVERRIDE_CONTROL=1 -DEXPECT_INHERITING_CONSTRUCTORS=0 -DEXPECT_FINAL=1 -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=0 From 770ba876997d1038acdc1d54419152abd0970312 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 16 Jan 2015 10:54:27 -0500 Subject: [PATCH 13/13] Help: Add notes for topic 'GNU-4.6-compile-features' --- Help/release/dev/GNU-4.6-compile-features.rst | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 Help/release/dev/GNU-4.6-compile-features.rst diff --git a/Help/release/dev/GNU-4.6-compile-features.rst b/Help/release/dev/GNU-4.6-compile-features.rst new file mode 100644 index 0000000000..059a075cb5 --- /dev/null +++ b/Help/release/dev/GNU-4.6-compile-features.rst @@ -0,0 +1,5 @@ +GNU-4.6-compile-features +------------------------ + +* The :manual:`Compile Features ` functionality + is now aware of features supported by GNU 4.6 compilers.