CMake version recommendations and install
CMake ≥ 3.24 is recommended for general users. Downloading the latest release of CMake is usually easy. Admin / sudo is not required.
- Linux:
snap install cmake
- macOS: brew install cmake
- Windows:
winget install Kitware.CMake
- PyPI CMake package:
python -m pip install cmake
For platforms where CMake binaries aren’t easily available, build CMake using scripts/build_cmake.cmake.
To see the merge requests for a certain release, use a URL like: https://gitlab.kitware.com/cmake/cmake/-/merge_requests?milestone_title=3.32.0&scope=all&state=all
CMake 3.32 enables
CMAKE_LINK_WARNING_AS_ERROR
boolean option sets most compilers to error if a compile warning occurs, which is generally a good setting for CI systems.
target_link_libraries()
can use a LINKER:
prefix to abstract options.
CTest
–interactive-debug-mode
is particularly useful on Windows to enable debug dumps and error popup windows.
CMake
3.31
warns if cmake_minimum_required()
is
< 3.10.
TLS ≥ 1.2 is required by default for internet operations e.g. file(DOWNLOAD)
, ExternalProject, FetchContent, and similar.
file(ARCHIVE_CREATE)
gained a long-needed WORKING_DIRECTORY
parameter that is essentially necessary to avoid machine-specific paths being embedded in the archive.
CMAKE_LINK_LIBRARIES_STRATEGY
allows specifying a strategy for ordering target direct link dependencies.
CMake 3.30 adds C++26 support. CMAKE_TLS_VERIFY environment variable was added to set TLS verification (true, false). CMake 3.31 defaults CMAKE_TLS_VERIFY to on, where previously it was off.
CMake 3.29 adds cmake_language(EXIT code) to exit CMake script mode with a specific return code. This is useful when using CMake as a platform-agnostic scripting language instead of shell script.
Environment variable
CMAKE_INSTALL_PREFIX
is used to set the default install prefix across projects–it can be overridden as typical by cmake -DCMAKE_INSTALL_PREFIX=
option.
Target property TEST_LAUNCHER allows specifying a test launcher. For MPI program this allows deduplicating or making more programmatic test runner scripts.
Linker information variables including
CMAKE_target_link_options()
based on the particular linker.
ctest --parallel
without a number or 0
will use unbounded
test run parallelism.
CMake
3.28
changes PATH behavior for
Windows find_{library,path,file}()
to no longer search PATH.
This may break some projects that rely on PATH for finding libraries.
The MSYS2-distributed CMake is patched to include PATH like earlier CMake, which can be confusing for CI etc. not using MSYS CMake with that patch.
Windows CI/user may need to specify CMAKE_PREFIX_PATH
like
cmake -DCMAKE_PREFIX_PATH=$Env:SYSTEMDRIVE/msys64/ucrt64/lib -B build
Support for C++20 modules is considerably improved and most users will want at least CMake 3.28 to make C++ modules usable.
Generator expressions $<IF> $<AND> $<OR>
now short circuit.
Test properties now have a DIRECTORY
parameter, useful for setting test parameters from the project’s top level CMakeLists.txt.
CMake 3.28.4 fixed a long-standing bug in Ninja Fortran targets that use include
statements.
CMake
3.27
emits warning for
cmake_minimum_required(VERSION)
< 3.5.
CTest test properties
TIMEOUT_SIGNAL_NAME
and
TIMEOUT_SIGNAL_GRACE_PERIOD
specify a POSIX signal to send to a timed out test process.
Interactive CMake debugger added by
cmake --debugger
is used with an IDE such as
Visual Studio.
CMake script command
cmake_file_api()
allows querying CMake
File API
from within CMake.
NOTE: Fortran + Ninja was broken for OBJECT libraries in CMake 3.27.0..3.27.8 and fixed in 3.27.9.