CMake 3.9 Release Notes¶
Contents
Changes made since CMake 3.8 include the following.
New Features¶
Languages¶
CUDAis now supported by the Visual Studio Generators for VS 2010 and above. This complements the existing support by the Makefile Generators and theNinjagenerator. CUDA 8.0.61 or higher is recommended due to known bugs in the VS integration by earlier versions.CMake is now aware of the
C++ standardsandC standardsand their associated meta-features for the followingcompiler ids:Cray,PGI, andXL.
Generators¶
Visual Studio Generators for VS 2010 and above learned to support the
ASM_NASMlanguage whennasmis installed.The
Xcodegenerator learned to create Xcode schema files. This is an experimental feature and can be activated by setting theCMAKE_XCODE_GENERATE_SCHEMEvariable to aTRUEvalue.
Commands¶
The
add_library()commandIMPORTEDoption learned to support Object Libraries.The
find_library()command learned to searchlibx32paths when the build targets thex32ABI. See theFIND_LIBRARY_USE_LIBX32_PATHSglobal property.The
include_external_msproject()command learned to use theMAP_IMPORTED_CONFIG_<CONFIG>target property to map current configurations to the external configurations.The
install(TARGETS)command learned a newOBJECTSoption to specify where to install Object Libraries.The
install(EXPORT)command learned how to export Object Libraries.The
project()command learned an optionalDESCRIPTIONparameter to set thePROJECT_DESCRIPTIONvariable.The
separate_arguments()command gained aNATIVE_COMMANDmode that performs argument separation depending on the host operating system.
Variables¶
A
CMAKE_ANDROID_NDK_DEPRECATED_HEADERSvariable was added for use when Cross Compiling for Android with the NDK to request use of the deprecated headers even when unified headers are available. The default is now to use unified headers if available.A
CMAKE_AUTOMOC_DEPEND_FILTERSvariable was introduced to allowCMAKE_AUTOMOCto extract additional dependency file names formocfrom the contents of source files.A
CMAKE_AUTOUIC_SEARCH_PATHSvariable was introduced to allowCMAKE_AUTOUICto search forfoo.uiin more places than the vicinity of the file includingui_foo.h.A
CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIXvariable was added to tell thefind_library()command to search in alib<suffix>directory before eachlibdirectory that would normally be searched.A
CMAKE_INTERPROCEDURAL_OPTIMIZATIONvariable was added to initialize theINTERPROCEDURAL_OPTIMIZATIONproperty on all targets.A
CMAKE_<LANG>_COMPILER_ARvariable was added to hold the path to the GCC/Clang wrapper ofar.A
CMAKE_<LANG>_COMPILER_RANLIBvariable was added to hold the path to the GCC/Clang wrapper ofranlib.The
CMAKE_SYSROOT_COMPILEandCMAKE_SYSROOT_LINKvariables were added to use separate sysroots for compiling and linking.
Properties¶
A new
AUTOGEN_BUILD_DIRtarget property was introduced to set a custom output directory forAUTOMOC,AUTOUIC, andAUTORCC.A new
AUTOMOC_DEPEND_FILTERStarget property was introduced to allowAUTOMOCto extract additional dependency file names formocfrom the contents of source files.A new
AUTOUIC_SEARCH_PATHStarget property was introduced to allowAUTOUICto search forfoo.uiin more places than the vicinity of the file includingui_foo.h.Global properties
AUTOGEN_SOURCE_GROUP,AUTOMOC_SOURCE_GROUPandAUTORCC_SOURCE_GROUPwere introduced to allow files generated byAUTOMOCorAUTORCCto be placed in asource_group().A
BUILD_WITH_INSTALL_NAME_DIRtarget property and correspondingCMAKE_BUILD_WITH_INSTALL_NAME_DIRvariable were added to control whether to use theINSTALL_NAME_DIRtarget property value for binaries in the build tree. This is for macOSinstall_nameasBUILD_WITH_INSTALL_RPATHis forRPATH.A
CUDA_PTX_COMPILATIONtarget property was added to Object Libraries to support compiling to.ptxfiles instead of host object files.A
GENERATOR_IS_MULTI_CONFIGglobal property was added to determine whether the current generator is a multi-configuration generator (such as Visual Studio Generators orXcode).The
INTERPROCEDURAL_OPTIMIZATIONtarget property is now enforced when enabled. CMake will add IPO flags unconditionally or produce an error if it does not know the flags for the current compiler. The project is now responsible to use theCheckIPOSupportedmodule to check for IPO support before enabling the target property. See policyCMP0069.The
WINDOWS_EXPORT_ALL_SYMBOLStarget property may now be used in combination with explicit.deffiles in order to export all symbols from the object files within a target plus an explicit list of symbols that the linker finds in dependencies (e.g.msvcrt.lib).
Modules¶
A
CheckIPOSupportedmodule was added to help projects check whether interprocedural optimization (IPO) is supported by the current toolchain and CMake version.The
CMakeFindDependencyMacromodulefind_dependencymacro now forwards all arguments to the underlyingfind_package()call. Existing uses will continue to function as before, but callers can now access the full suite of arguments thatfind_packageaccepts.The
FeatureSummarymodulefeature_summary()command now accepts the newDEFAULT_DESCRIPTIONoption that will print the default title for the selected package type.The
FeatureSummarymodule gained a newFeatureSummary_<TYPE>_DESCRIPTIONvariable that can be defined for each<TYPE>to replace the type name with the specified string whenever the package type is used in an output string by the module.The
FindDoxygenmodule learned to control Doxygen behavior using CMake variables and generate documentation via the newly addeddoxygen_add_docs()function. The Doxygen input file (Doxyfile) is automatically generated and doxygen is run as part of a custom target. Additional components can be specified to find optional tools:dot,mscgenanddia.The
FindMPImodule now provides imported targets.The
FindProtobufmoduleprotobuf_generate_cpp()command gained anEXPORT_MACROoption to specify the name of a DLL export markup macro.The
FindProtobufmodule now supports usage of static libraries for Unix via a newProtobuf_USE_STATIC_LIBSinput variable.The
FindProtobufmodule now provides imported targets when the libraries are found.A new
GoogleTestmodule was added to provide thegtest_add_tests()function independently of theFindGTestmodule. The function was also updated to support keyword arguments, with functionality expanded to allow a test name prefix and suffix to be specified, the dependency on the source files to be optional and the list of discovered test cases to be returned to the caller.
CTest¶
The
ctest_submit()command gained aHTTPHEADERoption to specify custom headers to send during submission.The
ctest(1)executable gained new options which allow the developer to disable automatically adding tests to the test set to satisfy fixture dependencies.-FSprevents adding setup tests for fixtures matching the provided regular expression,-FCprevents adding cleanup tests for matching fixtures and-FAprevents adding any test for matching fixtures.A
DISABLEDtest property was added to mark tests that are configured but explicitly disabled so they do not run.
CPack¶
The
CPackArchivemodule learned to modify the filename per-component. See theCPACK_ARCHIVE_FILE_NAMEvariable and its per-component versionCPACK_ARCHIVE_<component>_FILE_NAME.The
CPackComponentmodulecpack_add_component()command gained a newPLIST <filename>option to specify thepkgbuild--component-plistargument when using theproductbuildgenerator.The
CPackIFWmodulecpack_ifw_configure_component()andcpack_ifw_configure_component_group()commands gained internationalization support forDISPLAY_NAMEandDESCRIPTIONoptions.The
CPackIFWmodule learned the new hintCPACK_IFW_ROOTvariable for finding the QtIFW tool suite installed in a non-standard place.The
CPackProductBuildmodule gained a newCPACK_PRODUCTBUILD_RESOURCES_DIRvariable to specify resources to be copied into theResourcesdirectory.The
CPackRPMmodule learned to modify thedebuginfopackage name. See theCPACK_RPM_DEBUGINFO_FILE_NAMEvariable.The
CPackWIXmodule patching system now has the ability to set additional attributes. This can be done by specifying attributes with theCPackWiXFragmentXML tag after theIdattribute. See theCPACK_WIX_PATCH_FILEvariable.The CPack WIX generator implemented a new
CPACK_WIX_ROOT_FOLDER_IDvariable which allows using a custom root folder ID instead of the defaultProgramFilesFolder/ProgramFiles64Folder.
Other¶
Interprocedural optimization (IPO) is now supported for GNU and Clang compilers using link time optimization (LTO) flags. See the
INTERPROCEDURAL_OPTIMIZATIONtarget property andCheckIPOSupportedmodule.The
TARGET_OBJECTSgenerator expressionis now supported by theadd_custom_command()andfile(GENERATE)commands.Two new informational generator expressions to retrieve Apple Bundle directories have been added. The first one
$<TARGET_BUNDLE_DIR:tgt>outputs the full path to the Bundle directory, the other one$<TARGET_BUNDLE_CONTENT_DIR:tgt>outputs the full path to theContentsdirectory of macOS Bundles and App Bundles. For all other bundle types and SDKs it is identical with$<TARGET_BUNDLE_DIR:tgt>. The new expressions are helpful to query Bundle locations independent of the different Bundle types and layouts on macOS and iOS.
Deprecated and Removed Features¶
An explicit deprecation diagnostic was added for policies
CMP0036and below. Thecmake-policies(7)manual explains that the OLD behaviors of all policies are deprecated and that projects should always port to the NEW behaviors as soon as possible.The
Visual Studio 8 2005generator is now deprecated and will be removed in a future version of CMake.The
Visual Studio 7 .NET 2003generator has been removed.The
Xcodegenerator dropped support for Xcode versions older than 3.The
FindDoxygenmodule has deprecated several variables.The version of curl bundled with CMake no longer accepts URLs of the form
file://c:/...on Windows due to a change in upstream curl 7.52. Use the formfile:///c:/...instead to work on all versions.
Other Changes¶
When using
AUTOMOC, CMake now scans for the presence of theQ_PLUGIN_METADATAmacro and reruns moc when the file from the macro’sFILEargument changes.When
AUTOMOCdetects an include statement of the form#include "moc_<basename>.cpp"the search for the respective header file now looks in theINCLUDE_DIRECTORIESof the target as well.When running tests, CTest learned to treat skipped tests (using the
SKIP_RETURN_CODEproperty) the same as tests with the newDISABLEDproperty. Due to this change, CTest will not indicate failure when all tests are either skipped or pass.The
Ninjagenerator has loosened the dependencies of object compilation. Object compilation now depends only on custom targets and custom commands associated with libraries on which the object’s target depends and no longer depends on the libraries themselves. Source files in dependent targets may now compile without waiting for their targets’ dependencies to link.On macOS,
RPATHsettings such asBUILD_WITH_INSTALL_RPATHno longer affect theinstall_namefield. See policyCMP0068.The
Visual Studio 14 2015generator has been taught about a change to thev140toolset made by a VS 2015 update. VS changed the set of values it understands for theGenerateDebugInformationlinker setting that produces the-DEBUGlinker flag variants.
Updates¶
Changes made since CMake 3.9.0 include the following.
3.9.1¶
The
find_commandPACKAGE_ROOTsearch path group added by CMake 3.9.0 has been removed for the 3.9 series due to regressions caused by new use of<PackageName>_ROOTvariables. The behavior may be re-introduced in the future in a more-compatible way.
3.9.2¶
On macOS, the default application bundle
Info.plistfile no longer enables Hi-DPI support as it did in 3.9.0 and 3.9.1. The change had to be reverted because it broke iOS applications.The Xcode generator no longer adds “outputPaths” to custom script build phases as it did in 3.9.0 and 3.9.1. This was added in an attempt to support Xcode 9’s new build system, but broke incremental rebuilds for both the old and new Xcode build systems.