
Cmake target code#
The relvant code is here In fact our test scripts do what you suggested, using -DCMAKE_CXX_STANDARD in the command line.īut this is a problem in a library like abseil which changes depending on language level. We don't set CMAKE_CXX_STANDARD, we only read it. Or both are using a different version and everything is blowing up in your face. How do you propose to do this besides the standard mechanism in CMake?Įither the library and the application happen to use the same c++ version and doing a set CMAKE_CXX_STANDARD in the library cmake file is redundant, The only thing a library cmake file should do is a target_compile_features(mylib PUBLIC cxx_std_11) to state the minimum language version it needs. for testing and ci) in the command line command that invokes cmake( cmake -DCMAKE_CXX_STANDARD=17. ) ) or even better in the toolchain file that is used to build all the applications and libraries or (e.g. Set CMAKE_CXX_STANDARD belongs either in the top level cmake file of the Application (if the libraries are added via add_subdirectory(.

or both are using a different version and everything is blowing up in your face.

Either the library and the application happen to use the same c++ version and doing a set CMAKE_CXX_STANDARD in the library cmake file is redundant,.Especially if your API changes depending on the language level, then the used standard is something that you should simply adopt from the project abseil is used from. If I may make a comment on this: In my experience this is the absolutely wrong approach for a library.

The correct way to set the language level for abseil is to set CMAKE_CXX_STANDARD to 11, 14, or 17.
