# set(CMAKE\_CXX\_STANDARD) adding 2 more commands, is that necessary ?

**URL:** https://discourse.cmake.org/t/set-cmake-cxx-standard-adding-2-more-commands-is-that-necessary/10134
**Category:** Usage
**Created:** [February 19, 2024, 8:50am UTC](https://discourse.cmake.org/t/set-cmake-cxx-standard-adding-2-more-commands-is-that-necessary/10134 "2024-02-19T08:50:42Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![WaltOnline](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/w/9dc877/32.png) [@WaltOnline](https://discourse.cmake.org/u/WaltOnline)
#### Post date: [February 19, 2024, 8:50am UTC](https://discourse.cmake.org/t/set-cmake-cxx-standard-adding-2-more-commands-is-that-necessary/10134/1 "2024-02-19T08:50:42Z")

</div>

Hi!  
I can set a latest C++ standard with  
set(CMAKE\_CXX\_STANDARD 23) or add\_compile\_options(“/std:c++latest”)  
I set verbose mode to see what it’s doing under the hood and  
In case of set(CMAKE\_CXX\_STANDARD 23) CMake build from Visual Studio launches 4 commands  
[1/4] is cl.exe with compile args  
[2/4] is cmake itself with -E cmake\_ninja\_dyndep and other commands  
[3/4] is another launch of cl.exe (for some reason)  
[4/4] and then another launch of cmake

while if setting latest standard like that in cmakelists file:  
add\_compile\_options(“/std:c++latest”)  
it launches only 2 commands cl.exe and cmake.  
or I can say it’s not double launching them , why such behavior ? Is that a bug/issue ?

Windows 11  
Visual Studio  
CMake 3.28

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [February 20, 2024, 11:54am UTC](https://discourse.cmake.org/t/set-cmake-cxx-standard-adding-2-more-commands-is-that-necessary/10134/2 "2024-02-20T11:54:57Z")

</div>

In the former, CMake knows that C++20 or newer is in effect and is performing module scanning commands. The `1/4` is a scanning command to extract `import` and `export` metadata needed for a proper build; `3/4` is the actual compile. When passing options to the compiler “behind CMake’s back” like `add_compile_options` does, CMake doesn’t know that modules are available and doesn’t perform the necessary steps.
