diff options
-rw-r--r-- | Help/release/3.22.rst | 6 | ||||
-rw-r--r-- | Source/cmStandardLevelResolver.cxx | 5 | ||||
-rw-r--r-- | Tests/RunCMake/CompileFeatures/CMP0128OldSameStandard-build-check.cmake | 12 | ||||
-rw-r--r-- | Tests/RunCMake/CompileFeatures/CMP0128OldSameStandard.cmake | 1 | ||||
-rw-r--r-- | Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake | 18 |
5 files changed, 40 insertions, 2 deletions
diff --git a/Help/release/3.22.rst b/Help/release/3.22.rst index fcb655d..4cc34fa 100644 --- a/Help/release/3.22.rst +++ b/Help/release/3.22.rst @@ -142,3 +142,9 @@ Other Changes This became available as of VS 16.10 (toolchain version 14.29.30037). * The :cpack_gen:`CPack NSIS Generator` now requires NSIS 3.03 or later. + +3.22.2 +------ + +* The ``OLD`` behavior of :policy:`CMP0128` was fixed to add flags even when + the specified standard matches the compiler default. diff --git a/Source/cmStandardLevelResolver.cxx b/Source/cmStandardLevelResolver.cxx index 61416e0..acc2ed2 100644 --- a/Source/cmStandardLevelResolver.cxx +++ b/Source/cmStandardLevelResolver.cxx @@ -206,8 +206,9 @@ struct StandardLevelComputer // If the standard requested is older than the compiler's default or the // extension mode doesn't match then we need to use a flag. - if (stdIt < defaultStdIt || - (cmp0128 == cmPolicies::NEW && ext != defaultExt)) { + if ((cmp0128 != cmPolicies::NEW && stdIt <= defaultStdIt) || + (cmp0128 == cmPolicies::NEW && + (stdIt < defaultStdIt || ext != defaultExt))) { auto offset = std::distance(cm::cbegin(stds), stdIt); return cmStrCat("CMAKE_", this->Language, stdsStrings[offset], "_", type, "_COMPILE_OPTION"); 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/RunCMakeTest.cmake b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake index 35b01e3..ad9619e 100644 --- a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake +++ b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake @@ -70,6 +70,23 @@ macro(mangle_flags variable) list(APPEND flags "${result}") endmacro() +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") @@ -148,6 +165,7 @@ function(test_lang lang ext) 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() |