diff options
author | Brad King <brad.king@kitware.com> | 2022-01-24 17:37:44 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-01-24 17:37:52 (GMT) |
commit | d5e3b1ca1e29b9a73cd34ad641ed3c68d00ae573 (patch) | |
tree | 1a5ec9ac7dc723c195ea7d6bde26dc3467c20954 /Tests/RunCMake | |
parent | 63154cbf4501e11cae281eccbbdf9eceb453dae1 (diff) | |
parent | ee1396e29e98dbd3a4517ce364a534c80bc6fb4a (diff) | |
download | CMake-d5e3b1ca1e29b9a73cd34ad641ed3c68d00ae573.zip CMake-d5e3b1ca1e29b9a73cd34ad641ed3c68d00ae573.tar.gz CMake-d5e3b1ca1e29b9a73cd34ad641ed3c68d00ae573.tar.bz2 |
Merge topic 'cmp0128_cuda'
ee1396e29e CMP0128: Add flag in OLD mode even when standard matches the default
b2c25de8e0 CMP0128: Avoid test code duplication
3a089cd256 CMP0128: Prefix test names with mode
e13dd52535 XL: Detect default extensions mode for legacy compiler
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6890
Diffstat (limited to 'Tests/RunCMake')
14 files changed, 46 insertions, 31 deletions
diff --git a/Tests/RunCMake/CompileFeatures/ExtensionsStandardUnset.cmake b/Tests/RunCMake/CompileFeatures/CMP0128Common.cmake index 99bb3f0..b309d74 100644 --- a/Tests/RunCMake/CompileFeatures/ExtensionsStandardUnset.cmake +++ b/Tests/RunCMake/CompileFeatures/CMP0128Common.cmake @@ -4,5 +4,4 @@ enable_language(@lang@) string(REPLACE "${CMAKE_START_TEMP_FILE}" "" CMAKE_@lang@_COMPILE_OBJECT "${CMAKE_@lang@_COMPILE_OBJECT}") string(REPLACE "${CMAKE_END_TEMP_FILE}" "" CMAKE_@lang@_COMPILE_OBJECT "${CMAKE_@lang@_COMPILE_OBJECT}") -set(CMAKE_@lang@_EXTENSIONS @extensions_opposite@) add_library(foo "@RunCMake_SOURCE_DIR@/empty.@ext@") diff --git a/Tests/RunCMake/CompileFeatures/ExtensionsStandardDefault-build-check.cmake b/Tests/RunCMake/CompileFeatures/CMP0128NewExtensionsStandardDefault-build-check.cmake index 4e85397..4e85397 100644 --- a/Tests/RunCMake/CompileFeatures/ExtensionsStandardDefault-build-check.cmake +++ b/Tests/RunCMake/CompileFeatures/CMP0128NewExtensionsStandardDefault-build-check.cmake diff --git a/Tests/RunCMake/CompileFeatures/CMP0128NewExtensionsStandardDefault.cmake b/Tests/RunCMake/CompileFeatures/CMP0128NewExtensionsStandardDefault.cmake new file mode 100644 index 0000000..5b7358a --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/CMP0128NewExtensionsStandardDefault.cmake @@ -0,0 +1,2 @@ +set(CMAKE_@lang@_EXTENSIONS @extensions_opposite@) +set(CMAKE_@lang@_STANDARD @standard_default@) diff --git a/Tests/RunCMake/CompileFeatures/ExtensionsStandardUnset-build-check.cmake b/Tests/RunCMake/CompileFeatures/CMP0128NewExtensionsStandardUnset-build-check.cmake index abe293c..abe293c 100644 --- a/Tests/RunCMake/CompileFeatures/ExtensionsStandardUnset-build-check.cmake +++ b/Tests/RunCMake/CompileFeatures/CMP0128NewExtensionsStandardUnset-build-check.cmake diff --git a/Tests/RunCMake/CompileFeatures/CMP0128NewExtensionsStandardUnset.cmake b/Tests/RunCMake/CompileFeatures/CMP0128NewExtensionsStandardUnset.cmake new file mode 100644 index 0000000..6923c11 --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/CMP0128NewExtensionsStandardUnset.cmake @@ -0,0 +1 @@ +set(CMAKE_@lang@_EXTENSIONS @extensions_opposite@) diff --git a/Tests/RunCMake/CompileFeatures/NoUnnecessaryFlag-build-check.cmake b/Tests/RunCMake/CompileFeatures/CMP0128NewNoUnnecessaryFlag-build-check.cmake index 4f767fa..4f767fa 100644 --- a/Tests/RunCMake/CompileFeatures/NoUnnecessaryFlag-build-check.cmake +++ b/Tests/RunCMake/CompileFeatures/CMP0128NewNoUnnecessaryFlag-build-check.cmake diff --git a/Tests/RunCMake/CompileFeatures/CMP0128NewNoUnnecessaryFlag.cmake b/Tests/RunCMake/CompileFeatures/CMP0128NewNoUnnecessaryFlag.cmake new file mode 100644 index 0000000..73c0641 --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/CMP0128NewNoUnnecessaryFlag.cmake @@ -0,0 +1,2 @@ +set(CMAKE_@lang@_EXTENSIONS @extensions_default@) +set(CMAKE_@lang@_STANDARD @standard_default@) diff --git a/Tests/RunCMake/CompileFeatures/CMP0128OldSameStandard-build-check.cmake b/Tests/RunCMake/CompileFeatures/CMP0128OldSameStandard-build-check.cmake new file mode 100644 index 0000000..8074b9d --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/CMP0128OldSameStandard-build-check.cmake @@ -0,0 +1,12 @@ +foreach(flag @flags@) + string(FIND "${actual_stdout}" "${flag}" position) + + if(NOT position EQUAL -1) + set(found TRUE) + break() + endif() +endforeach() + +if(NOT found) + set(RunCMake_TEST_FAILED "No compile flags from \"@flags@\" found for LANG_STANDARD=default.") +endif() diff --git a/Tests/RunCMake/CompileFeatures/CMP0128OldSameStandard.cmake b/Tests/RunCMake/CompileFeatures/CMP0128OldSameStandard.cmake new file mode 100644 index 0000000..3be0f10 --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/CMP0128OldSameStandard.cmake @@ -0,0 +1 @@ +set(CMAKE_@lang@_STANDARD @standard_default@) diff --git a/Tests/RunCMake/CompileFeatures/CMP0128WarnMatch.cmake b/Tests/RunCMake/CompileFeatures/CMP0128WarnMatch.cmake index 0a5606a..7974093 100644 --- a/Tests/RunCMake/CompileFeatures/CMP0128WarnMatch.cmake +++ b/Tests/RunCMake/CompileFeatures/CMP0128WarnMatch.cmake @@ -1,7 +1,5 @@ -enable_language(@lang@) cmake_policy(SET CMP0128 OLD) set(CMAKE_POLICY_WARNING_CMP0128 ON) set(CMAKE_@lang@_EXTENSIONS @extensions_default@) set(CMAKE_@lang@_STANDARD @standard_default@) -add_library(foo "@RunCMake_SOURCE_DIR@/empty.@ext@") diff --git a/Tests/RunCMake/CompileFeatures/CMP0128WarnUnset.cmake b/Tests/RunCMake/CompileFeatures/CMP0128WarnUnset.cmake index cd7af2c..33425a1 100644 --- a/Tests/RunCMake/CompileFeatures/CMP0128WarnUnset.cmake +++ b/Tests/RunCMake/CompileFeatures/CMP0128WarnUnset.cmake @@ -1,6 +1,4 @@ -enable_language(@lang@) cmake_policy(SET CMP0128 OLD) set(CMAKE_POLICY_WARNING_CMP0128 ON) set(CMAKE_@lang@_EXTENSIONS @extensions_opposite@) -add_library(foo "@RunCMake_SOURCE_DIR@/empty.@ext@") diff --git a/Tests/RunCMake/CompileFeatures/ExtensionsStandardDefault.cmake b/Tests/RunCMake/CompileFeatures/ExtensionsStandardDefault.cmake deleted file mode 100644 index 32578d1..0000000 --- a/Tests/RunCMake/CompileFeatures/ExtensionsStandardDefault.cmake +++ /dev/null @@ -1,9 +0,0 @@ -enable_language(@lang@) - -# Make sure the compile command is not hidden. -string(REPLACE "${CMAKE_START_TEMP_FILE}" "" CMAKE_@lang@_COMPILE_OBJECT "${CMAKE_@lang@_COMPILE_OBJECT}") -string(REPLACE "${CMAKE_END_TEMP_FILE}" "" CMAKE_@lang@_COMPILE_OBJECT "${CMAKE_@lang@_COMPILE_OBJECT}") - -set(CMAKE_@lang@_EXTENSIONS @extensions_opposite@) -set(CMAKE_@lang@_STANDARD @standard_default@) -add_library(foo "@RunCMake_SOURCE_DIR@/empty.@ext@") diff --git a/Tests/RunCMake/CompileFeatures/NoUnnecessaryFlag.cmake b/Tests/RunCMake/CompileFeatures/NoUnnecessaryFlag.cmake deleted file mode 100644 index 8ef3a72..0000000 --- a/Tests/RunCMake/CompileFeatures/NoUnnecessaryFlag.cmake +++ /dev/null @@ -1,9 +0,0 @@ -enable_language(@lang@) - -# Make sure the compile command is not hidden. -string(REPLACE "${CMAKE_START_TEMP_FILE}" "" CMAKE_@lang@_COMPILE_OBJECT "${CMAKE_@lang@_COMPILE_OBJECT}") -string(REPLACE "${CMAKE_END_TEMP_FILE}" "" CMAKE_@lang@_COMPILE_OBJECT "${CMAKE_@lang@_COMPILE_OBJECT}") - -set(CMAKE_@lang@_EXTENSIONS @extensions_default@) -set(CMAKE_@lang@_STANDARD @standard_default@) -add_library(foo "@RunCMake_SOURCE_DIR@/empty.@ext@") diff --git a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake index ebd981b..ad9619e 100644 --- a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake +++ b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake @@ -35,11 +35,13 @@ elseif (cxx_std_98 IN_LIST CXX_FEATURES AND cxx_std_11 IN_LIST CXX_FEATURES) endif() configure_file("${RunCMake_SOURCE_DIR}/CMakeLists.txt" "${RunCMake_BINARY_DIR}/CMakeLists.txt" COPYONLY) +file(READ "${RunCMake_SOURCE_DIR}/CMP0128Common.cmake" cmp0128_common) function(test_build) set(test ${name}-${lang}) - configure_file("${RunCMake_SOURCE_DIR}/${name}.cmake" "${RunCMake_BINARY_DIR}/${test}.cmake" @ONLY) + file(READ "${RunCMake_SOURCE_DIR}/${name}.cmake" cmake) + file(CONFIGURE OUTPUT "${RunCMake_BINARY_DIR}/${test}.cmake" CONTENT "${cmake}${cmp0128_common}" @ONLY) if(EXISTS "${RunCMake_SOURCE_DIR}/${name}-build-check.cmake") configure_file("${RunCMake_SOURCE_DIR}/${name}-build-check.cmake" "${RunCMake_BINARY_DIR}/${test}-build-check.cmake" @ONLY) endif() @@ -68,7 +70,24 @@ macro(mangle_flags variable) list(APPEND flags "${result}") endmacro() -function(test_extensions_opposite) +function(test_cmp0128_old_same_standard) + if(extensions_default) + set(flag_ext "_EXT") + endif() + + set(flag "${${lang}${${lang}_STANDARD_DEFAULT}${flag_ext}_FLAG}") + + if(NOT flag) + return() + endif() + + mangle_flags(flag) + + set(name CMP0128OldSameStandard) + test_build(--verbose) +endfunction() + +function(test_cmp0128_new_extensions_opposite) if(extensions_opposite) set(flag_ext "_EXT") endif() @@ -83,16 +102,16 @@ function(test_extensions_opposite) # Make sure we enable/disable extensions when: # 1. LANG_STANDARD is unset. - set(name ExtensionsStandardUnset) + set(name CMP0128NewExtensionsStandardUnset) set(RunCMake_TEST_OPTIONS -DCMAKE_POLICY_DEFAULT_CMP0128=NEW) test_build(--verbose) # 2. LANG_STANDARD matches CMAKE_LANG_STANDARD_DEFAULT. - set(name ExtensionsStandardDefault) + set(name CMP0128NewExtensionsStandardDefault) test_build(--verbose) endfunction() -function(test_no_unnecessary_flag) +function(test_cmp0128_new_no_unnecessary_flag) set(standard_flag "${${lang}${${lang}_STANDARD_DEFAULT}_FLAG}") set(extension_flag "${${lang}${${lang}_STANDARD_DEFAULT}_EXT_FLAG}") @@ -103,7 +122,7 @@ function(test_no_unnecessary_flag) mangle_flags(standard_flag) mangle_flags(extension_flag) - set(name NoUnnecessaryFlag) + set(name CMP0128NewNoUnnecessaryFlag) set(RunCMake_TEST_OPTIONS -DCMAKE_POLICY_DEFAULT_CMP0128=NEW) test_build(--verbose) endfunction() @@ -144,8 +163,9 @@ function(test_lang lang ext) set(extensions_opposite ON) endif() - test_extensions_opposite() - test_no_unnecessary_flag() + test_cmp0128_new_extensions_opposite() + test_cmp0128_new_no_unnecessary_flag() + test_cmp0128_old_same_standard() test_cmp0128_warn_match() test_cmp0128_warn_unset() endfunction() |