summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-11-13 15:08:29 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2014-11-13 15:08:29 (GMT)
commitf4e652b5633c14d3602be8805a2f0c49bb524147 (patch)
treea6d283b95c8c959bad4be25a45203a3a656b74f1
parentdd89506c1ea85240b81867db5a467e6632a7ec7a (diff)
parent32b91b9e019774365029f98026ed0676708ce318 (diff)
downloadCMake-f4e652b5633c14d3602be8805a2f0c49bb524147.zip
CMake-f4e652b5633c14d3602be8805a2f0c49bb524147.tar.gz
CMake-f4e652b5633c14d3602be8805a2f0c49bb524147.tar.bz2
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.
-rw-r--r--Modules/Compiler/Clang-C.cmake8
-rw-r--r--Modules/Compiler/Clang-CXX-FeatureTests.cmake54
-rw-r--r--Modules/Compiler/Clang-CXX-TestableFeatures.cmake54
-rw-r--r--Modules/Compiler/Clang-CXX.cmake8
-rw-r--r--Modules/Compiler/GNU-C.cmake8
-rw-r--r--Modules/Compiler/GNU-CXX.cmake13
6 files changed, 75 insertions, 70 deletions
diff --git a/Modules/Compiler/Clang-C.cmake b/Modules/Compiler/Clang-C.cmake
index 05d3c0b..92119ba 100644
--- a/Modules/Compiler/Clang-C.cmake
+++ b/Modules/Compiler/Clang-C.cmake
@@ -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)
diff --git a/Modules/Compiler/Clang-CXX-FeatureTests.cmake b/Modules/Compiler/Clang-CXX-FeatureTests.cmake
index 4c532fb..df2e1a8 100644
--- a/Modules/Compiler/Clang-CXX-FeatureTests.cmake
+++ b/Modules/Compiler/Clang-CXX-FeatureTests.cmake
@@ -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
diff --git a/Modules/Compiler/Clang-CXX-TestableFeatures.cmake b/Modules/Compiler/Clang-CXX-TestableFeatures.cmake
new file mode 100644
index 0000000..b39475c
--- /dev/null
+++ b/Modules/Compiler/Clang-CXX-TestableFeatures.cmake
@@ -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)")
diff --git a/Modules/Compiler/Clang-CXX.cmake b/Modules/Compiler/Clang-CXX.cmake
index 5dd7b4a..780a072 100644
--- a/Modules/Compiler/Clang-CXX.cmake
+++ b/Modules/Compiler/Clang-CXX.cmake
@@ -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)
diff --git a/Modules/Compiler/GNU-C.cmake b/Modules/Compiler/GNU-C.cmake
index 35954be..c4a2ed6 100644
--- a/Modules/Compiler/GNU-C.cmake
+++ b/Modules/Compiler/GNU-C.cmake
@@ -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)
diff --git a/Modules/Compiler/GNU-CXX.cmake b/Modules/Compiler/GNU-CXX.cmake
index 14dc76a..422bacd 100644
--- a/Modules/Compiler/GNU-CXX.cmake
+++ b/Modules/Compiler/GNU-CXX.cmake
@@ -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)