Adding general C++20 support #177
-
I am trying to do a C++20 Modules test. I have figured out a way in CMAKE to add the module flag. What would be the easier and/or the best way to switch to C++20? See this fork for some of the stuff I have tried: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
From your own root level CMakeLists.txt: target_compile_features(project_options INTERFACE cxx_std_20) This is the correct way to set the If you want to confirm that the flag is set properly, you can use cmake -S . -B ./build -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON I don't know anything about adding C++20 module support; last time I checked, there weren't any compilers that had fully implemented the feature yet. You may need to check that your compiler supports this feature. |
Beta Was this translation helpful? Give feedback.
From your own root level CMakeLists.txt:
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 tocmake
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…