Professional CMake:

A Practical Guide

Learn to use CMake effectively with practical advice from a CMake co-maintainer. You can also have the author work directly with your team!

Professional CMake: A Practical Guide 3rd Edition

Release Date: 15th March 2019

This is part of the change history for the book Professional CMake: A Practical Guide. The 3rd Edition has been updated for the CMake 3.14.0 release and also contains some other minor improvements. The following lists the main changes in this edition.


Flow Control chapter:

  • New for CMake 3.14, the if() command can now check specifically whether a variable is a cache variable using if(CACHE{name}).

Modules chapter:

  • New for CMake 3.14, the try_compile() command now supports link options through the new CMAKE_REQUIRED_LINK_OPTIONS variable.
  • The new CheckFortranSourceRuns module added in CMake 3.14 is now mentioned and has been added to the existing examples for C and C++.

Target Types chapter:

  • Added comments about fixes in CMake 3.14 for transitive behavior of object libraries.
  • Added brief comment that the name of an exported target can be different to the original.

Working With Files chapter:

  • New NAME_WLE and LAST_EXT options added in CMake 3.14 for get_filename_component().
  • New file() subcommands READ_SYMLINK, CREATE_LINK and SIZE added in CMake 3.14.

Toolchains And Cross Compiling chapter:

  • Added comment regarding new support in CMake 3.14 for iOS, watchOS and tvOS as CMAKE_SYSTEM_NAME values.
  • Fixed an example where a generator expression was split across multiple lines.
  • Added notes highlighting that Android NDK r19 breaks CMake’s built-in Android support.

Apple chapter:

  • New for CMake 3.14, the target Apple platform can now be selected by setting CMAKE_SYSTEM_NAME to  iOS, watchOS and tvOS.
  • Corrected and expanded statements about how CMAKE_XCODE_ATTRIBUTE_XXX variables and XCODE_ATTRIBUTE_XXX target properties relate to each other and where the variable will and won’t have any effect.
  • Cleaned up discussion of provisioning and added material covering manual provisioning with the XCODE_ATTRIBUTE_PROVISIONING_PROFILE_SPECIFIER target property.
  • With CMake 3.14, code signing is no longer needed or used in try_compile() tests. Combined with the new CMAKE_SYSTEM_NAME support, toolchain files are no longer needed for iOS, watchOS or tvOS.
  • Clarified some comments in the Recommendations section around the use of the CMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH and CMAKE_OSX_ARCHITECTURES variables.

Finding Things chapter:

  • Clarified the interaction of QUIET and REQUIRED options to find_package().

Testing chapter:

  • Added a brief mention of the ctest --progress option added in CMake 3.13.
  • New for CMake 3.14, the CTest module now supports a CTEST_SUBMIT_URL variable for more convenient dashboard URL definition.
  • New for CMake 3.14, dashboard submissions now support a new Done part.

Installing chapter:

  • New for CMake 3.14, A number of install() commands now support a default destination based on GNUInstallDirs.
  • CMake 3.14 added a new BUILD_RPATH_USE_ORIGIN target property and an associated CMAKE_BUILD_RPATH_USE_ORIGIN variable.
  • Added discussion of the EXPORT_NAME target property to allow the exported target name to be different from the original target.
  • The order in which install() commands are used during an install has been made much clearer with CMake 3.14. Changes in behavior are noted with an example to illustrate.
  • CMake 3.14 added support for generator expressions within custom code or a custom script file name given to install().
  • A new ARCH_INDEPENDENT option was added to write_basic_package_version_file() in CMake 3.14.

External Content chapter:

  • CMake 3.14 added a new FetchContent_MakeAvailable() command for bringing in dependencies much more concisely.
  • CMake 3.14 added new LOG_DIR and LOG_MERGED_STDOUTERR options to ExternalProject_Add().
  • Added a brief note mentioning a drawback to the BUILD_ALWAYS option of ExternalProject_Add().

Project Organization chapter:

  • Updated discussion and examples to account for the new FetchContent_MakeAvailable() command added in CMake 3.14.
  • Updated examples to show how to use the EXPORT_NAME target property.