CMake 3.18 Release Notes

Changes made since CMake 3.17 include the following.

New Features

Languages

  • The CUDA language can now be compiled using Clang on non-Windows platforms. Separable compilation is not yet supported on any platform.

Command-Line

  • cmake(1) gained support for profiling of CMake scripts through the parameters --profiling-output and --profiling-format.

  • cmake(1) gained a cat command line option that can be used to concatenate files and print them on standard output.

Commands

  • The add_library() and add_executable() commands learned to create Alias Targets referencing non-GLOBAL Imported Targets.

  • The cmake_language() command was added for meta-operations on scripted or built-in commands, starting with a mode to CALL other commands, and EVAL CODE to inplace evaluate a CMake script.

  • The execute_process() command gained the ECHO_OUTPUT_VARIABLE and ECHO_ERROR_VARIABLE options.

  • The export() command now raise an error if used multiple times with same FILE without APPEND. See policy CMP0103.

  • The file() command gained the ARCHIVE_CREATE and ARCHIVE_EXTRACT subcommands to expose the cmake(1) -E tar functionality to CMake scripting code.

  • The file(CONFIGURE) subcommand was created in order to replicate the configure_file() functionality without resorting to a pre-existing file on disk as input. The content is instead passed as a string.

  • The file(UPLOAD) command gained TLS_VERIFY and TLS_CAINFO options to control server certificate verification.

  • The find_program(), find_library(), find_path() and find_file() commands gained a new REQUIRED option that will stop processing with an error message if nothing is found.

  • The get_property() command with SOURCE scope gained the DIRECTORY and TARGET_DIRECTORY options to get a property from the provided directory scope.

  • The get_source_file_property() command gained the DIRECTORY and TARGET_DIRECTORY options to get a property from the provided directory scope.

  • The list() operation SORT gained the NATURAL sort option to sort using natural order (see strverscmp(3) manual).

  • The set_property() command with the SOURCE scope gained the DIRECTORY and TARGET_DIRECTORY options to set properties in the provided directory scopes.

  • The set_source_files_properties() command gained the DIRECTORY and TARGET_DIRECTORY options to set properties in the provided directory scopes.

  • The string() command learned a new HEX sub-command, which converts strings into their hexadecimal representation.

Variables

Properties

Modules

  • The CheckLinkerFlag module has been added to provide a facility to check validity of link flags.

  • The ExternalProject module ExternalProject_Add() command gained a new GIT_REMOTE_UPDATE_STRATEGY keyword. This can be used to specify how failed rebase operations during a git update should be handled. The CMAKE_EP_GIT_REMOTE_UPDATE_STRATEGY variable was also added as a global default and is honored by both the ExternalProject and FetchContent modules.

  • The FetchContent module FetchContent_Declare() command now supports a SOURCE_SUBDIR option. It can be used to direct FetchContent_MakeAvailable() to look in a different location for the CMakeLists.txt file.

  • The FindBLAS module now provides an imported target.

  • The FindCUDAToolkit module:

    • gained the variable CUDAToolkit_LIBRARY_ROOT, which is the directory containing the nvvm directory and version.txt.

    • uses toolkit and library root found during CUDA compiler detection.

  • The FindLAPACK module now provides an imported target.

  • The FindPython3, FindPython2 and FindPython modules:

    • gained the possibility to create per-artifact cache variables for interactive editing in cmake-gui(1) and ccmake(1).

    • gained sub-components Development.Module and Development.Embed under the Development component.

    • gained the capability to specify which Python implementations to find, including IronPython and PyPy.

  • The FindRuby module input and output variables were all renamed from RUBY_ to Ruby_ for consistency with other find modules. Input variables of the old case will be honored if provided, and output variables of the old case are always provided.

  • The FindSWIG module now accepts target languages as COMPONENTS and OPTIONAL_COMPONENTS arguments to find_package.

  • The GoogleTest module gtest_discover_tests() command:

    • gained a new DISCOVERY_MODE option to control when the test discovery step is run. It offers a new PRE_TEST setting to run the discovery at test time instead of build time. A new CMAKE_GTEST_DISCOVER_TESTS_DISCOVERY_MODE variable can be used to change the default globally.

    • gained a new optional parameter XML_OUTPUT_DIR. When set the JUnit XML test results are stored in that directory.

  • The FindLibXslt module now provides imported targets.

  • The UseSWIG module now supports Fortran as a target language if the SWIG_EXECUTABLE is SWIG-Fortran.

Generator Expressions

CTest

CPack

Other

Deprecated and Removed Features

  • The Documentation module has been deprecated via CMP0106. This module was essentially VTK code that CMake should not be shipping anymore.

  • An explicit deprecation diagnostic was added for policy CMP0070 and policy CMP0071 (CMP0069 and below were already deprecated). The cmake-policies(7) manual explains that the OLD behaviors of all policies are deprecated and that projects should port to the NEW behaviors.

Other Changes

  • On Windows, the Ninja and Ninja Multi-Config generators, when a compiler is not explicitly specified, now select the first compiler (of any name) found in directories listed by the PATH environment variable.

  • The LINK_OPTIONS and INTERFACE_LINK_OPTIONS target properties are now used for the device link step. See policy CMP0105.

  • Creation of an ALIAS target overwriting an existing target now raises an error. See policy CMP0107.

  • Linking a target to itself through an alias now raises an error. See policy CMP0108.

  • The FindPackageHandleStandardArgs module option REQUIRED_VARS is now optional if HANDLE_COMPONENTS is specified.

  • The source_group() command now also recognizes forward slashes as subgroup delimiters, not just backslashes.

  • ctest(1) now logs environment variables that it sets for each test, either due to the ENVIRONMENT property or the resource allocation feature, and submits this log to CDash. It does not log environment variables that were set outside of CTest.

  • When building CMake itself from source and not using a system-provided libcurl, HTTP/2 support is now enabled for commands supporting network communication via http(s), such as file(DOWNLOAD), file(UPLOAD), and ctest_submit(). The precompiled binaries provided on cmake.org now support HTTP/2.

  • The cmake-file-api(7) “codemodel” version 2 version field has been updated to 2.1.

  • The cmake-file-api(7) “codemodel” version 2 “target” object gained a new precompileHeaders field in the compileGroups objects.

Updates

Changes made since CMake 3.18.0 include the following.

3.18.1

  • The Xcode generator, when CMAKE_OSX_ARCHITECTURES is not defined, now selects $(NATIVE_ARCH_ACTUAL) as the default architecture (the Xcode ARCHS setting). This is needed for Xcode 12 to select the host’s architecture, which older versions of Xcode did by default.

  • In CMake 3.18.0 the add_test() command learned to support special characters in test names. This was accidentally left out of its release notes. Unfortunately the fix breaks existing projects that were using manual quoting or escaping to work around the prior limitation. This fix has been reverted in 3.18.1, but may be re-introduced in future versions of CMake with a policy for compatibility.

3.18.2

  • The default value of CMAKE_AUTOMOC_PATH_PREFIX was changed to OFF because this feature can break existing projects that have identically named header files in different include directories. This restores compatibility with behavior of CMake 3.15 and below. The default was also changed to OFF in 3.16.9 and 3.17.5.

  • The Compile Features functionality was updated for MSVC 19.27 as mentioned above (c_restrict).

3.18.3

  • The Compile Features functionality was updated for MSVC 19.28 as mentioned above (c_static_assert).