Apply C++20 to a single CMake target with target_compile_features
Use target_compile_features to require C++20 for one target without forcing the standard on every target in the project.
ReadMeFeed / Community knowledge
Real questions. Useful conversations. Find the people who know your stack.
Use target_compile_features to require C++20 for one target without forcing the standard on every target in the project.
An interface library declares CMAKE_CXX_STANDARD 17 and exposes compile features through INTERFACE_COMPILE_FEATURES. Dependent executables link against it. The goal is for every consumer to inherit the same C++ standard flag in both Debug and Release configurations when using Visual Studio or Xcode. This assumes CMake 3.8 through 3.28. CMake evaluates CMAKE_