diff options
author | Stephen Kelly <steveire@gmail.com> | 2014-05-05 22:21:14 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2014-05-22 16:01:23 (GMT) |
commit | dd043c3f21fbfab17d7f400bd2bc9f927215b18e (patch) | |
tree | 73f942d1294819f457309e1ccb507a057901a180 /Modules | |
parent | 3ea9bde8450a28b58730230e9e73e4b8d439f701 (diff) | |
download | CMake-dd043c3f21fbfab17d7f400bd2bc9f927215b18e.zip CMake-dd043c3f21fbfab17d7f400bd2bc9f927215b18e.tar.gz CMake-dd043c3f21fbfab17d7f400bd2bc9f927215b18e.tar.bz2 |
Features: Add support for C++14 features.
Record the features implemented by GNU 4.9 and Clang 3.4.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/CMakeCXXCompiler.cmake.in | 1 | ||||
-rw-r--r-- | Modules/CMakeDetermineCompileFeatures.cmake | 8 | ||||
-rw-r--r-- | Modules/Compiler/Clang-CXX-FeatureTests.cmake | 17 | ||||
-rw-r--r-- | Modules/Compiler/GNU-CXX-FeatureTests.cmake | 20 | ||||
-rw-r--r-- | Modules/Compiler/GNU-CXX.cmake | 13 |
5 files changed, 57 insertions, 2 deletions
diff --git a/Modules/CMakeCXXCompiler.cmake.in b/Modules/CMakeCXXCompiler.cmake.in index 6e531ca..af79a31 100644 --- a/Modules/CMakeCXXCompiler.cmake.in +++ b/Modules/CMakeCXXCompiler.cmake.in @@ -5,6 +5,7 @@ set(CMAKE_CXX_COMPILER_VERSION "@CMAKE_CXX_COMPILER_VERSION@") set(CMAKE_CXX_COMPILE_FEATURES "@CMAKE_CXX_COMPILE_FEATURES@") set(CMAKE_CXX98_COMPILE_FEATURES "@CMAKE_CXX98_COMPILE_FEATURES@") set(CMAKE_CXX11_COMPILE_FEATURES "@CMAKE_CXX11_COMPILE_FEATURES@") +set(CMAKE_CXX14_COMPILE_FEATURES "@CMAKE_CXX14_COMPILE_FEATURES@") set(CMAKE_CXX_PLATFORM_ID "@CMAKE_CXX_PLATFORM_ID@") set(CMAKE_CXX_SIMULATE_ID "@CMAKE_CXX_SIMULATE_ID@") diff --git a/Modules/CMakeDetermineCompileFeatures.cmake b/Modules/CMakeDetermineCompileFeatures.cmake index da68e94..2bb7a74 100644 --- a/Modules/CMakeDetermineCompileFeatures.cmake +++ b/Modules/CMakeDetermineCompileFeatures.cmake @@ -57,6 +57,7 @@ function(cmake_determine_compile_features lang) set(CMAKE_CXX98_COMPILE_FEATURES) set(CMAKE_CXX11_COMPILE_FEATURES) + set(CMAKE_CXX14_COMPILE_FEATURES) include("${CMAKE_ROOT}/Modules/Internal/FeatureTesting.cmake") @@ -67,7 +68,10 @@ function(cmake_determine_compile_features lang) return() endif() - if (CMAKE_CXX11_COMPILE_FEATURES AND CMAKE_CXX98_COMPILE_FEATURES) + if (CMAKE_CXX11_COMPILE_FEATURES AND CMAKE_CXX14_COMPILE_FEATURES) + list(REMOVE_ITEM CMAKE_CXX14_COMPILE_FEATURES ${CMAKE_CXX11_COMPILE_FEATURES}) + endif() + if (CMAKE_CXX98_COMPILE_FEATURES AND CMAKE_CXX11_COMPILE_FEATURES) list(REMOVE_ITEM CMAKE_CXX11_COMPILE_FEATURES ${CMAKE_CXX98_COMPILE_FEATURES}) endif() @@ -75,12 +79,14 @@ function(cmake_determine_compile_features lang) set(CMAKE_CXX_COMPILE_FEATURES ${CMAKE_CXX98_COMPILE_FEATURES} ${CMAKE_CXX11_COMPILE_FEATURES} + ${CMAKE_CXX14_COMPILE_FEATURES} ) endif() set(CMAKE_CXX_COMPILE_FEATURES ${CMAKE_CXX_COMPILE_FEATURES} PARENT_SCOPE) set(CMAKE_CXX98_COMPILE_FEATURES ${CMAKE_CXX98_COMPILE_FEATURES} PARENT_SCOPE) set(CMAKE_CXX11_COMPILE_FEATURES ${CMAKE_CXX11_COMPILE_FEATURES} PARENT_SCOPE) + set(CMAKE_CXX14_COMPILE_FEATURES ${CMAKE_CXX14_COMPILE_FEATURES} PARENT_SCOPE) message(STATUS "Detecting ${lang} compile features - done") endif() diff --git a/Modules/Compiler/Clang-CXX-FeatureTests.cmake b/Modules/Compiler/Clang-CXX-FeatureTests.cmake index c4092c4..4c532fb 100644 --- a/Modules/Compiler/Clang-CXX-FeatureTests.cmake +++ b/Modules/Compiler/Clang-CXX-FeatureTests.cmake @@ -7,7 +7,9 @@ set(testable_features cxx_alignas cxx_attributes cxx_auto_type + cxx_binary_literals cxx_constexpr + cxx_contextual_conversions cxx_decltype cxx_decltype_incomplete_return_types cxx_default_function_template_args @@ -25,6 +27,8 @@ set(testable_features cxx_range_for cxx_raw_string_literals cxx_reference_qualified_functions + cxx_relaxed_constexpr + cxx_return_type_deduction cxx_rvalue_references cxx_static_assert cxx_strong_enums @@ -32,6 +36,7 @@ set(testable_features cxx_unicode_literals cxx_unrestricted_unions cxx_user_literals + cxx_variable_templates cxx_variadic_templates ) @@ -43,12 +48,24 @@ endforeach() unset(testable_features) +set(_cmake_feature_test_cxx_aggregate_default_initializers "${_cmake_oldestSupported} && __has_feature(cxx_aggregate_nsdmi)") + set(_cmake_feature_test_cxx_trailing_return_types "${_cmake_oldestSupported} && __has_feature(cxx_trailing_return)") set(_cmake_feature_test_cxx_alignof "${_cmake_oldestSupported} && __has_feature(cxx_alignas)") set(_cmake_feature_test_cxx_final "${_cmake_oldestSupported} && __has_feature(cxx_override_control)") set(_cmake_feature_test_cxx_override "${_cmake_oldestSupported} && __has_feature(cxx_override_control)") set(_cmake_feature_test_cxx_uniform_initialization "${_cmake_oldestSupported} && __has_feature(cxx_generalized_initializers)") set(_cmake_feature_test_cxx_defaulted_move_initializers "${_cmake_oldestSupported} && __has_feature(cxx_defaulted_functions)") +set(_cmake_feature_test_cxx_lambda_init_captures "${_cmake_oldestSupported} && __has_feature(cxx_init_captures)") + +set(Clang34_CXX14 "((__clang_major__ * 100) + __clang_minor__) >= 304 && __cplusplus > 201103L") +# http://llvm.org/bugs/show_bug.cgi?id=19242 +set(_cmake_feature_test_cxx_attribute_deprecated "${Clang34_CXX14}") +# http://llvm.org/bugs/show_bug.cgi?id=19698 +set(_cmake_feature_test_cxx_decltype_auto "${Clang34_CXX14}") +set(_cmake_feature_test_cxx_digit_separators "${Clang34_CXX14}") +# http://llvm.org/bugs/show_bug.cgi?id=19674 +set(_cmake_feature_test_cxx_generic_lambdas "${Clang34_CXX14}") # TODO: Should be supported by Clang 3.1 set(Clang31_CXX11 "${_cmake_oldestSupported} && __cplusplus >= 201103L") diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index c65c22c..9c98e44 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -2,6 +2,26 @@ # Reference: http://gcc.gnu.org/projects/cxx0x.html set(_cmake_oldestSupported "(__GNUC__ * 100 + __GNUC_MINOR__) >= 407") + +set(GNU49_CXX14 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 409 && __cplusplus > 201103L") +set(_cmake_feature_test_cxx_contextual_conversions "${GNU49_CXX14}") +set(_cmake_feature_test_cxx_attribute_deprecated "${GNU49_CXX14}") +set(_cmake_feature_test_cxx_decltype_auto "${GNU49_CXX14}") +set(_cmake_feature_test_cxx_digit_separators "${GNU49_CXX14}") +set(_cmake_feature_test_cxx_generic_lambdas "${GNU49_CXX14}") +set(_cmake_feature_test_cxx_lambda_init_captures "${GNU49_CXX14}") +# GNU 4.3 supports binary literals as an extension, but may warn about +# use of extensions prior to GNU 4.9 +# http://stackoverflow.com/questions/16334024/difference-between-gcc-binary-literals-and-c14-ones +set(_cmake_feature_test_cxx_binary_literals "${GNU49_CXX14}") +# The feature below is documented as available in GNU 4.8 (by implementing an +# earlier draft of the standard paper), but that version of the compiler +# does not set __cplusplus to a value greater than 201103L until GNU 4.9: +# http://gcc.gnu.org/onlinedocs/gcc-4.8.2/cpp/Standard-Predefined-Macros.html#Standard-Predefined-Macros +# http://gcc.gnu.org/onlinedocs/gcc-4.9.0/cpp/Standard-Predefined-Macros.html#Standard-Predefined-Macros +# So, CMake only reports availability for it with GNU 4.9 or later. +set(_cmake_feature_test_cxx_return_type_deduction "${GNU49_CXX14}") + # Introduced in GCC 4.8.1 set(GNU481_CXX11 "((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40801) && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_decltype_incomplete_return_types "${GNU481_CXX11}") diff --git a/Modules/Compiler/GNU-CXX.cmake b/Modules/Compiler/GNU-CXX.cmake index 1ecdad2..14dc76a 100644 --- a/Modules/Compiler/GNU-CXX.cmake +++ b/Modules/Compiler/GNU-CXX.cmake @@ -24,6 +24,11 @@ elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.3) set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++0x") endif() +if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8) + set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++1y") + set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++1y") +endif() + set(CMAKE_CXX_STANDARD_DEFAULT 98) macro(cmake_record_cxx_compile_features) @@ -31,8 +36,14 @@ macro(cmake_record_cxx_compile_features) record_compiler_features(CXX "-std=${std_version}" ${list}) endmacro() + set(_result 0) + if (UNIX AND NOT APPLE AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8) + _get_gcc_features(c++1y CMAKE_CXX14_COMPILE_FEATURES) + endif() if (UNIX AND NOT APPLE AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7) - _get_gcc_features(c++11 CMAKE_CXX11_COMPILE_FEATURES) + if (_result EQUAL 0) + _get_gcc_features(c++11 CMAKE_CXX11_COMPILE_FEATURES) + endif() if (_result EQUAL 0) _get_gcc_features(c++98 CMAKE_CXX98_COMPILE_FEATURES) endif() |