Visual Studio: select /std:c++23preview or /std:c++latest ?

How do I select among the options /std:c++23preview and /std:c++latest in Visual Studio. I currently have:

set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

and this results in “/std:c++latest” in my generated project (both in Visual Studio 2022, and in 2026). I have not been able to get " /std:c++23preview" via setting variables like above in CMake. I guess it should be possible, but I haven’t succeeded yet.

I have tried with CMake 4.2.1 and setting cmake_minimum_required(VERSION 4.2) too, suspecting that it should have an effect too.

Have I missed some obvious detail?

1 Like