From 5bb7429166240ffaf6f53f834bbb1a4973df8e1d Mon Sep 17 00:00:00 2001 From: Chuck Atkins Date: Wed, 10 May 2017 16:20:10 -0400 Subject: Compilers: Add default cmake_record_{c,cxx}_compile_features macros Add default implementations for the cmake_record_lang_compile_features macros. All implementations of this are the same so it can be safely factored out to a common implementation. --- Modules/Compiler/CMakeCommonCompilerMacros.cmake | 31 ++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Modules/Compiler/CMakeCommonCompilerMacros.cmake b/Modules/Compiler/CMakeCommonCompilerMacros.cmake index cb365d6..684fd30 100644 --- a/Modules/Compiler/CMakeCommonCompilerMacros.cmake +++ b/Modules/Compiler/CMakeCommonCompilerMacros.cmake @@ -60,3 +60,34 @@ macro(__compiler_check_default_language_standard lang stdver1 std1) endif () unset(__std_ver_pairs) endmacro() + +# Define to allow compile features to be automatically determined +macro(cmake_record_c_compile_features) + set(_result 0) + if(_result EQUAL 0 AND DEFINED CMAKE_C11_STANDARD_COMPILE_OPTION) + _record_compiler_features_c(11) + endif() + if(_result EQUAL 0 AND DEFINED CMAKE_C99_STANDARD_COMPILE_OPTION) + _record_compiler_features_c(99) + endif() + if(_result EQUAL 0 AND DEFINED CMAKE_C90_STANDARD_COMPILE_OPTION) + _record_compiler_features_c(90) + endif() +endmacro() + +# Define to allow compile features to be automatically determined +macro(cmake_record_cxx_compile_features) + set(_result 0) + if(_result EQUAL 0 AND DEFINED CMAKE_CXX17_STANDARD_COMPILE_OPTION) + _record_compiler_features_cxx(17) + endif() + if(_result EQUAL 0 AND DEFINED CMAKE_CXX14_STANDARD_COMPILE_OPTION) + _record_compiler_features_cxx(14) + endif() + if(_result EQUAL 0 AND DEFINED CMAKE_CXX11_STANDARD_COMPILE_OPTION) + _record_compiler_features_cxx(11) + endif() + if(_result EQUAL 0 AND DEFINED CMAKE_CXX98_STANDARD_COMPILE_OPTION) + _record_compiler_features_cxx(98) + endif() +endmacro() -- cgit v0.12 From 20ffa14708e5e1b324ac954fd06a1415b9398b7c Mon Sep 17 00:00:00 2001 From: Chuck Atkins Date: Mon, 15 May 2017 18:05:17 +0000 Subject: Tests: Allow test macro to take no executable arguments --- Tests/CMakeLists.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 335267a..cbd7906 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1,6 +1,9 @@ # a macro for tests that have a simple format where the name matches the # directory and project -macro(ADD_TEST_MACRO NAME COMMAND) +macro(ADD_TEST_MACRO NAME) + if(${ARGC} GREATER 1) + set(_test_command --test-command ${ARGN}) + endif() string(REPLACE "." "/" dir "${NAME}") string(REGEX REPLACE "[^.]*\\." "" proj "${NAME}") add_test(NAME "${NAME}" COMMAND "${CMAKE_CTEST_COMMAND}" @@ -13,7 +16,8 @@ macro(ADD_TEST_MACRO NAME COMMAND) ${${NAME}_CTEST_OPTIONS} --build-options ${build_options} ${${NAME}_BUILD_OPTIONS} - --test-command ${COMMAND} ${ARGN}) + ${_test_command}) + unset(_test_command) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${dir}") endmacro() -- cgit v0.12 From e556f1b909a910f7124bd26f82e4b42dd2142c17 Mon Sep 17 00:00:00 2001 From: Chuck Atkins Date: Mon, 15 May 2017 18:06:29 +0000 Subject: CompileFeatures: Makes tests work with meta-feature only --- .../target_compile_features/CMakeLists.txt | 70 ++++++++++++++-------- .../target_compile_features/dummy.cpp | 5 -- Tests/CMakeLists.txt | 2 +- Tests/CompileFeatures/CMakeLists.txt | 23 +++++-- .../WriteCompilerDetectionHeader/CMakeLists.txt | 13 +++- .../LinkImplementationFeatureCycle.cmake | 5 +- Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake | 5 +- 7 files changed, 81 insertions(+), 42 deletions(-) delete mode 100644 Tests/CMakeCommands/target_compile_features/dummy.cpp diff --git a/Tests/CMakeCommands/target_compile_features/CMakeLists.txt b/Tests/CMakeCommands/target_compile_features/CMakeLists.txt index 555a08f..5096a58 100644 --- a/Tests/CMakeCommands/target_compile_features/CMakeLists.txt +++ b/Tests/CMakeCommands/target_compile_features/CMakeLists.txt @@ -1,45 +1,65 @@ cmake_minimum_required(VERSION 3.0) +cmake_policy(SET CMP0057 NEW) project(target_compile_features) -if (NOT CMAKE_CXX_COMPILE_FEATURES AND NOT CMAKE_C_COMPILE_FEATURES) - file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_dummy.cpp" - "int main(int,char**) { return 0; }\n" - ) - add_executable(target_compile_features "${CMAKE_CURRENT_BINARY_DIR}/test_dummy.cpp") - return() -endif() - set(CMAKE_VERBOSE_MAKEFILE ON) -if (CMAKE_C_COMPILE_FEATURES) - add_executable(target_compile_features main.c) - target_compile_features(target_compile_features +if (c_restrict IN_LIST CMAKE_C_COMPILE_FEATURES) + add_executable(c_target_compile_features_specific main.c) + target_compile_features(c_target_compile_features_specific PRIVATE c_restrict ) - add_library(lib_restrict lib_restrict.c) - target_compile_features(lib_restrict + add_library(c_lib_restrict_specific lib_restrict.c) + target_compile_features(c_lib_restrict_specific PUBLIC c_restrict ) - add_executable(restrict_user restrict_user.c) - target_link_libraries(restrict_user lib_restrict) + add_executable(c_restrict_user_specific restrict_user.c) + target_link_libraries(c_restrict_user_specific c_lib_restrict_specific) endif() -if (CMAKE_CXX_COMPILE_FEATURES AND ";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";cxx_auto_type;") - if (CMAKE_C_COMPILE_FEATURES) - set(target_suffix _cxx) - endif() - add_executable(target_compile_features${target_suffix} main.cpp) - target_compile_features(target_compile_features${target_suffix} +if (c_std_99 IN_LIST CMAKE_C_COMPILE_FEATURES) + add_executable(c_target_compile_features_meta main.c) + target_compile_features(c_target_compile_features_meta + PRIVATE c_std_99 + ) + + add_library(c_lib_restrict_meta lib_restrict.c) + target_compile_features(c_lib_restrict_meta + PUBLIC c_std_99 + ) + + add_executable(c_restrict_user_meta restrict_user.c) + target_link_libraries(c_restrict_user_meta c_lib_restrict_meta) +endif() + +if (cxx_auto_type IN_LIST CMAKE_CXX_COMPILE_FEATURES) + add_executable(cxx_target_compile_features_specific main.cpp) + target_compile_features(cxx_target_compile_features_specific PRIVATE cxx_auto_type ) - add_library(lib_auto_type lib_auto_type.cpp) - target_compile_features(lib_auto_type + add_library(cxx_lib_auto_type_specific lib_auto_type.cpp) + target_compile_features(cxx_lib_auto_type_specific PUBLIC cxx_auto_type ) - add_executable(lib_user lib_user.cpp) - target_link_libraries(lib_user lib_auto_type) + add_executable(cxx_lib_user_specific lib_user.cpp) + target_link_libraries(cxx_lib_user_specific cxx_lib_auto_type_specific) +endif() + +if (cxx_std_11 IN_LIST CMAKE_CXX_COMPILE_FEATURES) + add_executable(cxx_target_compile_features_meta main.cpp) + target_compile_features(cxx_target_compile_features_meta + PRIVATE cxx_std_11 + ) + + add_library(cxx_lib_auto_type_meta lib_auto_type.cpp) + target_compile_features(cxx_lib_auto_type_meta + PUBLIC cxx_std_11 + ) + + add_executable(cxx_lib_user_meta lib_user.cpp) + target_link_libraries(cxx_lib_user_meta cxx_lib_auto_type_meta) endif() diff --git a/Tests/CMakeCommands/target_compile_features/dummy.cpp b/Tests/CMakeCommands/target_compile_features/dummy.cpp deleted file mode 100644 index e9ad257..0000000 --- a/Tests/CMakeCommands/target_compile_features/dummy.cpp +++ /dev/null @@ -1,5 +0,0 @@ - -int main(int, char**) -{ - return 0; -} diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index cbd7906..02156e8 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -275,7 +275,7 @@ if(BUILD_TESTING) ADD_TEST_MACRO(SystemInformation SystemInformation) ADD_TEST_MACRO(MathTest MathTest) ADD_TEST_MACRO(CompileFeatures CompileFeatures) - ADD_TEST_MACRO(CMakeCommands.target_compile_features target_compile_features) + ADD_TEST_MACRO(CMakeCommands.target_compile_features) if(CMake_TEST_RESOURCES) ADD_TEST_MACRO(VSResource VSResource) diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt index bb18543..4a5558d 100644 --- a/Tests/CompileFeatures/CMakeLists.txt +++ b/Tests/CompileFeatures/CMakeLists.txt @@ -1,10 +1,11 @@ cmake_minimum_required(VERSION 3.1) +cmake_policy(SET CMP0057 NEW) project(CompileFeatures) macro(run_test feature lang) - if (";${CMAKE_${lang}_COMPILE_FEATURES};" MATCHES ${feature}) + if (${feature} IN_LIST CMAKE_${lang}_COMPILE_FEATURES) add_library(test_${feature} OBJECT ${feature}) set_property(TARGET test_${feature} PROPERTY COMPILE_FEATURES "${feature}" @@ -15,12 +16,13 @@ macro(run_test feature lang) endmacro() get_property(c_features GLOBAL PROPERTY CMAKE_C_KNOWN_FEATURES) -list(REMOVE_ITEM c_features c_std_90 c_std_99 c_std_11) +list(FILTER c_features EXCLUDE REGEX "^c_std_[0-9][0-9]") foreach(feature ${c_features}) run_test(${feature} C) endforeach() + get_property(cxx_features GLOBAL PROPERTY CMAKE_CXX_KNOWN_FEATURES) -list(REMOVE_ITEM cxx_features cxx_std_98 cxx_std_11 cxx_std_14 cxx_std_17) +list(FILTER cxx_features EXCLUDE REGEX "^cxx_std_[0-9][0-9]") foreach(feature ${cxx_features}) run_test(${feature} CXX) endforeach() @@ -171,12 +173,20 @@ if (CMAKE_C_COMPILER_ID STREQUAL "Intel") endif() endif() +if (CMAKE_C_COMPILE_FEATURES) + set(C_expected_features ${CMAKE_C_COMPILE_FEATURES}) + list(FILTER C_expected_features EXCLUDE REGEX "^c_std_[0-9][0-9]") +endif() +if (CMAKE_CXX_COMPILE_FEATURES) + set(CXX_expected_features ${CMAKE_CXX_COMPILE_FEATURES}) + list(FILTER CXX_expected_features EXCLUDE REGEX "^cxx_std_[0-9][0-9]") +endif () set(C_ext c) set(C_standard_flag 11) set(CXX_ext cpp) set(CXX_standard_flag 14) foreach(lang CXX C) - if (CMAKE_${lang}_COMPILE_FEATURES) + if (${lang}_expected_features) foreach(feature ${${lang}_non_features}) message("Testing feature : ${feature}") try_compile(${feature}_works @@ -198,7 +208,7 @@ foreach(lang CXX C) endif() endforeach() -if (CMAKE_C_COMPILE_FEATURES) +if (C_expected_features) if (CMAKE_C_STANDARD_DEFAULT) string(FIND "${CMAKE_C_FLAGS}" "-std=" std_flag_idx) if (std_flag_idx EQUAL -1) @@ -280,7 +290,8 @@ if (CMAKE_CXX_COMPILE_FEATURES) endif () # always add a target "CompileFeatures" -if (NOT ";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";cxx_auto_type;") +if ((NOT CXX_expected_features) OR + (NOT cxx_auto_type IN_LIST CXX_expected_features)) file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp" "int main(int,char**) { return 0; }\n" ) diff --git a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt index 2657aeb..52d4613 100644 --- a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt +++ b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt @@ -48,7 +48,14 @@ macro(set_defines target true_defs false_defs) ) endmacro() +# Only run the compiler detection header test for compilers with +# detailed features tables, not just meta-features + if (CMAKE_C_COMPILE_FEATURES) + set(C_expected_features ${CMAKE_C_COMPILE_FEATURES}) + list(FILTER C_expected_features EXCLUDE REGEX "^c_std_[0-9][0-9]") +endif() +if (C_expected_features) string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" COMPILER_VERSION_MAJOR "${CMAKE_C_COMPILER_VERSION}") string(REGEX REPLACE "^[0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" COMPILER_VERSION_MINOR "${CMAKE_C_COMPILER_VERSION}") string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" COMPILER_VERSION_PATCH "${CMAKE_C_COMPILER_VERSION}") @@ -85,7 +92,11 @@ if (CMAKE_C_COMPILE_FEATURES) endif() endif() -if (NOT CMAKE_CXX_COMPILE_FEATURES) +if (CMAKE_CXX_COMPILE_FEATURES) + set(CXX_expected_features ${CMAKE_CXX_COMPILE_FEATURES}) + list(FILTER CXX_expected_features EXCLUDE REGEX "^cxx_std_[0-9][0-9]") +endif() +if (NOT CXX_expected_features) file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp" "int main(int,char**) { return 0; }\n" ) diff --git a/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycle.cmake b/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycle.cmake index 2d14a9e..b24a680 100644 --- a/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycle.cmake +++ b/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycle.cmake @@ -6,9 +6,10 @@ add_library(empty3 INTERFACE) target_compile_features(empty3 INTERFACE cxx_std_11) 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_std_11, but that would require CXX_STANDARD = 11, # which is not allowed after freeze. Report an error. empty3 diff --git a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake index 8dc627d..5a70da2 100644 --- a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake +++ b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake @@ -1,3 +1,4 @@ +cmake_policy(SET CMP0057 NEW) include(RunCMake) run_cmake(NotAFeature) @@ -28,13 +29,13 @@ endif() if (NOT CXX_FEATURES) run_cmake(NoSupportedCxxFeatures) run_cmake(NoSupportedCxxFeaturesGenex) -else() +elseif (cxx_std_98 IN_LIST CXX_FEATURES AND cxx_std_11 IN_LIST CXX_FEATURES) if(CXX_STANDARD_DEFAULT EQUAL 98) run_cmake(LinkImplementationFeatureCycle) endif() run_cmake(LinkImplementationFeatureCycleSolved) - if (";${CXX_FEATURES};" MATCHES ";cxx_final;") + if (cxx_final IN_LIST CXX_FEATURES) set(RunCMake_TEST_OPTIONS "-DHAVE_FINAL=1") endif() run_cmake(NonValidTarget1) -- cgit v0.12 From 37221529c7d032599cd7f8a4bb6778a55b8bc5a8 Mon Sep 17 00:00:00 2001 From: Chuck Atkins Date: Wed, 10 May 2017 16:37:19 -0400 Subject: MSVC: Add empty definitions for std compile options There are no specific options for MSVC to set language standards, but set them as empty strings anyways so the feature test infrastructure can at least check to see if they are defined. --- Modules/Compiler/MSVC-CXX.cmake | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Modules/Compiler/MSVC-CXX.cmake b/Modules/Compiler/MSVC-CXX.cmake index 8fcfa0f..98b74e4 100644 --- a/Modules/Compiler/MSVC-CXX.cmake +++ b/Modules/Compiler/MSVC-CXX.cmake @@ -1,6 +1,20 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. -if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16.0) - # MSVC has no specific language level or flags to change it. +if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.0) + # MSVC has no specific options to set language standards, but set them as + # empty strings anyways so the feature test infrastructure can at least check + # to see if they are defined. + set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "") + set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "") + set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "") + set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "") + set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "") + set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "") + set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "") + set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "") + + # There is no meaningful default for this set(CMAKE_CXX_STANDARD_DEFAULT "") endif() -- cgit v0.12 From 9b112a848a2063c81fe758984351d765e712a2bc Mon Sep 17 00:00:00 2001 From: Chuck Atkins Date: Wed, 10 May 2017 16:39:53 -0400 Subject: Compilers: Port to use default cmake_record_lang_compile_features macros --- Modules/Compiler/AppleClang-C.cmake | 15 --------------- Modules/Compiler/AppleClang-CXX.cmake | 18 ------------------ Modules/Compiler/Clang-C.cmake | 15 --------------- Modules/Compiler/Clang-CXX.cmake | 18 ------------------ Modules/Compiler/GNU-C.cmake | 15 --------------- Modules/Compiler/GNU-CXX.cmake | 18 ------------------ Modules/Compiler/Intel-C.cmake | 15 --------------- Modules/Compiler/Intel-CXX.cmake | 18 ------------------ Modules/Compiler/MSVC-CXX.cmake | 14 ++------------ Modules/Compiler/SunPro-C.cmake | 15 --------------- Modules/Compiler/SunPro-CXX.cmake | 12 ------------ 11 files changed, 2 insertions(+), 171 deletions(-) diff --git a/Modules/Compiler/AppleClang-C.cmake b/Modules/Compiler/AppleClang-C.cmake index c18f541..a48adec 100644 --- a/Modules/Compiler/AppleClang-C.cmake +++ b/Modules/Compiler/AppleClang-C.cmake @@ -13,18 +13,3 @@ if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.0) endif() __compiler_check_default_language_standard(C 4.0 99) - -macro(cmake_record_c_compile_features) - set(_result 0) - if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.0) - if (_result EQUAL 0) - _record_compiler_features_c(11) - endif() - if (_result EQUAL 0) - _record_compiler_features_c(99) - endif() - if (_result EQUAL 0) - _record_compiler_features_c(90) - endif() - endif() -endmacro() diff --git a/Modules/Compiler/AppleClang-CXX.cmake b/Modules/Compiler/AppleClang-CXX.cmake index 904d965..e5fd647 100644 --- a/Modules/Compiler/AppleClang-CXX.cmake +++ b/Modules/Compiler/AppleClang-CXX.cmake @@ -28,21 +28,3 @@ if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.1) endif() __compiler_check_default_language_standard(CXX 4.0 98) - -macro(cmake_record_cxx_compile_features) - set(_result 0) - if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.0) - if(_result EQUAL 0 AND CMAKE_CXX17_STANDARD_COMPILE_OPTION) - _record_compiler_features_cxx(17) - endif() - if(_result EQUAL 0 AND CMAKE_CXX14_STANDARD_COMPILE_OPTION) - _record_compiler_features_cxx(14) - endif() - if (_result EQUAL 0) - _record_compiler_features_cxx(11) - endif() - if (_result EQUAL 0) - _record_compiler_features_cxx(98) - endif() - endif() -endmacro() diff --git a/Modules/Compiler/Clang-C.cmake b/Modules/Compiler/Clang-C.cmake index b94087f..b881e2b 100644 --- a/Modules/Compiler/Clang-C.cmake +++ b/Modules/Compiler/Clang-C.cmake @@ -18,18 +18,3 @@ if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4) endif() __compiler_check_default_language_standard(C 3.4 99 3.6 11) - -macro(cmake_record_c_compile_features) - set(_result 0) - if (UNIX AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4) - if (_result EQUAL 0) - _record_compiler_features_c(11) - endif() - if (_result EQUAL 0) - _record_compiler_features_c(99) - endif() - if (_result EQUAL 0) - _record_compiler_features_c(90) - endif() - endif() -endmacro() diff --git a/Modules/Compiler/Clang-CXX.cmake b/Modules/Compiler/Clang-CXX.cmake index 5904efa..ff041ab 100644 --- a/Modules/Compiler/Clang-CXX.cmake +++ b/Modules/Compiler/Clang-CXX.cmake @@ -37,21 +37,3 @@ if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5) endif() __compiler_check_default_language_standard(CXX 3.1 98) - -macro(cmake_record_cxx_compile_features) - set(_result 0) - if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.1) - if(_result EQUAL 0 AND CMAKE_CXX17_STANDARD_COMPILE_OPTION) - _record_compiler_features_cxx(17) - endif() - if(_result EQUAL 0 AND CMAKE_CXX14_STANDARD_COMPILE_OPTION) - _record_compiler_features_cxx(14) - endif() - if (_result EQUAL 0 AND CMAKE_CXX11_STANDARD_COMPILE_OPTION) - _record_compiler_features_cxx(11) - endif() - if (_result EQUAL 0) - _record_compiler_features_cxx(98) - endif() - endif() -endmacro() diff --git a/Modules/Compiler/GNU-C.cmake b/Modules/Compiler/GNU-C.cmake index 8090fa6..f072c54 100644 --- a/Modules/Compiler/GNU-C.cmake +++ b/Modules/Compiler/GNU-C.cmake @@ -23,18 +23,3 @@ elseif (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.6) endif() __compiler_check_default_language_standard(C 3.4 90 5.0 11) - -macro(cmake_record_c_compile_features) - set(_result 0) - if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4) - if(_result EQUAL 0 AND CMAKE_C11_STANDARD_COMPILE_OPTION) - _record_compiler_features_c(11) - endif() - if (_result EQUAL 0) - _record_compiler_features_c(99) - endif() - if (_result EQUAL 0) - _record_compiler_features_c(90) - endif() - endif() -endmacro() diff --git a/Modules/Compiler/GNU-CXX.cmake b/Modules/Compiler/GNU-CXX.cmake index b221c4a..4b8b3c0 100644 --- a/Modules/Compiler/GNU-CXX.cmake +++ b/Modules/Compiler/GNU-CXX.cmake @@ -39,21 +39,3 @@ if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.1) endif() __compiler_check_default_language_standard(CXX 4.4 98 6.0 14) - -macro(cmake_record_cxx_compile_features) - set(_result 0) - if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4) - if(_result EQUAL 0 AND CMAKE_CXX17_STANDARD_COMPILE_OPTION) - _record_compiler_features_cxx(17) - endif() - if(_result EQUAL 0 AND CMAKE_CXX14_STANDARD_COMPILE_OPTION) - _record_compiler_features_cxx(14) - endif() - if (_result EQUAL 0) - _record_compiler_features_cxx(11) - endif() - if (_result EQUAL 0) - _record_compiler_features_cxx(98) - endif() - endif() -endmacro() diff --git a/Modules/Compiler/Intel-C.cmake b/Modules/Compiler/Intel-C.cmake index 20e29e2..2e7ea24 100644 --- a/Modules/Compiler/Intel-C.cmake +++ b/Modules/Compiler/Intel-C.cmake @@ -39,20 +39,5 @@ endif() __compiler_check_default_language_standard(C 12.1 90 15.0.0 11) -macro(cmake_record_c_compile_features) - set(_result 0) - if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 12.1) - if (_result EQUAL 0 AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 15.0.0) - _record_compiler_features_C(11) - endif() - if (_result EQUAL 0) - _record_compiler_features_C(99) - endif() - if (_result EQUAL 0) - _record_compiler_features_C(90) - endif() - endif() -endmacro() - set(CMAKE_C_CREATE_PREPROCESSED_SOURCE " -E > ") set(CMAKE_C_CREATE_ASSEMBLY_SOURCE " -S -o ") diff --git a/Modules/Compiler/Intel-CXX.cmake b/Modules/Compiler/Intel-CXX.cmake index 08d23fc..0eb9e1f 100644 --- a/Modules/Compiler/Intel-CXX.cmake +++ b/Modules/Compiler/Intel-CXX.cmake @@ -56,23 +56,5 @@ endif() __compiler_check_default_language_standard(CXX 12.1 98) -macro(cmake_record_cxx_compile_features) - set(_result 0) - if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.1) - if (_result EQUAL 0 AND - (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16.0 - OR (NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC" AND - NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15.0))) - _record_compiler_features_cxx(14) - endif() - if (_result EQUAL 0) - _record_compiler_features_cxx(11) - endif() - if (_result EQUAL 0) - _record_compiler_features_cxx(98) - endif() - endif() -endmacro() - set(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE " -E > ") set(CMAKE_CXX_CREATE_ASSEMBLY_SOURCE " -S -o ") diff --git a/Modules/Compiler/MSVC-CXX.cmake b/Modules/Compiler/MSVC-CXX.cmake index 98b74e4..9371301 100644 --- a/Modules/Compiler/MSVC-CXX.cmake +++ b/Modules/Compiler/MSVC-CXX.cmake @@ -1,6 +1,8 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. +include(Compiler/CMakeCommonCompilerMacros) + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.0) # MSVC has no specific options to set language standards, but set them as # empty strings anyways so the feature test infrastructure can at least check @@ -17,15 +19,3 @@ if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.0) # There is no meaningful default for this set(CMAKE_CXX_STANDARD_DEFAULT "") endif() - -macro(cmake_record_cxx_compile_features) - if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16.0) - list(APPEND CMAKE_CXX_COMPILE_FEATURES - cxx_std_98 - cxx_std_11 - cxx_std_14 - cxx_std_17 - ) - _record_compiler_features(CXX "" CMAKE_CXX_COMPILE_FEATURES) - endif() -endmacro() diff --git a/Modules/Compiler/SunPro-C.cmake b/Modules/Compiler/SunPro-C.cmake index ac88e6f..29c2f22 100644 --- a/Modules/Compiler/SunPro-C.cmake +++ b/Modules/Compiler/SunPro-C.cmake @@ -43,20 +43,5 @@ endif() __compiler_check_default_language_standard(C 5.11 90 5.14 11) -macro(cmake_record_c_compile_features) - set(_result 0) - if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 5.13) - if(_result EQUAL 0 AND CMAKE_C11_STANDARD_COMPILE_OPTION) - _record_compiler_features_c(11) - endif() - if (_result EQUAL 0) - _record_compiler_features_c(99) - endif() - if (_result EQUAL 0) - _record_compiler_features_c(90) - endif() - endif() -endmacro() - set(CMAKE_C_CREATE_PREPROCESSED_SOURCE " -E > ") set(CMAKE_C_CREATE_ASSEMBLY_SOURCE " -S -o ") diff --git a/Modules/Compiler/SunPro-CXX.cmake b/Modules/Compiler/SunPro-CXX.cmake index 4b0a21d..2222b25 100644 --- a/Modules/Compiler/SunPro-CXX.cmake +++ b/Modules/Compiler/SunPro-CXX.cmake @@ -49,15 +49,3 @@ else() endif() __compiler_check_default_language_standard(CXX 5.13 98) - -macro(cmake_record_cxx_compile_features) - set(_result 0) - if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13) - if (_result EQUAL 0) - _record_compiler_features_cxx(11) - endif() - if (_result EQUAL 0) - _record_compiler_features_cxx(98) - endif() - endif() -endmacro() -- cgit v0.12 From a40e6ba88dfe88df9a9665325636b0e01a4beb5c Mon Sep 17 00:00:00 2001 From: Chuck Atkins Date: Mon, 29 May 2017 12:51:53 -0400 Subject: Clang: Fix language defaults for 2.1 --- Modules/Compiler/Clang-CXX.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Compiler/Clang-CXX.cmake b/Modules/Compiler/Clang-CXX.cmake index ff041ab..d3707ee 100644 --- a/Modules/Compiler/Clang-CXX.cmake +++ b/Modules/Compiler/Clang-CXX.cmake @@ -36,4 +36,4 @@ if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5) set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std=gnu++1z") endif() -__compiler_check_default_language_standard(CXX 3.1 98) +__compiler_check_default_language_standard(CXX 2.1 98) -- cgit v0.12 From 220ede74ff5dcd8a8078057c1ba71ecfa768f475 Mon Sep 17 00:00:00 2001 From: Chuck Atkins Date: Mon, 29 May 2017 13:22:09 -0400 Subject: GNU: Fix language defaults for 3.4 --- Modules/Compiler/GNU-CXX.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Compiler/GNU-CXX.cmake b/Modules/Compiler/GNU-CXX.cmake index 4b8b3c0..4f1f30e 100644 --- a/Modules/Compiler/GNU-CXX.cmake +++ b/Modules/Compiler/GNU-CXX.cmake @@ -38,4 +38,4 @@ if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.1) set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std=gnu++1z") endif() -__compiler_check_default_language_standard(CXX 4.4 98 6.0 14) +__compiler_check_default_language_standard(CXX 3.4 98 6.0 14) -- cgit v0.12 From f70b0bb36545befdf5c5d9d524d51a6ff14021f1 Mon Sep 17 00:00:00 2001 From: Chuck Atkins Date: Tue, 30 May 2017 09:18:47 -0400 Subject: SunPro: Make sure all known versions get CXX98 defaults --- Modules/Compiler/SunPro-CXX.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/Compiler/SunPro-CXX.cmake b/Modules/Compiler/SunPro-CXX.cmake index 2222b25..5cb7edc 100644 --- a/Modules/Compiler/SunPro-CXX.cmake +++ b/Modules/Compiler/SunPro-CXX.cmake @@ -43,9 +43,9 @@ if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13) set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=c++11") set(CMAKE_CXX_LINK_WITH_STANDARD_COMPILE_OPTION 1) else() - set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-library=stlport") - set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-library=stlport") + set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-library=stlport4") + set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-library=stlport4") set(CMAKE_CXX_LINK_WITH_STANDARD_COMPILE_OPTION 1) endif() -__compiler_check_default_language_standard(CXX 5.13 98) +__compiler_check_default_language_standard(CXX 1 98) -- cgit v0.12 From 3c1ecb5214afa45a44742ad2b1e24517925e858a Mon Sep 17 00:00:00 2001 From: Chuck Atkins Date: Tue, 30 May 2017 09:35:22 -0400 Subject: Intel: Fix missing C std default for 12.0 <= ver < 12.1 --- Modules/Compiler/Intel-C.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Compiler/Intel-C.cmake b/Modules/Compiler/Intel-C.cmake index 2e7ea24..4e4af29 100644 --- a/Modules/Compiler/Intel-C.cmake +++ b/Modules/Compiler/Intel-C.cmake @@ -37,7 +37,7 @@ else() endif() -__compiler_check_default_language_standard(C 12.1 90 15.0.0 11) +__compiler_check_default_language_standard(C 12.0 90 15.0.0 11) set(CMAKE_C_CREATE_PREPROCESSED_SOURCE " -E > ") set(CMAKE_C_CREATE_ASSEMBLY_SOURCE " -S -o ") -- cgit v0.12