![]() This was more granular than asking for a C++ version, though it's a bit tricky to pick out just the features a package is using unless you wrote the package and have a good memory. You can ask for specific compiler features to be available. It's really just a more advanced version of the following method, so it interacts nicely with that, too. If a target further down the dependency chain specifies a higher C++ level, this interacts nicely. The first line even works on INTERFACE targets only actual compiled targets can use the second line. The second line is optional, but will avoid extensions being added without it you'd get things like -std=g++11 replacing -std=c++11. Set_target_properties(myTarget PROPERTIES CXX_EXTENSIONS OFF)įor the first line, we get to pick between cxx_std_11, cxx_std_14, and cxx_std_17. Assuming you have a target named myTarget, it looks like this: target_compile_features(myTarget PUBLIC cxx_std_11) This is the most powerful way, with the nicest syntax and the best support for new standards, and the best target behavior for mixing standards and options. CMake 3.8+: Meta compiler featuresĪs long as you can require that a user install CMake, you'll have access to the newest way to enable C++ standards. I'll start with that, since this is Modern CMake. And as you'll soon see, there's even better support in CMake 3.8+. As long as you are using CMake 3.1 or newer, you should be fine, there are two different ways to enable support. Just not in CMake 2.8, because, guess what, C++11 didn't exist in 2009 when 2.0 was released.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |