summaryrefslogtreecommitdiffstats
path: root/Source/cmStandardLevelResolver.cxx
diff options
context:
space:
mode:
authorRaul Tambre <raul@tambre.ee>2022-01-22 15:29:45 (GMT)
committerRaul Tambre <raul@tambre.ee>2022-01-23 21:10:28 (GMT)
commitee1396e29e98dbd3a4517ce364a534c80bc6fb4a (patch)
tree4733f62457243d208594a854e42ec0f5e1424943 /Source/cmStandardLevelResolver.cxx
parentb2c25de8e0e2d53d3ff2ad37ed33d4b8a9bf8b1a (diff)
downloadCMake-ee1396e29e98dbd3a4517ce364a534c80bc6fb4a.zip
CMake-ee1396e29e98dbd3a4517ce364a534c80bc6fb4a.tar.gz
CMake-ee1396e29e98dbd3a4517ce364a534c80bc6fb4a.tar.bz2
CMP0128: Add flag in OLD mode even when standard matches the default
Commit 4a0485be (cmStandardLevelResolver: Avoid unnecessary flags, fix unset level logic, 2021-04-29) unintentionally changed the behavior by modifying the code to match a pre-existing comment. The resulting behavior change however matches the intentions of CMP0128, so we simply need to guard it. Fixes #23122.
Diffstat (limited to 'Source/cmStandardLevelResolver.cxx')
-rw-r--r--Source/cmStandardLevelResolver.cxx5
1 files changed, 3 insertions, 2 deletions
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");