3.16.rst 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. CMake 3.16 Release Notes
  2. ************************
  3. .. only:: html
  4. .. contents::
  5. Changes made since CMake 3.15 include the following.
  6. New Features
  7. ============
  8. Languages
  9. ---------
  10. * CMake learned to support the Objective C (``OBJC``) and Objective C++
  11. (``OBJCXX``) languages. They may be enabled via the :command:`project`
  12. and :command:`enable_language` commands. When ``OBJC`` or ``OBJCXX``
  13. is enabled, source files with the ``.m`` or ``.mm``, respectively,
  14. will be compiled as Objective C or C++. Otherwise they will be treated
  15. as plain C++ sources as they were before.
  16. Compilers
  17. ---------
  18. * The ``Clang`` compiler is now supported on ``Solaris``.
  19. Platforms
  20. ---------
  21. * On AIX, executables using the :prop_tgt:`ENABLE_EXPORTS` target property
  22. now produce a linker import file with a ``.imp`` extension in addition
  23. to the executable file. Plugins (created via :command:`add_library` with
  24. the ``MODULE`` option) that use :command:`target_link_libraries` to link
  25. to the executable for its symbols are now linked using the import file.
  26. The :command:`install(TARGETS)` command now installs the import file as
  27. an ``ARCHIVE`` artifact.
  28. * On AIX, runtime linking is no longer enabled by default. CMake provides
  29. the linker enough information to resolve all symbols up front.
  30. One may manually enable runtime linking for shared libraries and/or
  31. loadable modules by adding ``-Wl,-G`` to their link flags
  32. (e.g. in the :variable:`CMAKE_SHARED_LINKER_FLAGS` or
  33. :variable:`CMAKE_MODULE_LINKER_FLAGS` variable).
  34. One may manually enable runtime linking for executables by adding
  35. ``-Wl,-brtl`` to their link flags (e.g. in the
  36. :variable:`CMAKE_EXE_LINKER_FLAGS` variable).
  37. Command-Line
  38. ------------
  39. * :manual:`cmake(1)` ``-E`` now supports ``true`` and ``false`` commands,
  40. which do nothing while returning exit codes of 0 and 1, respectively.
  41. * :manual:`cmake(1)` gained a ``--trace-redirect=<file>`` command line
  42. option that can be used to redirect ``--trace`` output to a file instead
  43. of ``stderr``.
  44. * The :manual:`cmake(1)` ``--loglevel`` command line option has been
  45. renamed to ``--log-level`` to make it consistent with the naming of other
  46. command line options. The ``--loglevel`` option is still supported to
  47. preserve backward compatibility.
  48. Commands
  49. --------
  50. * The :command:`add_test` command learned the option ``COMMAND_EXPAND_LISTS``
  51. which causes lists in the ``COMMAND`` argument to be expanded, including
  52. lists created by generator expressions.
  53. * The :command:`file` command learned a new sub-command,
  54. ``GET_RUNTIME_DEPENDENCIES``, which allows you to recursively get the list of
  55. libraries linked by an executable or library. This sub-command is intended as
  56. a replacement for :module:`GetPrerequisites`.
  57. * The :command:`find_file`, :command:`find_library`, :command:`find_path`,
  58. :command:`find_package`, and :command:`find_program` commands have learned to
  59. check the following variables to control the default behavior for groups of
  60. search locations:
  61. * :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` - Controls the default
  62. behavior of searching the :variable:`<PackageName>_ROOT` variables.
  63. * :variable:`CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH` - Controls the default
  64. behavior of searching the CMake-specific environment variables.
  65. * :variable:`CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH` - Controls the default
  66. behavior of searching the standard system environment variables.
  67. * :variable:`CMAKE_FIND_USE_CMAKE_PATH` - Controls the default behavior of
  68. searching the CMake-specific cache variables.
  69. * :variable:`CMAKE_FIND_USE_CMAKE_SYSTEM_PATH` - Controls the default
  70. behavior of searching the platform-specific CMake variables.
  71. * The :command:`find_package` command has learned to check the
  72. :variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY` variable to control the default
  73. behavior of searching the CMake user package registry.
  74. * The :command:`message` command learned indentation control with the new
  75. :variable:`CMAKE_MESSAGE_INDENT` variable.
  76. * The :command:`target_precompile_headers` command was added to specify
  77. a list of headers to precompile for faster compilation times.
  78. Variables
  79. ---------
  80. * The :variable:`CMAKE_CUDA_RESOLVE_DEVICE_SYMBOLS` variable has been
  81. introduced to optionally initialize the
  82. :prop_tgt:`CUDA_RESOLVE_DEVICE_SYMBOLS` target property.
  83. * The :variable:`CMAKE_ECLIPSE_RESOURCE_ENCODING` variable was added to
  84. specify the resource encoding for the the :generator:`Eclipse CDT4` extra
  85. generator.
  86. * The :variable:`CMAKE_UNITY_BUILD` variable was added to initialize the
  87. :prop_tgt:`UNITY_BUILD` target property to tell generators to batch
  88. include source files for faster compilation times.
  89. Properties
  90. ----------
  91. * The :prop_tgt:`BUILD_RPATH` and :prop_tgt:`INSTALL_RPATH` target properties
  92. now support :manual:`generator expressions <cmake-generator-expressions(7)>`.
  93. * The :prop_tgt:`INSTALL_REMOVE_ENVIRONMENT_RPATH` target property was
  94. added to remove compiler-defined ``RPATH`` entries from a target.
  95. This property is initialized by the
  96. :variable:`CMAKE_INSTALL_REMOVE_ENVIRONMENT_RPATH` variable.
  97. * The :prop_tgt:`PRECOMPILE_HEADERS` target property was added to specify
  98. a list of headers to precompile for faster compilation times.
  99. Set it using the :command:`target_precompile_headers` command.
  100. * The :prop_tgt:`UNITY_BUILD` target property was added to tell
  101. generators to batch include source files for faster compilation
  102. times.
  103. * The :prop_tgt:`VS_CONFIGURATION_TYPE` target property now supports
  104. :manual:`generator expressions <cmake-generator-expressions(7)>`.
  105. * The :prop_tgt:`VS_DPI_AWARE` target property was added to tell
  106. :ref:`Visual Studio Generators` to set the ``EnableDpiAwareness``
  107. property in ``.vcxproj`` files.
  108. * The :prop_tgt:`XCODE_SCHEME_DEBUG_DOCUMENT_VERSIONING` target property was
  109. added to tell the :generator:`Xcode` generator to set the value of the
  110. ``Allow debugging when using document Versions Browser`` schema option.
  111. Modules
  112. -------
  113. * The :module:`FindDoxygen` module :command:`doxygen_add_docs` command
  114. gained a new ``USE_STAMP_FILE`` option. When this option present,
  115. the custom target created by the command will only re-run Doxygen if
  116. any of the source files have changed since the last successful run.
  117. * The :module:`FindGnuTLS` module now provides an imported target.
  118. * The :module:`FindPackageHandleStandardArgs` module
  119. :command:`find_package_handle_standard_args` command gained
  120. a new ``REASON_FAILURE_MESSAGE`` option to specify a message
  121. giving the reason for the failure.
  122. * The :module:`FindPkgConfig` module :command:`pkg_search_module` macro
  123. now defines a ``<prefix>_MODULE_NAME`` result variable containing the
  124. first matching module name.
  125. * The :module:`FindPython3` and :module:`FindPython` modules gained
  126. options to control which ``ABIs`` will be searched.
  127. * The :module:`FindPython3`, :module:`FindPython2`, and :module:`FindPython`
  128. modules now support direct specification of artifacts via cache entries.
  129. Autogen
  130. -------
  131. * When using :prop_tgt:`AUTOMOC`, CMake now generates the ``-p`` path prefix
  132. option for ``moc``. This ensures that ``moc`` output files are identical
  133. on different build setups (given, that the headers compiled by ``moc`` are
  134. in an :command:`include directory <target_include_directories>`).
  135. Also it ensures that ``moc`` output files will compile correctly when the
  136. source and/or build directory is a symbolic link.
  137. The ``moc`` path prefix generation behavior can be configured by setting
  138. the new :variable:`CMAKE_AUTOMOC_PATH_PREFIX` variable and/or
  139. :prop_tgt:`AUTOMOC_PATH_PREFIX` target property.
  140. CTest
  141. -----
  142. * :manual:`ctest(1)` now has the ability to schedule tests based on resource
  143. requirements for each test. See :ref:`ctest-resource-allocation` for
  144. details.
  145. * A new test property, :prop_test:`SKIP_REGULAR_EXPRESSION`, has been added.
  146. This property is similar to :prop_test:`FAIL_REGULAR_EXPRESSION` and
  147. :prop_test:`PASS_REGULAR_EXPRESSION`, but with the same meaning as
  148. :prop_test:`SKIP_RETURN_CODE`. This is useful, for example, in cases where
  149. the user has no control over the return code of the test. For example, in
  150. Catch2, the return value is the number of assertion failed, therefore it is
  151. impossible to use it for :prop_test:`SKIP_RETURN_CODE`.
  152. CPack
  153. -----
  154. * CPack variable :variable:`CPACK_INSTALL_CMAKE_CONFIGURATIONS` was added to
  155. control what configurations are to be packaged for multi-configuration
  156. CMake generators.
  157. * The :cpack_gen:`CPack DEB Generator` is now able to format generic text
  158. (usually used as the description for multiple CPack generators) according
  159. to the `Debian Policy Manual`_. See the
  160. :variable:`CPACK_PACKAGE_DESCRIPTION_FILE` and
  161. :variable:`CPACK_DEBIAN_<COMPONENT>_DESCRIPTION` variables.
  162. * The :cpack_gen:`CPack Archive Generator` learned to generate ``.tar.zst``
  163. packages with Zstandard compression.
  164. .. _`Debian Policy Manual`: https://www.debian.org/doc/debian-policy/ch-controlfields.html#description
  165. Deprecated and Removed Features
  166. ===============================
  167. * An explicit deprecation diagnostic was added for policy ``CMP0067``
  168. (``CMP0066`` and below were already deprecated).
  169. The :manual:`cmake-policies(7)` manual explains that the OLD behaviors
  170. of all policies are deprecated and that projects should port to the
  171. NEW behaviors.
  172. * The :variable:`CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY` variable has been
  173. deprecated. Use the :variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY` variable
  174. instead.
  175. * The :module:`GetPrerequisites` module has been deprecated, as it has been
  176. superceded by :command:`file(GET_RUNTIME_DEPENDENCIES)`.
  177. * The ``CPACK_INSTALL_SCRIPT`` variable has been deprecated in favor of the
  178. new, more accurately named :variable:`CPACK_INSTALL_SCRIPTS` variable.
  179. Other Changes
  180. =============
  181. * The :manual:`cmake(1)` ``-C <initial-cache>`` option now evaluates the
  182. initial cache script with :variable:`CMAKE_SOURCE_DIR` and
  183. :variable:`CMAKE_BINARY_DIR` set to the top-level source and build trees.
  184. * The :manual:`cmake(1)` ``-E remove_directory`` command-line tool,
  185. when given the path to a symlink to a directory, now removes just
  186. the symlink. It no longer removes content of the linked directory.
  187. * The :manual:`ctest(1)` ``--build-makeprogram`` command-line option now
  188. specifies the make program used when configuring a project with the
  189. :generator:`Ninja` generator or the :ref:`Makefile Generators`.
  190. * The :module:`ExternalProject` module :command:`ExternalProject_Add` command
  191. has been updated so that ``GIT_SUBMODULES ""`` initializes no submodules.
  192. See policy :policy:`CMP0097`.
  193. * The :module:`FindGTest` module has been updated to recognize
  194. MSVC build trees generated by GTest 1.8.1.
  195. * The :command:`project` command no longer strips leading zeros in version
  196. components. See policy :policy:`CMP0096`.
  197. * The Qt Compressed Help file is now named ``CMake.qch``, which no longer
  198. contains the release version in the file name. When CMake is upgraded
  199. in-place, the name and location of this file will remain constant.
  200. Tools such as IDEs, help viewers, etc. should now be able to refer to this
  201. file at a fixed location that remains valid across CMake upgrades.
  202. * ``RPATH`` entries are properly escaped in the generated CMake scripts
  203. used for installation. See policy :policy:`CMP0095`.
  204. * When using :variable:`CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS` on Windows the
  205. auto-generated exports are now updated only when the object files
  206. providing the symbols are updated.