Merge topic 'compile-features-refactor'

32b91b9e Features: Run GNU feature tests with std=c++14 when available.
82c283f9 Features: Use the correct dialect flag when recording features.
b18155b7 Features: Reorder the GNU C dialect feature tests
e68d5c60 Features: Split the Clang testable features to a separate file.
This commit is contained in:
Brad King 2014-11-13 10:08:29 -05:00 committed by CMake Topic Stage
commit f4e652b563
6 changed files with 75 additions and 70 deletions

View File

@ -21,16 +21,16 @@ set(CMAKE_C_STANDARD_DEFAULT 90)
macro(cmake_record_c_compile_features)
macro(_get_clang_features std_version list)
record_compiler_features(C "-std=${std_version}" ${list})
record_compiler_features(C "${std_version}" ${list})
endmacro()
if (UNIX AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4)
_get_clang_features(c11 CMAKE_C11_COMPILE_FEATURES)
_get_clang_features(${CMAKE_C11_STANDARD_COMPILE_OPTION} CMAKE_C11_COMPILE_FEATURES)
if (_result EQUAL 0)
_get_clang_features(c99 CMAKE_C99_COMPILE_FEATURES)
_get_clang_features(${CMAKE_C99_STANDARD_COMPILE_OPTION} CMAKE_C99_COMPILE_FEATURES)
endif()
if (_result EQUAL 0)
_get_clang_features(c90 CMAKE_C90_COMPILE_FEATURES)
_get_clang_features(${CMAKE_C90_STANDARD_COMPILE_OPTION} CMAKE_C90_COMPILE_FEATURES)
endif()
else()
set(_result 0)

View File

@ -2,61 +2,9 @@
# Reference: http://clang.llvm.org/cxx_status.html
# http://clang.llvm.org/docs/LanguageExtensions.html
set(testable_features
cxx_alias_templates
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
cxx_defaulted_functions
cxx_delegating_constructors
cxx_deleted_functions
cxx_explicit_conversions
cxx_generalized_initializers
cxx_inheriting_constructors
cxx_lambdas
cxx_local_type_template_args
cxx_noexcept
cxx_nonstatic_member_init
cxx_nullptr
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
cxx_thread_local
cxx_unicode_literals
cxx_unrestricted_unions
cxx_user_literals
cxx_variable_templates
cxx_variadic_templates
)
set(_cmake_oldestSupported "((__clang_major__ * 100) + __clang_minor__) >= 304")
foreach(feature ${testable_features})
set(_cmake_feature_test_${feature} "${_cmake_oldestSupported} && __has_feature(${feature})")
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)")
include("${CMAKE_CURRENT_LIST_DIR}/Clang-CXX-TestableFeatures.cmake")
set(Clang34_CXX14 "((__clang_major__ * 100) + __clang_minor__) >= 304 && __cplusplus > 201103L")
# http://llvm.org/bugs/show_bug.cgi?id=19242

View File

@ -0,0 +1,54 @@
set(testable_features
cxx_alias_templates
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
cxx_defaulted_functions
cxx_delegating_constructors
cxx_deleted_functions
cxx_explicit_conversions
cxx_generalized_initializers
cxx_inheriting_constructors
cxx_lambdas
cxx_local_type_template_args
cxx_noexcept
cxx_nonstatic_member_init
cxx_nullptr
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
cxx_thread_local
cxx_unicode_literals
cxx_unrestricted_unions
cxx_user_literals
cxx_variable_templates
cxx_variadic_templates
)
foreach(feature ${testable_features})
set(_cmake_feature_test_${feature} "${_cmake_oldestSupported} && __has_feature(${feature})")
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)")

View File

@ -35,16 +35,16 @@ set(CMAKE_CXX_STANDARD_DEFAULT 98)
macro(cmake_record_cxx_compile_features)
macro(_get_clang_features std_version list)
record_compiler_features(CXX "-std=${std_version}" ${list})
record_compiler_features(CXX "${std_version}" ${list})
endmacro()
if (UNIX AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4)
_get_clang_features(c++1y CMAKE_CXX14_COMPILE_FEATURES)
_get_clang_features(${CMAKE_CXX14_STANDARD_COMPILE_OPTION} CMAKE_CXX14_COMPILE_FEATURES)
if (_result EQUAL 0)
_get_clang_features(c++11 CMAKE_CXX11_COMPILE_FEATURES)
_get_clang_features(${CMAKE_CXX11_STANDARD_COMPILE_OPTION} CMAKE_CXX11_COMPILE_FEATURES)
endif()
if (_result EQUAL 0)
_get_clang_features(c++98 CMAKE_CXX98_COMPILE_FEATURES)
_get_clang_features(${CMAKE_CXX98_STANDARD_COMPILE_OPTION} CMAKE_CXX98_COMPILE_FEATURES)
endif()
else()
set(_result 0)

View File

@ -17,16 +17,16 @@ set(CMAKE_C_STANDARD_DEFAULT 90)
macro(cmake_record_c_compile_features)
macro(_get_gcc_features std_version list)
record_compiler_features(C "-std=${std_version}" ${list})
record_compiler_features(C "${std_version}" ${list})
endmacro()
if (UNIX AND NOT APPLE AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7)
_get_gcc_features(c90 CMAKE_C90_COMPILE_FEATURES)
_get_gcc_features(${CMAKE_C11_STANDARD_COMPILE_OPTION} CMAKE_C11_COMPILE_FEATURES)
if (_result EQUAL 0)
_get_gcc_features(c99 CMAKE_C99_COMPILE_FEATURES)
_get_gcc_features(${CMAKE_C99_STANDARD_COMPILE_OPTION} CMAKE_C99_COMPILE_FEATURES)
endif()
if (_result EQUAL 0)
_get_gcc_features(c11 CMAKE_C11_COMPILE_FEATURES)
_get_gcc_features(${CMAKE_C90_STANDARD_COMPILE_OPTION} CMAKE_C90_COMPILE_FEATURES)
endif()
else()
set(_result 0)

View File

@ -24,7 +24,10 @@ 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)
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9)
set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++14")
set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++14")
elseif (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()
@ -33,19 +36,19 @@ set(CMAKE_CXX_STANDARD_DEFAULT 98)
macro(cmake_record_cxx_compile_features)
macro(_get_gcc_features std_version list)
record_compiler_features(CXX "-std=${std_version}" ${list})
record_compiler_features(CXX "${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)
_get_gcc_features(${CMAKE_CXX14_STANDARD_COMPILE_OPTION} CMAKE_CXX14_COMPILE_FEATURES)
endif()
if (UNIX AND NOT APPLE AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
if (_result EQUAL 0)
_get_gcc_features(c++11 CMAKE_CXX11_COMPILE_FEATURES)
_get_gcc_features(${CMAKE_CXX11_STANDARD_COMPILE_OPTION} CMAKE_CXX11_COMPILE_FEATURES)
endif()
if (_result EQUAL 0)
_get_gcc_features(c++98 CMAKE_CXX98_COMPILE_FEATURES)
_get_gcc_features(${CMAKE_CXX98_STANDARD_COMPILE_OPTION} CMAKE_CXX98_COMPILE_FEATURES)
endif()
else()
set(_result 0)