Release Date: 20th May 2025
This is part of the change history for the book Professional CMake: A Practical Guide. The 21st Edition has been updated for the CMake 4.0 release. A few new usability features were added to CMake, but the most significant change was the removal of all OLD
policy behaviours up to CMP0065
(i.e. all policies from CMake 3.4 and earlier). The Policies chapter of the book has been updated to give increased visibility to the policy life cycle, now that OLD
behaviours have been completely removed for the first time.
The other major update in this edition is a new Debugging Executables chapter. This contains previous material covering Windows only, but has now been expanded to cover corresponding features for Xcode and some IDE-independent improvements from CMake 4.0. The new chapter is structured to allow focusing on specific problems encountered when running and debugging executables in IDE tools.
In addition to the usual updates, the effort to review existing material, improve clarity, and add more examples continues in this edition. Chapters 19 to 21 have been reviewed and updated, as noted in the details below.
Basic Testing And Deployment chapter:
- Corrected a Ninja Multi-Config packaging example which previously used
--config
instead of-C
to specify the configuration to package (Release
). - Added a paragraph to highlight the inconsistency between
cmake
,ctest
, andcpack
where they use different options to specify the configuration (--config
or-C
) .
Policies chapter:
- Added a new Policy Removal section which covers CMake’s formal policy removal timeline. CMake 4.0 was the first release to completely remove a set of OLD policies and to formally document expectations around future removals.
- Broke up the Policy Control section into subsections for improved navigation.
- Moved and expanded content to a new Overriding Policy Defaults And Warnings section. CMake 4.0 added a new
CMAKE_POLICY_VERSION_MINIMUM
variable to assist with the migration of older projects that still have not been updated toNEW
policy settings where theOLD
behavior is no longer available.
Debugging And Diagnostics chapter:
- Added a note at the beginning of the chapter directing attention to the new Debugging Executables chapter for debugging code rather than CMake scripts.
Compiler And Linker Essentials chapter:
- CMake 4.0 added support for a new
ARCHIVER:
prefix, which can be used with theSTATIC_LIBRARY_OPTIONS
target property. CMake 4.0 also extended support for theLINKER:
prefix to theLINK_LIBRARIES
andINTERFACE_LINK_LIBRARIES
target properties. The Linker Flags and De-duplicating Options sections were updated accordingly. - CMake 4.0 added a new
LINK_WARNING_AS_ERROR
target property, an associatedCMAKE_LINK_WARNING_AS_ERROR
variable, and a--link-no-warning-as-error
command line option. These are now covered in the Warnings As Errors section. - A new Runtime Checks Selection subsection was added to the Compiler Option Abstractions section. This discusses a new feature in CMake 4.0 which abstracts the
/RTC...
set of compiler flags when using the Visual Studio compilers. - Fixed an error in the example within the Debug Information Format Selection section. The
PROPERTIES
keyword was missing from theset_target_properties()
call in earlier editions.
Language Requirements chapter:
- This chapter was reviewed and wording improved in various places. Most changes were relatively minor grammatical improvements, with a few paragraphs being merged or reworked more substantially.
- A new example was added to the Requirements For C++20 Modules section, showing how to set source file properties to disable scanning specific files for C++20 modules.
Advanced Linking chapter:
- This chapter was reviewed, but no significant changes were made.
Target Types chapter:
- This chapter was reviewed, and some minor improvements were made to readability. A few paragraphs in the Imported Libraries section were moved to the end of that section for improved logical flow.
Custom Tasks chapter:
- A new
INSTALL_JOB_SERVER_AWARE
keyword was added toExternalProject_Add()
in CMake 4.0, and this is now mentioned very briefly with theJOB_SERVER_AWARE
keyword in the Custom Targets section. - CMake 4.0 added a new
CMAKE_EXECUTE_PROCESS_COMMAND_ERROR_IS_FATAL
variable, which affects the default behavior ofexecute_process()
when a command fails.
Package Generators chapter:
- CMake 4.0 added support for a
TAR
package format with no compression.
Project Structure chapter:
- Updated a paragraph in the Target Output Locations section to mention
PROJECT_BINARY_DIR
as another alternative toCMAKE_CURRENT_BINARY_DIR
as preferred relative base directories overCMAKE_BINARY_DIR
. - Move the Windows-specific Issues section content out to the new Debugging Executables chapter. The associated comments in the Recommended Practices section were also moved to that chapter.
Debugging Executables chapter:
- This is a new chapter focused on the task of running executables in IDEs. Some of the content is moved from the Windows-specific Issues section of the Project Structure chapter. That content has been expanded to also cover equivalent features for Xcode.
- The new
DEBUGGER_WORKING_DIRECTORY
target property added in CMake 4.0 is discussed prominently, including its relationship to the existingVS_DEBUGGER_WORKING_DIRECTORY
andXCODE_SCHEME_WORKING_DIRECTORY
target properties.