Craig Scott Cmake

  1. Craig Scott Attorney Columbus Ohio
  2. Craig Scott Professional Cmake
  3. Professional Cmake Craig Scott

Chapters 25 Installing and 26 Packaging of Craig Scott’s excellent book Professional CMake – A Practical Guide (5th edition) helped me a lot in writing this post. Cmake cpack installer update Post navigation. Craig Scott (4): cmComputeLinkInformation: Fix misspelt private variable name Xcode: Don’t hard-code SDK-provided implicit framework search paths IOSINSTALLCOMBINED: Support Xcode 12 (command line only) Help: Add 3.19.5 release notes for Xcode iOS-related changes. Robert Maynard (1).

Craig scott wiki

C++11 is supported by CMake. Really. Just not in CMake 2.8, because, guess what, C++11 didn't exist in 2009 when 2.0 was released. As long as you are using CMake 3.1 or newer, you should be fine, there are two different ways to enable support. And as you'll soon see, there's even better support in CMake 3.8+. I'll start with that, since this is Modern CMake.

CMake 3.8+: Meta compiler features

Craig Scott Attorney Columbus Ohio

As long as you can require that a user install CMake, you'll have access to the newest way to enable C++ standards. 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. Assuming you have a target named myTarget, it looks like this:

For the first line, we get to pick between cxx_std_11, cxx_std_14, and cxx_std_17. 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. The first line even works on INTERFACE targets; only actual compiled targets can use the second line.

If a target further down the dependency chain specifies a higher C++ level, this interacts nicely. It's really just a more advanced version of the following method, so it interacts nicely with that, too.

CMake 3.1+: Compiler features

You can ask for specific compiler features to be available. 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. Since this ultimately checks against a list of options CMake knows your compiler supports and picks the highest flag indicated in that list, you don't have to specify all the options you need, just the rarest ones. The syntax is identical to the section above, you just have a list of options to pick instead of cxx_std_* options. See the whole list here.

If you have optional features, you can use the list CMAKE_CXX_COMPILE_FEATURES and use if(... IN_LIST ...) from CMake 3.3+ to see if that feature is supported, and add it conditionally. See the docs here for other use cases.

CMake 3.1+: Global and property settings

There is another way that C++ standards are supported; a specific set of three properties (both global and target level). The global properties are:

The first line sets a C++ standard level, and the second tells CMake to use it, and the final line is optional and ensures -std=c++11 vs. something like -std=g++11. This method isn't bad for a final package, but shouldn't be used by a library. You should always set this as a cached variable, so you can override it to try a new version easily (or if this gets used as a library, this is the only way to override it - but again, don't use this for libraries). You can also set these values on a target:

Which is better, but still doesn't have the sort of explicit control that compiler features have for populating PRIVATE and INTERFACE properties, so it really is only useful on final targets.

You can find more information about the final two methods on Craig Scott's useful blog post.

Don't set manual flags yourself. You'll then become responsible for mainting correct flags for every release of every compiler, error messages for unsupported compilers won't be useful, and some IDEs might not pick up the manual flags.

We are pleased to announce that CMake 3.20.2 is now available for download.

Craig Scott Professional Cmake

Please use the latest release from our download page:

Thanks for your support!

Changes made since CMake 3.20.1:

Ben Boeckel (2):

  • ci: pay attention to the machine load when running tests
  • ci: limit builds by machine load

Brad King (8):

  • Help: Add 3.20 release note for error on unknown arguments
  • gitlab-ci: equally delay all jobs on integration branches
  • Autogen: Restore mocs_compilation in OBJECT libraries
  • Help: Fix typos in cmake-compile-features(7)
  • Help: Do not recommend WCDH in cmake-compile-features(7)
  • Intel: Update Classic compiler version detection for 2021
  • IntelLLVM: Add special case for ifx 2021.1 version extraction
  • CMake 3.20.2

Professional Cmake Craig Scott

Craig Scott (2):

  • Help: Behavior of file(TO_NATIVE_PATH) depends on the host platform
  • Help: Document special cases for if(IS_ABSOLUTE)

Joel Johnson (1):

  • Add missing ‘not’ in error messages

KWIML Upstream (1):

  • KWIML 2021-04-21 (49d91529)

Kyle Edwards (2):

  • autogen: fix race in depfile parsing
  • Ninja Multi-Config: Correctly generate POST_BUILD custom targets

Lihua Zhao (1):

  • BinUtils: Restore toolchain prefix detection from compiler name ‘c++’

Rafael Sadowski (1):

  • OpenBSD: Fix system feature definitions