CMake 3.8 Release Notes¶
Contents
Changes made since CMake 3.7 include the following.
New Features¶
Languages¶
C#¶
CMake learned to support
CSharp(C#) as a first-class language that can be enabled via theproject()andenable_language()commands. It is currently supported by the Visual Studio Generators for VS 2010 and above.C# assemblies and programs can be added just like common C++ targets using the
add_library()andadd_executable()commands. References between C# targets in the same source tree may be specified bytarget_link_libraries()like for C++. References to system or 3rd-party assemblies may be specified by the target propertiesVS_DOTNET_REFERENCE_<refname>andVS_DOTNET_REFERENCES.More fine tuning of C# targets may be done using target and source file properties. Specifically the target properties related to Visual Studio (
VS_*) are worth a look (for setting toolset versions, root namespaces, assembly icons, ...).
CUDA¶
- CMake learned to support
CUDAas a first-class language that can be enabled via theproject()andenable_language()commands. CUDAis currently supported by the Makefile Generators and theNinjagenerator on Linux, macOS, and Windows. Support for the Visual Studio IDE is under development but not included in this release.- The NVIDIA CUDA Toolkit compiler (
nvcc) is supported.
C & C++¶
- The
Compile Featuresfunctionality now offers meta-features that request compiler modes for specific language standard levels (e.g.cxx_std_11). SeeCMAKE_C_KNOWN_FEATURESandCMAKE_CXX_KNOWN_FEATURES. - The
Compile Featuresfunctionality is now aware of C++ 17. No specific features are yet enumerated besides thecxx_std_17meta-feature. - The
Compile Featuresfunctionality is now aware of the availability of C99 in gcc since version 3.4.
Generators¶
- The
CodeBlocksextra generator may now be used to generate withNMake Makefiles JOM. - The Visual Studio Generators for VS 2013 and above learned to
support a
host=x64option in theCMAKE_GENERATOR_TOOLSETvalue (e.g. via thecmake(1)-Toption) to request use of a VS 64-bit toolchain on 64-bit hosts. - The Visual Studio Generators learned to treat files passed to
target_link_libraries()whose names end in.targetsas MSBuild “targets” files to be imported into generated project files.
Commands¶
- The
add_custom_command()andadd_custom_target()commands learned the optionCOMMAND_EXPAND_LISTSwhich causes lists in theCOMMANDargument to be expanded, including lists created by generator expressions. - The
execute_process()command gained anENCODINGoption to specify on Windows which encoding is used for output from child process. - The
math(EXPR)command gained support for unary+and-operators. - The
source_group()command gainedTREEandPREFIXoptions to add groups following source tree directory structure. - The
string(TIMESTAMP)command learned to treat%%as a way to encode plain%. - The
string(TIMESTAMP)command will now honor theSOURCE_DATE_EPOCHenvironment variable and use its value instead of the current time. - The
try_compile()command source file signature gained new options to specify the language standard to use in the generated test project. - The
try_compile()command source file signature now honors language standard variables likeCMAKE_CXX_STANDARD. See policyCMP0067.
Variables¶
- A
CMAKE_CODELITE_USE_TARGETSvariable was added to tell theCodeLiteextra generator to change the generated project to have target-centric organization. Thebuild,rebuild, andcleanoperations withinCodeLitethen work on a selected target rather than the whole workspace. (Note that theNinjaclean operation on a target includes its dependencies, though.) - The
CMAKE_SUBLIME_TEXT_2_ENV_SETTINGSvariable was added to tell theSublime Text 2extra generator to place specified environment variables in the generated.sublime-project. - The
CMAKE_SUBLIME_TEXT_2_EXCLUDE_BUILD_TREEvariable was added to tell theSublime Text 2extra generator whether to exclude the build tree from the.sublime-projectwhen it is inside the source tree. - A
CMAKE_VS_INCLUDE_PACKAGE_TO_DEFAULT_BUILDvariable was added to tell Visual Studio Generators for VS 2010 and above to include thePACKAGEtarget in the default build, similar to the existingCMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILDvariable for theINSTALLtarget.
Properties¶
- A
BUILD_RPATHtarget property and correspondingCMAKE_BUILD_RPATHvariable were added to support customRPATHlocations to be added to binaries in the build tree. - The
COMPILE_FLAGSsource file property learned to supportgenerator expressions. - The
FRAMEWORKtarget property may now also be applied to static libraries on Apple targets. It will result in a proper Framework but with a static library inside. - Imported Interface Libraries learned new
IMPORTED_LIBNAMEandIMPORTED_LIBNAME_<CONFIG>target properties to specify a link library name since interface libraries do not build their own library files. - A
<LANG>_CPPLINTtarget property and supportingCMAKE_<LANG>_CPPLINTvariable were introduced to tell the Makefile Generators and theNinjagenerator to run thecpplintstyle checker along with the compiler forCandCXXlanguages. - A
MANUALLY_ADDED_DEPENDENCIEStarget property has been added. It provides a read-only list of dependencies that have been added with theadd_dependencies()command. - The
MAP_IMPORTED_CONFIG_<CONFIG>target property learned to interpret empty list elements as referring to the configuration-less imported location specified byIMPORTED_LOCATION. - The
NO_SYSTEM_FROM_IMPORTEDtarget property is now supported on Imported Interface Libraries. - New source file properties
SKIP_AUTOMOC,SKIP_AUTOUIC,SKIP_AUTORCC, andSKIP_AUTOGENwere added to allow source files to be excluded from processing byAUTOMOC,AUTOUIC, andAUTORCCtarget properties. - A
VS_COPY_TO_OUT_DIRsource file property was added to tell Visual Studio Generators for VS 2010 and above whether or not a file should e copied to the output directory. - A
VS_DEBUGGER_WORKING_DIRECTORYtarget property was added to tell Visual Studio Generators for VS 2010 and above what debugger working directory should be set for the target. - A
VS_DOTNET_REFERENCES_COPY_LOCALtarget property was added to specify whether to copy referenced assemblies to the output directory. - A
VS_DOTNET_REFERENCE_<refname>target property was added to tell Visual Studio Generators for VS 2010 and above to add a .NET reference with a given hint path. - A
VS_INCLUDE_IN_VSIXsource file property was added to tell Visual Studio Generators for VS 2010 and above whether to include the file in a Visual Studio extension package. - A
VS_RESOURCE_GENERATORsource file property was added to give Visual Studio Generators for VS 2010 and above a setting for the resource generator (C#only). - A
VS_USER_PROPStarget property was added to tell Visual Studio Generators for VS 2010 and above to use a custom MSBuild user.propsfile. - A
XCODE_EMIT_EFFECTIVE_PLATFORM_NAMEglobal property was added to tell theXcodegenerator whether to emit theEFFECTIVE_PLATFORM_NAMEvariable. This is useful when building with multiple SDKs likemacosxandiphoneosin parallel. - New
XCODE_PRODUCT_TYPEandXCODE_EXPLICIT_FILE_TYPEtarget properties were created to tell theXcodegenerator to use custom values of the corresponding attributes for a target in the generated Xcode project.
Modules¶
- A
CSharpUtilitiesmodule was added to aid parameterization of Visual Studio C# targets. It provides functions to allow automated setting of source file properties to support Windows Forms, WPF/XAML or other technologies as needed. - The
ExternalDatamodule learned to support multiple content links for one data file using different hashes, e.g.img.png.sha256andimg.png.sha1. This allows objects to be fetched from sources indexed by different hash algorithms. - The
ExternalProjectmodule gained theGIT_PROGRESSoption to force Git to show progress when cloning repositories. - The
ExternalProjectmodule gained aGIT_CONFIGoption to pass--configoptions to Git when cloning repositories. - The
FeatureSummarymodulefeature_summary()command now accepts a newQUIET_ON_EMPTYoption that suppresses the output when the list of packages that belong to the selected category is empty. - The
FeatureSummarymoduleadd_feature_info()command now accepts lists of dependencies for deciding whether a feature is enabled or not. - The package types accepted by the
FeatureSummarymodule can now be tweaked by changing theFeatureSummary_PKG_TYPES,FeatureSummary_REQUIRED_PKG_TYPESandFeatureSummary_DEFAULT_PKG_TYPEglobal properties. - The
FindOpenGLmodule now provides imported targetsOpenGL::GLandOpenGL::GLUwhen the libraries are found. - The
UseSWIGmodule gained aswig_add_librarycommand to give more flexibility over the oldswig_add_modulecommand. - The
UseSWIGmoduleswig_add_source_to_modulecommand learned a newSWIG_OUTFILE_DIRoption to control the output file location (swig -o). - The
WriteCompilerDetectionHeadermodule gained theALLOW_UNKNOWN_COMPILERSandALLOW_UNKNOWN_COMPILER_VERSIONSoptions that allow creation of headers that will work also with unknown or old compilers by simply assuming they do not support any of the requested features.
CTest¶
- The
ctest_memcheck()command gained aDEFECT_COUNT <var>option to capture the number of memory defects detected. - The
ctest_memcheck()command learned to read the location of suppressions files for sanitizers from theCTEST_MEMORYCHECK_SUPPRESSIONS_FILEvariable. - The
ctest_memcheck()command learned to supportLeakSanitizerindependently fromAddressSanitizer. - The
ctest_update()commandCDASH_UPLOADsignature was taught to honor theRETRY_COUNT,RETRY_DELAY, andQUIEToptions.
CPack¶
- The
CPackIFWConfigureFilemodule was added to define a newcpack_ifw_configure_file()command to configure file templates prepared in QtIFW/SDK/Creator style. - The
CPackIFWmodulecpack_ifw_configure_component()andcpack_ifw_configure_component_group()commands gained a newDEFAULT,VIRTUAL,FORCED_INSTALLATION,REQUIRES_ADMIN_RIGHTS,DISPLAY_NAME,UPDATE_TEXT,DESCRIPTION,RELEASE_DATE,AUTO_DEPEND_ONandTRANSLATIONSoptions to more specific configuration. - The
CPackIFWmodulecpack_ifw_configure_component()command gained a newDEPENDENCIESalias forDEPENDSoption. - The
CPackIFWmodulecpack_ifw_configure_component_group()command gained a newDEPENDSoption. TheDEPENDENCIESalias also added. - The
CPackIFWmodulecpack_ifw_configure_component()andcpack_ifw_configure_component_group()commandsPRIORITYoption now is deprecated and will be removed in a future version of CMake. Please use newSORTING_PRIORITYoption instead. - The
CPackIFWmodule gained newCPACK_IFW_PACKAGE_WATERMARK,CPACK_IFW_PACKAGE_BANNER,CPACK_IFW_PACKAGE_BACKGROUND,CPACK_IFW_PACKAGE_WIZARD_STYLE,CPACK_IFW_PACKAGE_WIZARD_DEFAULT_WIDTH,CPACK_IFW_PACKAGE_WIZARD_DEFAULT_HEIGHT, andCPACK_IFW_PACKAGE_TITLE_COLORvariables to customize a QtIFW installer look. - The
CPackProductBuildmodule gained options to sign packages. See the variablesCPACK_PRODUCTBUILD_IDENTITY_NAME,CPACK_PRODUCTBUILD_KEYCHAIN_PATH,CPACK_PKGBUILD_IDENTITY_NAME, andCPACK_PKGBUILD_KEYCHAIN_PATH. - The
CPackRPMmodule learned to omit tags that are not supported by providedrpmbuildtool. If unsupported tags are set they are ignored and a developer warning is printed out. - The
CPackRPMmodule learned to generate main component package which forces generation of a rpm for defined component without component suffix in filename and package name. SeeCPACK_RPM_MAIN_COMPONENTvariable. - The
CPackRPMmodule learned to generate a singledebuginfopackage on demand even if components packaging is used. SeeCPACK_RPM_DEBUGINFO_SINGLE_PACKAGEvariable. - The
CPackRPMmodule learned to support multiple directives per file when usingCPACK_RPM_USER_FILELISTvariable.
Deprecated and Removed Features¶
- The
FeatureSummarymodule commandsset_package_info(),set_feature_info(),print_enabled_features(), andprint_disabled_features()are now deprecated. - The
UseSWIGmoduleswig_add_modulecommand is now deprecated in favor ofswig_add_library.
Other Changes¶
- If a command specified by the
<LANG>_CLANG_TIDYtarget property returns non-zero at build time this is now treated as an error instead of silently ignored. - The
ctest_memcheck()command no longer automatically addsleak_check=1to the options used byAddressSanitizer. The default behavior ofAddressSanitizeris to run LeakSanitizer to check leaks unlessleak_check=0. - The
ctest_memcheck()command was fixed to correctly append extra sanitizer options read from theCTEST_MEMORYCHECK_SANITIZER_OPTIONSvariable to the environment variables used internally by the sanitizers. - The
FeatureSummarymoduleset_package_properties()command no longer forces the package type toOPTIONALwhen the type is not explicitly set. - The
Compile Featuresfunctionality is now aware of features supported by Intel C++ compilers versions 12.1 through 17.0 on UNIX and Windows platforms. - Calls to the
FindPkgConfigmodulepkg_check_modules()command following a successful call learned to re-evaluate the cached values for a given prefix after changes to the parameters to the command for that prefix. - When using
AUTOMOCorAUTOUIC, generatedmoc_*,*.mocandui_*are placed in the<CMAKE_CURRENT_BINARY_DIR>/<TARGETNAME>_autogen/includedirectory which is automatically added to the target’sINCLUDE_DIRECTORIES. It is therefore not necessary anymore to haveCMAKE_CURRENT_BINARY_DIRin the target’sINCLUDE_DIRECTORIES. - The
Sublime Text 2generator no longer runs the native build command (e.g.ninjaormake) with verbose build output enabled. - The
try_compile()command source file signature now honors theCMAKE_WARN_DEPRECATEDvariable value in the generated test project. - The Visual Studio Generators for VS 2010 and above now place
per-source file flags after target-wide flags when they are classified
as raw flags with no project file setting (
AdditionalOptions). This behavior is more consistent with the ordering of flags produced by other generators, and allows flags on more-specific properties (per-source) to override those on more general ones (per-target). - The precompiled Windows binary MSI package provided on
cmake.orgnow records the installation directory in the Windows Registry under the keyHKLM\Software\Kitware\CMakewith a value namedInstallDir.