CMake 3.1 Release Notes¶
Contents
Changes made since CMake 3.0 include the following.
Documentation Changes¶
- A new
cmake-compile-features(7)
manual was added.
New Features¶
Generators¶
- The
Visual Studio 14 2015
generator was added.
Windows Phone and Windows Store¶
- Generators for Visual Studio 11 (2012) and above learned to generate
projects for Windows Phone and Windows Store. One may set the
CMAKE_SYSTEM_NAME
variable toWindowsPhone
orWindowsStore
on thecmake(1)
command-line or in aCMAKE_TOOLCHAIN_FILE
to activate these platforms. Also setCMAKE_SYSTEM_VERSION
to8.0
or8.1
to specify the version of Windows to be targeted.
NVIDIA Nsight Tegra¶
- Generators for Visual Studio 10 (2010) and above learned to generate
projects for NVIDIA Nsight Tegra Visual Studio Edition. One may set
the
CMAKE_SYSTEM_NAME
variable toAndroid
on thecmake(1)
command-line or in aCMAKE_TOOLCHAIN_FILE
to activate this platform.
Syntax¶
- The
cmake-language(7)
syntax for Variable References and Escape Sequences was simplified in order to allow a much faster implementation. See policyCMP0053
. - The
if()
command no longer automatically dereferences variables named in quoted or bracket arguments. See policyCMP0054
.
Commands¶
- The
add_custom_command()
command learned to interpretcmake-generator-expressions(7)
in arguments toDEPENDS
. - The
export(PACKAGE)
command learned to check theCMAKE_EXPORT_NO_PACKAGE_REGISTRY
variable to skip exporting the package. - The
file(STRINGS)
command gained a newENCODING
option to enable extraction ofUTF-8
strings. - The
find_package()
command learned to check theCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY
andCMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY
variables to skip searching the package registries. - The
get_property()
command learned a newINSTALL
scope for properties. - The
install()
command learned aMESSAGE_NEVER
option to avoid output during installation. - The
set_property()
command learned a newINSTALL
scope for properties. - The
string()
command learned a newGENEX_STRIP
subcommand which removesgenerator expression
. - The
string()
command learned a newUUID
subcommand to generate a univerally unique identifier. - New
target_compile_features()
command allows populating theCOMPILE_FEATURES
target property, just like any other build variable. - The
target_sources()
command was added to add to theSOURCES
target property.
Variables¶
- The Visual Studio generators for versions 8 (2005) and above
learned to read the target platform name from a new
CMAKE_GENERATOR_PLATFORM
variable when it is not specified as part of the generator name. The platform name may be specified on thecmake(1)
command line with the-A
option, e.g.-G "Visual Studio 12 2013" -A x64
. - The
CMAKE_GENERATOR_TOOLSET
variable may now be initialized in a toolchain file specified by theCMAKE_TOOLCHAIN_FILE
variable. This is useful when cross-compiling with the Xcode or Visual Studio generators. - The
CMAKE_INSTALL_MESSAGE
variable was introduced to optionally reduce output installation.
Properties¶
- New
CXX_STANDARD
andCXX_EXTENSIONS
target properties may specify values which CMake uses to compute required compile options such as-std=c++11
or-std=gnu++11
. TheCMAKE_CXX_STANDARD
andCMAKE_CXX_EXTENSIONS
variables may be set to initialize the target properties. - New
C_STANDARD
andC_EXTENSIONS
target properties may specify values which CMake uses to compute required compile options such as-std=c11
or-std=gnu11
. TheCMAKE_C_STANDARD
andCMAKE_C_EXTENSIONS
variables may be set to initialize the target properties. - New
COMPILE_FEATURES
target property may contain a list of features required to compile a target. CMake uses this information to ensure that the compiler in use is capable of building the target, and to add any necessary compile flags to support language features. - New
COMPILE_PDB_NAME
andCOMPILE_PDB_OUTPUT_DIRECTORY
target properties were introduced to specify the MSVC compiler program database file location (cl /Fd
). This complements the existingPDB_NAME
andPDB_OUTPUT_DIRECTORY
target properties that specify the linker program database file location (link /pdb
). - The
INTERFACE_LINK_LIBRARIES
target property now supports a$<LINK_ONLY:...>
generator expression
. - A new
INTERFACE_SOURCES
target property was introduced. This is consumed by dependent targets, which compile and link the listed sources. - The
SOURCES
target property now containsgenerator expression
such asTARGET_OBJECTS
when read at configure time, if policyCMP0051
isNEW
. - The
SOURCES
target property now generally supportsgenerator expression
. The generator expressions may be used in theadd_library()
andadd_executable()
commands. - It is now possible to write and append to the
SOURCES
target property. TheCMAKE_DEBUG_TARGET_PROPERTIES
variable may be used to trace the origin of sources. - A
VS_DEPLOYMENT_CONTENT
source file property was added to tell the Visual Studio generators to mark content for deployment in Windows Phone and Windows Store projects. - A
VS_DEPLOYMENT_LOCATION
source file property was added to tell the Visual Studio generators the relative location of content marked for deployment in Windows Phone and Windows Store projects. - The
VS_WINRT_COMPONENT
target property was created to tell Visual Studio generators to compile a shared library as a Windows Runtime (WinRT) component. - The
Xcode
generator learned to check source file propertiesXCODE_EXPLICIT_FILE_TYPE
andXCODE_LAST_KNOWN_FILE_TYPE
for a custom Xcode file reference type.
Modules¶
- The
BundleUtilities
module learned to resolve and replace@rpath
placeholders on OS X to correctly bundle applications using them. - The
CMakePackageConfigHelpers
moduleconfigure_package_config_file()
command learned a newINSTALL_PREFIX
option to generate package configuration files meant for a prefix other thanCMAKE_INSTALL_PREFIX
. - The
CheckFortranSourceCompiles
module was added to provide aCHECK_Fortran_SOURCE_COMPILES
macro. - The
ExternalData
module learned to tolerate aDATA{}
reference to a missing source file with a warning instead of rejecting it with an error. This helps developers write newDATA{}
references to test reference outputs that have not yet been created. - The
ExternalProject
module learned to support lzma-compressed source tarballs with.7z
,.tar.xz
, and.txz
extensions. - The
ExternalProject
moduleExternalProject_Add
command learned a newBUILD_ALWAYS
option to cause the external project build step to run every time the host project is built. - The
ExternalProject
moduleExternalProject_Add
command learned a newEXCLUDE_FROM_ALL
option to cause the external project target to have theEXCLUDE_FROM_ALL
target property set. - The
ExternalProject
moduleExternalProject_Add_Step
command learned a newEXCLUDE_FROM_MAIN
option to cause the step to not be a direct dependency of the main external project target. - The
ExternalProject
moduleExternalProject_Add
command learned a newDOWNLOAD_NO_PROGRESS
option to disable progress output while downloading the source tarball. - The
FeatureSummary
modulefeature_summary
API learned to accept multiple values for theWHAT
option and combine them appropriately. - The
FindCUDA
module learned to supportfatbin
andcubin
modules. - The
FindGTest
modulegtest_add_tests
macro learned a newAUTO
option to automatically read theSOURCES
target property of the test executable and scan the source files for tests to be added. - The
FindGLEW
module now provides imported targets. - The
FindGLUT
module now provides imported targets. - The
FindHg
module gained a newHg_WC_INFO
macro to help runhg
to extract information about a Mercurial work copy. - The
FindOpenCL
module was introduced. - The
FindOpenMP
module learned to support Fortran. - The
FindPkgConfig
module learned to use thePKG_CONFIG
environment variable value as thepkg-config
executable, if set. - The
FindXercesC
module was introduced. - The
FindZLIB
module now provides imported targets. - The
GenerateExportHeader
modulegenerate_export_header
function learned to allow use with Object Libraries. - The
InstallRequiredSystemLibraries
module gained a newCMAKE_INSTALL_OPENMP_LIBRARIES
option to install MSVC OpenMP runtime libraries. - The
UseSWIG
module learned to detect the module name from.i
source files if possible to avoid the need to set theSWIG_MODULE_NAME
source file property explicitly. - The
WriteCompilerDetectionHeader
module was added to allow creation of a portable header file for compiler optional feature detection.
Generator Expressions¶
- New
COMPILE_FEATURES
generator expression
allows setting build properties based on available compiler features.
CTest¶
- The
ctest_coverage()
command learned to read variableCTEST_COVERAGE_EXTRA_FLAGS
to setCoverageExtraFlags
. - The
ctest_coverage()
command learned to support Intel coverage files with thecodecov
tool. - The
ctest_memcheck()
command learned to support sanitizer modes, includingAddressSanitizer
,MemorySanitizer
,ThreadSanitizer
, andUndefinedBehaviorSanitizer
. Options may be set using the newCTEST_MEMORYCHECK_SANITIZER_OPTIONS
variable.
CPack¶
cpack(1)
gained anIFW
generator to package using Qt Framework Installer tools. See theCPackIFW
module.cpack(1)
gained7Z
andTXZ
generators supporting lzma-compressed archives.- The
CPackDeb
module learned a newCPACK_DEBIAN_COMPRESSION_TYPE
variable to set the tarball compression type. - The
cpack(1)
WiX
generator learned to support aCPACK_WIX_ACL
installed file property to specify an Access Control List.
Other¶
- The
cmake(1)
-E
option learned a newenv
command. - The
cmake(1)
-E tar
command learned to support lzma-compressed files. - Object Libraries may now have extra sources that do not
compile to object files so long as they would not affect linking
of a normal library (e.g.
.dat
is okay but not.def
). - Visual Studio generators for VS 8 and later learned to support
the
ASM_MASM
language. - The Visual Studio generators learned to treat
.hlsl
source files as High Level Shading Language sources (usingFXCompile
in.vcxproj
files). Source file propertiesVS_SHADER_TYPE
,VS_SHADER_MODEL
, andVS_SHADER_ENTRYPOINT
were added added to specify the shader type, model, and entry point name.
New Diagnostics¶
- Policy
CMP0052
introduced to control directories in theINTERFACE_INCLUDE_DIRECTORIES
of exported targets.
Deprecated and Removed Features¶
In CMake 3.0 the
target_link_libraries()
command accidentally began allowing unquoted arguments to usegenerator expressions
containing a (;
separated) list within them. For example:set(libs B C) target_link_libraries(A PUBLIC $<BUILD_INTERFACE:${libs}>)
This is equivalent to writing:
target_link_libraries(A PUBLIC $<BUILD_INTERFACE:B C>)
and was never intended to work. It did not work in CMake 2.8.12. Such generator expressions should be in quoted arguments:
set(libs B C) target_link_libraries(A PUBLIC "$<BUILD_INTERFACE:${libs}>")
CMake 3.1 again requires the quotes for this to work correctly.
Prior to CMake 3.1 the Makefile generators did not escape
#
correctly inside make variable assignments used in generated makefiles, causing them to be treated as comments. This made code like:add_compile_options(-Wno-#pragma-messages)
not work in Makefile generators, but work in other generators. Now it is escaped correctly, making the behavior consistent across generators. However, some projects may have tried to workaround the original bug with code like:
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-\\#pragma-messages")
This added the needed escape for Makefile generators but also caused other generators to pass
-Wno-\#pragma-messages
to the shell, which would work only in POSIX shells. Unfortunately the escaping fix could not be made in a compatible way so this platform- and generator-specific workaround no longer works. Project code may test theCMAKE_VERSION
variable value to make the workaround version-specific too.Callbacks established by the
variable_watch()
command will no longer receive theALLOWED_UNKNOWN_READ_ACCESS
access type when the undocumentedCMAKE_ALLOW_UNKNOWN_VARIABLE_READ_ACCESS
variable is set. Uninitialized variable accesses will always be reported asUNKNOWN_READ_ACCESS
.The
CMakeDetermineVSServicePack
module now warns that it is deprecated and should not longer be used. Use theCMAKE_<LANG>_COMPILER_VERSION
variable instead.The
FindITK
module has been removed altogether. It was a thin-wrapper aroundfind_package(ITK ... NO_MODULE)
. This produces much clearer error messages when ITK is not found.The
FindVTK
module has been removed altogether. It was a thin-wrapper aroundfind_package(VTK ... NO_MODULE)
. This produces much clearer error messages when VTK is not found.The module also provided compatibility support for finding VTK 4.0. This capability has been dropped.
Other Changes¶
- The
cmake-gui(1)
learned to capture output from child processes started by theexecute_process()
command and display it in the output window. - The
cmake-language(7)
internal implementation of generator expression and list expansion parsers have been optimized and shows non-trivial speedup on large projects. - The Makefile generators learned to use response files with GNU tools on Windows to pass library directories and names to the linker.
- When generating linker command-lines, CMake now avoids repeating items corresponding to SHARED library targets.
- Support for the Open Watcom compiler has been overhauled.
The
CMAKE_<LANG>_COMPILER_ID
is nowOpenWatcom
, and theCMAKE_<LANG>_COMPILER_VERSION
now uses the Open Watcom external version numbering. The external version numbers are lower than the internal version number by 11. - The
cmake-mode.el
major Emacs editing mode no longer treats_
as part of words, making it more consistent with other major modes.