# Query about policy CMP0128

**URL:** https://discourse.cmake.org/t/query-about-policy-cmp0128/14386
**Category:** Usage
**Created:** [July 17, 2025, 12:10pm UTC](https://discourse.cmake.org/t/query-about-policy-cmp0128/14386 "2025-07-17T12:10:24Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Chardrazle](https://discourse.cmake.org/user_avatar/discourse.cmake.org/chardrazle/32/4362_2.png) [@Chardrazle](https://discourse.cmake.org/u/Chardrazle)
#### Post date: [July 17, 2025, 12:10pm UTC](https://discourse.cmake.org/t/query-about-policy-cmp0128/14386/1 "2025-07-17T12:10:25Z")

</div>

We recently ran into an issue when the _cmake\_minimum\_required_ was bumped above 3.21, and policy CMP0128 came into force.  
There were common project settings with:

```auto
  set(CMAKE_CXX_STANDARD 20)
  set(CMAKE_CXX_EXTENSIONS OFF)

```

The compiler in use was g++ version 7.4.

Pre-CMP0128 this resulted in the “-std=c++1z” compile flag being added (to the compiler invocation).  
Post-CMP0128 this is not emitted.

The [documentation](https://cmake.org/cmake/help/latest/policy/CMP0128.html) says that “Extensions are correctly enabled/disabled […]”, but also states: " \* Standard mode-affecting flags aren’t added unless necessary to achieve the specified mode."

So is this now considered an extension (the former statement, rather than the latter)?

This was useful to “let cmake figure out the most supported standard for the compiler”.  
Is disabling the policy the way to achieve this, now? (loathe to do…)

---

<div class="post-metadata">

### Author: ![vito.gamberini](https://discourse.cmake.org/user_avatar/discourse.cmake.org/vito.gamberini/32/4376_2.png) [@vito.gamberini](https://discourse.cmake.org/u/vito.gamberini)
#### Post date: [July 17, 2025, 4:16pm UTC](https://discourse.cmake.org/t/query-about-policy-cmp0128/14386/2 "2025-07-17T16:16:01Z")

</div>

GCC 7.4 has no support for C++20 whatsoever, with `CMP0128` set to `NEW` CMake correctly gives up when there’s no flags it knows about to achieve the requested behavior. It assumes the user producing the build knows something about the compiler it does not.

Setting `CMAKE_CXX_STANDARD` to `17` will get you the `-std=c++1z` flag. Alternatively, upgrading to a GCC version `>= 8.0` will get you the `-std=c++2a` the current configuration is asking for.

---

<div class="post-metadata">

### Author: ![Chardrazle](https://discourse.cmake.org/user_avatar/discourse.cmake.org/chardrazle/32/4362_2.png) [@Chardrazle](https://discourse.cmake.org/u/Chardrazle)
#### Post date: [July 17, 2025, 5:05pm UTC](https://discourse.cmake.org/t/query-about-policy-cmp0128/14386/3 "2025-07-17T17:05:08Z")

</div>

The codebase is actually cross compiled for several platforms, so different versions of gcc come into play (via toolchain files for each platform). Some features of C++20 are conditionally used in shared parts.

However, a common file for compiler settings is used so it was just convenient (and self maintaining) when cmake popped in the closest it could. Although it sounds like it may not have been doing that (hence the policy).

Thanks for the response and clarifying.

---

<div class="post-metadata">

### Author: ![Chardrazle](https://discourse.cmake.org/user_avatar/discourse.cmake.org/chardrazle/32/4362_2.png) [@Chardrazle](https://discourse.cmake.org/u/Chardrazle)
#### Post date: [July 23, 2025, 7:34pm UTC](https://discourse.cmake.org/t/query-about-policy-cmp0128/14386/4 "2025-07-23T19:34:56Z")

</div>

Should anyone stumble across this with a similar requirement, it is achievable.  
See [this comment](https://gitlab.kitware.com/cmake/cmake/-/issues/22656#note_1682547) and associated links.
