Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Adding general C++20 support #177

Answered by ddalcino
Neuromancer2701 asked this question in Q&A
Discussion options

You must be logged in to vote

From your own root level CMakeLists.txt:

target_compile_features(project_options INTERFACE cxx_std_20)

This is the correct way to set the -std=c++20 flag in a CMake project (see CMake docs). There is a CMAKE_CXX_FLAGS variable that you can play with, but it's not the accepted "best practice" way to do things.

If you want to confirm that the flag is set properly, you can use -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON as an argument to cmake during the configure step. This will turn on verbose mode, which will print every compile command so that you can see what flags are being passed to the compiler:

cmake -S . -B ./build -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON

I don't know anything about adding C++20 modu…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by aminya
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants