3.16.rst 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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 searching
  60. * :variable:`CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH` - Controls the searching
  61. the cmake-specific environment variables.
  62. * :variable:`CMAKE_FIND_USE_CMAKE_PATH` - Controls the searching the
  63. cmake-specific cache variables.
  64. * :variable:`CMAKE_FIND_USE_CMAKE_SYSTEM_PATH` - Controls the searching
  65. cmake platform specific variables.
  66. * :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` - Controls the searching of
  67. :variable:`<PackageName>_ROOT` variables.
  68. * :variable:`CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH` - Controls the searching
  69. the standard system environment variables.
  70. * The :command:`find_package` command has learned to check the following
  71. variables to control searching
  72. * :variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY` - Controls the searching the
  73. cmake user 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. Properties
  87. ----------
  88. * The :prop_tgt:`BUILD_RPATH` and :prop_tgt:`INSTALL_RPATH` target properties
  89. now support :manual:`generator expressions <cmake-generator-expressions(7)>`.
  90. * The :prop_tgt:`INSTALL_REMOVE_ENVIRONMENT_RPATH` target property was
  91. added to remove compiler-defined ``RPATH`` entries from a target.
  92. This property is initialized by the
  93. :variable:`CMAKE_INSTALL_REMOVE_ENVIRONMENT_RPATH` variable.
  94. * The :prop_tgt:`PRECOMPILE_HEADERS` target property was added to specify
  95. a list of headers to precompile for faster compilation times.
  96. Set it using the :command:`target_precompile_headers` command.
  97. * The :prop_tgt:`UNITY_BUILD` target property was added to tell
  98. generators to batch include source files for faster compilation
  99. times.
  100. * The :prop_tgt:`VS_CONFIGURATION_TYPE` target property now supports
  101. :manual:`generator expressions <cmake-generator-expressions(7)>`.
  102. * The :prop_tgt:`VS_DPI_AWARE` target property was added to tell
  103. :ref:`Visual Studio Generators` to set the ``EnableDpiAwareness``
  104. property in ``.vcxproj`` files.
  105. * The :prop_tgt:`XCODE_SCHEME_DEBUG_DOCUMENT_VERSIONING` target property was
  106. added to tell the :generator:`Xcode` generator to set the value of the
  107. ``Allow debugging when using document Versions Browser`` schema option.
  108. Modules
  109. -------
  110. * The :module:`FindDoxygen` module :command:`doxygen_add_docs` command
  111. gained a new ``USE_STAMP_FILE`` option. When this option present,
  112. the custom target created by the command will only re-run Doxygen if
  113. any of the source files have changed since the last successful run.
  114. * The :module:`FindGnuTLS` module now provides an imported target.
  115. * The :module:`FindPackageHandleStandardArgs` module
  116. :command:`find_package_handle_standard_args` command gained
  117. a new ``REASON_FAILURE_MESSAGE`` option to specify a message
  118. giving the reason for the failure.
  119. * The :module:`FindPkgConfig` module :command:`pkg_search_module` macro
  120. now defines a ``<prefix>_MODULE_NAME`` result variable containing the
  121. first matching module name.
  122. * The :module:`FindPython3` and :module:`FindPython` modules gained
  123. options to control which ``ABIs`` will be searched.
  124. * The :module:`FindPython3`, :module:`FindPython2`, and :module:`FindPython`
  125. modules now support direct specification of artifacts via cache entries.
  126. Autogen
  127. -------
  128. * When using :prop_tgt:`AUTOMOC`, CMake now generates the ``-p`` path prefix
  129. option for ``moc``. This ensures that ``moc`` output files are identical
  130. on different build setups (given, that the headers compiled by ``moc`` are
  131. in an :command:`include directory <target_include_directories>`).
  132. Also it ensures that ``moc`` output files will compile correctly when the
  133. source and/or build directory is a symbolic link.
  134. The ``moc`` path prefix generation behavior can be configured by setting
  135. the new :variable:`CMAKE_AUTOMOC_PATH_PREFIX` variable and/or
  136. :prop_tgt:`AUTOMOC_PATH_PREFIX` target property.
  137. CTest
  138. -----
  139. * :manual:`ctest(1)` now has the ability to serialize tests based on hardware
  140. requirements for each test. See :ref:`ctest-hardware-allocation` for
  141. details.
  142. * A new test property, :prop_test:`SKIP_REGULAR_EXPRESSION`, has been added.
  143. This property is similar to :prop_test:`FAIL_REGULAR_EXPRESSION` and
  144. :prop_test:`PASS_REGULAR_EXPRESSION`, but with the same meaning as
  145. :prop_test:`SKIP_RETURN_CODE`. This is useful, for example, in cases where
  146. the user has no control over the return code of the test. For example, in
  147. Catch2, the return value is the number of assertion failed, therefore it is
  148. impossible to use it for :prop_test:`SKIP_RETURN_CODE`.
  149. CPack
  150. -----
  151. * CPack variable :variable:`CPACK_INSTALL_CMAKE_CONFIGURATIONS` was added to
  152. control what configurations are to be packaged for multi-configuration
  153. CMake generators.
  154. * The :cpack_gen:`CPack DEB Generator` is now able to format generic text
  155. (usually used as the description for multiple CPack generators) according
  156. to the `Debian Policy Manual`_. See the
  157. :variable:`CPACK_PACKAGE_DESCRIPTION_FILE` and
  158. :variable:`CPACK_DEBIAN_<COMPONENT>_DESCRIPTION` variables.
  159. * The :cpack_gen:`CPack Archive Generator` learned to generate ``.tar.zst``
  160. packages with Zstandard compression.
  161. .. _`Debian Policy Manual`: https://www.debian.org/doc/debian-policy/ch-controlfields.html#description
  162. Deprecated and Removed Features
  163. ===============================
  164. * An explicit deprecation diagnostic was added for policy ``CMP0067``
  165. (``CMP0066`` and below were already deprecated).
  166. The :manual:`cmake-policies(7)` manual explains that the OLD behaviors
  167. of all policies are deprecated and that projects should port to the
  168. NEW behaviors.
  169. * The :variable:`CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY` variable has been
  170. deprecated. Use the :variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY` variable
  171. instead.
  172. * The :module:`GetPrerequisites` module has been deprecated, as it has been
  173. superceded by :command:`file(GET_RUNTIME_DEPENDENCIES)`.
  174. * The ``CPACK_INSTALL_SCRIPT`` variable has been deprecated in favor of the
  175. new, more accurately named :variable:`CPACK_INSTALL_SCRIPTS` variable.
  176. Other Changes
  177. =============
  178. * The :manual:`cmake(1)` ``-C <initial-cache>`` option now evaluates the
  179. initial cache script with :variable:`CMAKE_SOURCE_DIR` and
  180. :variable:`CMAKE_BINARY_DIR` set to the top-level source and build trees.
  181. * The :manual:`cmake(1)` ``-E remove_directory`` command-line tool,
  182. when given the path to a symlink to a directory, now removes just
  183. the symlink. It no longer removes content of the linked directory.
  184. * The :manual:`ctest(1)` ``--build-makeprogram`` command-line option now
  185. specifies the make program used when configuring a project with the
  186. :generator:`Ninja` generator or the :ref:`Makefile Generators`.
  187. * The :module:`ExternalProject` module :command:`ExternalProject_Add` command
  188. has been updated so that ``GIT_SUBMODULES ""`` initializes no submodules.
  189. See policy :policy:`CMP0097`.
  190. * The :module:`FindGTest` module has been updated to recognize
  191. MSVC build trees generated by GTest 1.8.1.
  192. * The :command:`project` command no longer strips leading zeros in version
  193. components. See policy :policy:`CMP0096`.
  194. * The Qt Compressed Help file is now named ``CMake.qch``, which no longer
  195. contains the release version in the file name. When CMake is upgraded
  196. in-place, the name and location of this file will remain constant.
  197. Tools such as IDEs, help viewers, etc. should now be able to refer to this
  198. file at a fixed location that remains valid across CMake upgrades.
  199. * ``RPATH`` entries are properly escaped in the generated CMake scripts
  200. used for installation. See policy :policy:`CMP0095`.
  201. * When using :variable:`CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS` on Windows the
  202. auto-generated exports are now updated only when the object files
  203. providing the symbols are updated.