diff options
Diffstat (limited to 'Tests/RunCMake')
-rw-r--r-- | Tests/RunCMake/CompileFeatures/ExtensionsStandardDefault-build-check.cmake | 12 | ||||
-rw-r--r-- | Tests/RunCMake/CompileFeatures/ExtensionsStandardDefault.cmake | 9 | ||||
-rw-r--r-- | Tests/RunCMake/CompileFeatures/ExtensionsStandardUnset-build-check.cmake (renamed from Tests/RunCMake/CompileFeatures/UnsetStandard-build-check.cmake) | 0 | ||||
-rw-r--r-- | Tests/RunCMake/CompileFeatures/ExtensionsStandardUnset.cmake (renamed from Tests/RunCMake/CompileFeatures/UnsetStandard.cmake) | 0 | ||||
-rw-r--r-- | Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake | 16 |
5 files changed, 32 insertions, 5 deletions
diff --git a/Tests/RunCMake/CompileFeatures/ExtensionsStandardDefault-build-check.cmake b/Tests/RunCMake/CompileFeatures/ExtensionsStandardDefault-build-check.cmake new file mode 100644 index 0000000..4e85397 --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/ExtensionsStandardDefault-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 and @lang@_EXTENSIONS=@extensions_opposite@.") +endif() diff --git a/Tests/RunCMake/CompileFeatures/ExtensionsStandardDefault.cmake b/Tests/RunCMake/CompileFeatures/ExtensionsStandardDefault.cmake new file mode 100644 index 0000000..32578d1 --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/ExtensionsStandardDefault.cmake @@ -0,0 +1,9 @@ +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/UnsetStandard-build-check.cmake b/Tests/RunCMake/CompileFeatures/ExtensionsStandardUnset-build-check.cmake index abe293c..abe293c 100644 --- a/Tests/RunCMake/CompileFeatures/UnsetStandard-build-check.cmake +++ b/Tests/RunCMake/CompileFeatures/ExtensionsStandardUnset-build-check.cmake diff --git a/Tests/RunCMake/CompileFeatures/UnsetStandard.cmake b/Tests/RunCMake/CompileFeatures/ExtensionsStandardUnset.cmake index 99bb3f0..99bb3f0 100644 --- a/Tests/RunCMake/CompileFeatures/UnsetStandard.cmake +++ b/Tests/RunCMake/CompileFeatures/ExtensionsStandardUnset.cmake diff --git a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake index 3bfd211..ebd981b 100644 --- a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake +++ b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake @@ -36,7 +36,7 @@ endif() configure_file("${RunCMake_SOURCE_DIR}/CMakeLists.txt" "${RunCMake_BINARY_DIR}/CMakeLists.txt" COPYONLY) -macro(test_build) +function(test_build) set(test ${name}-${lang}) configure_file("${RunCMake_SOURCE_DIR}/${name}.cmake" "${RunCMake_BINARY_DIR}/${test}.cmake" @ONLY) @@ -52,7 +52,7 @@ macro(test_build) run_cmake(${test}) set(RunCMake_TEST_NO_CLEAN 1) run_cmake_command(${test}-build ${CMAKE_COMMAND} --build . ${ARGN}) -endmacro() +endfunction() # Mangle flags such as they're in verbose build output. macro(mangle_flags variable) @@ -68,7 +68,7 @@ macro(mangle_flags variable) list(APPEND flags "${result}") endmacro() -function(test_unset_standard) +function(test_extensions_opposite) if(extensions_opposite) set(flag_ext "_EXT") endif() @@ -81,9 +81,15 @@ function(test_unset_standard) mangle_flags(flag) - set(name UnsetStandard) + # Make sure we enable/disable extensions when: + # 1. LANG_STANDARD is unset. + set(name ExtensionsStandardUnset) set(RunCMake_TEST_OPTIONS -DCMAKE_POLICY_DEFAULT_CMP0128=NEW) test_build(--verbose) + + # 2. LANG_STANDARD matches CMAKE_LANG_STANDARD_DEFAULT. + set(name ExtensionsStandardDefault) + test_build(--verbose) endfunction() function(test_no_unnecessary_flag) @@ -138,7 +144,7 @@ function(test_lang lang ext) set(extensions_opposite ON) endif() - test_unset_standard() + test_extensions_opposite() test_no_unnecessary_flag() test_cmp0128_warn_match() test_cmp0128_warn_unset() |