3.16.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  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 and to check the
  74. :variable:`CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY` variable to control
  75. the default behavior of searching the CMake system package registry.
  76. * The :command:`message` command learned indentation control with the new
  77. :variable:`CMAKE_MESSAGE_INDENT` variable.
  78. * The :command:`target_precompile_headers` command was added to specify
  79. a list of headers to precompile for faster compilation times.
  80. Variables
  81. ---------
  82. * The :variable:`CMAKE_CUDA_RESOLVE_DEVICE_SYMBOLS` variable has been
  83. introduced to optionally initialize the
  84. :prop_tgt:`CUDA_RESOLVE_DEVICE_SYMBOLS` target property.
  85. * The :variable:`CMAKE_ECLIPSE_RESOURCE_ENCODING` variable was added to
  86. specify the resource encoding for the the :generator:`Eclipse CDT4` extra
  87. generator.
  88. * The :variable:`CMAKE_UNITY_BUILD` variable was added to initialize the
  89. :prop_tgt:`UNITY_BUILD` target property to tell generators to batch
  90. include source files for faster compilation times.
  91. Properties
  92. ----------
  93. * The :prop_tgt:`BUILD_RPATH` and :prop_tgt:`INSTALL_RPATH` target properties
  94. now support :manual:`generator expressions <cmake-generator-expressions(7)>`.
  95. * The :prop_tgt:`INSTALL_REMOVE_ENVIRONMENT_RPATH` target property was
  96. added to remove compiler-defined ``RPATH`` entries from a target.
  97. This property is initialized by the
  98. :variable:`CMAKE_INSTALL_REMOVE_ENVIRONMENT_RPATH` variable.
  99. * The :prop_tgt:`PRECOMPILE_HEADERS` target property was added to specify
  100. a list of headers to precompile for faster compilation times.
  101. Set it using the :command:`target_precompile_headers` command.
  102. * The :prop_tgt:`UNITY_BUILD` target property was added to tell
  103. generators to batch include source files for faster compilation
  104. times.
  105. * The :prop_tgt:`VS_CONFIGURATION_TYPE` target property now supports
  106. :manual:`generator expressions <cmake-generator-expressions(7)>`.
  107. * The :prop_tgt:`VS_DPI_AWARE` target property was added to tell
  108. :ref:`Visual Studio Generators` to set the ``EnableDpiAwareness``
  109. property in ``.vcxproj`` files.
  110. * The :prop_tgt:`XCODE_SCHEME_DEBUG_DOCUMENT_VERSIONING` target property was
  111. added to tell the :generator:`Xcode` generator to set the value of the
  112. ``Allow debugging when using document Versions Browser`` schema option.
  113. Modules
  114. -------
  115. * The :module:`FindDoxygen` module :command:`doxygen_add_docs` command
  116. gained a new ``USE_STAMP_FILE`` option. When this option present,
  117. the custom target created by the command will only re-run Doxygen if
  118. any of the source files have changed since the last successful run.
  119. * The :module:`FindGnuTLS` module now provides an imported target.
  120. * The :module:`FindPackageHandleStandardArgs` module
  121. :command:`find_package_handle_standard_args` command gained
  122. a new ``REASON_FAILURE_MESSAGE`` option to specify a message
  123. giving the reason for the failure.
  124. * The :module:`FindPkgConfig` module :command:`pkg_search_module` macro
  125. now defines a ``<prefix>_MODULE_NAME`` result variable containing the
  126. first matching module name.
  127. * The :module:`FindPython3` and :module:`FindPython` modules gained
  128. options to control which ``ABIs`` will be searched.
  129. * The :module:`FindPython3`, :module:`FindPython2`, and :module:`FindPython`
  130. modules now support direct specification of artifacts via cache entries.
  131. Autogen
  132. -------
  133. * When using :prop_tgt:`AUTOMOC`, CMake now generates the ``-p`` path prefix
  134. option for ``moc``. This ensures that ``moc`` output files are identical
  135. on different build setups (given, that the headers compiled by ``moc`` are
  136. in an :command:`include directory <target_include_directories>`).
  137. Also it ensures that ``moc`` output files will compile correctly when the
  138. source and/or build directory is a symbolic link.
  139. The ``moc`` path prefix generation behavior can be configured by setting
  140. the new :variable:`CMAKE_AUTOMOC_PATH_PREFIX` variable and/or
  141. :prop_tgt:`AUTOMOC_PATH_PREFIX` target property.
  142. CTest
  143. -----
  144. * :manual:`ctest(1)` now has the ability to schedule tests based on resource
  145. requirements for each test. See :ref:`ctest-resource-allocation` for
  146. details.
  147. * A new test property, :prop_test:`SKIP_REGULAR_EXPRESSION`, has been added.
  148. This property is similar to :prop_test:`FAIL_REGULAR_EXPRESSION` and
  149. :prop_test:`PASS_REGULAR_EXPRESSION`, but with the same meaning as
  150. :prop_test:`SKIP_RETURN_CODE`. This is useful, for example, in cases where
  151. the user has no control over the return code of the test. For example, in
  152. Catch2, the return value is the number of assertion failed, therefore it is
  153. impossible to use it for :prop_test:`SKIP_RETURN_CODE`.
  154. CPack
  155. -----
  156. * :manual:`cpack(1)` learned support for multiple configurations for ``-C``
  157. option.
  158. * The :cpack_gen:`CPack DEB Generator` is now able to format generic text
  159. (usually used as the description for multiple CPack generators) according
  160. to the `Debian Policy Manual`_. See the
  161. :variable:`CPACK_PACKAGE_DESCRIPTION_FILE` and
  162. :variable:`CPACK_DEBIAN_<COMPONENT>_DESCRIPTION` variables.
  163. * The :cpack_gen:`CPack Archive Generator` learned to generate ``.tar.zst``
  164. packages with Zstandard compression.
  165. .. _`Debian Policy Manual`: https://www.debian.org/doc/debian-policy/ch-controlfields.html#description
  166. Deprecated and Removed Features
  167. ===============================
  168. * An explicit deprecation diagnostic was added for policy ``CMP0067``
  169. (``CMP0066`` and below were already deprecated).
  170. The :manual:`cmake-policies(7)` manual explains that the OLD behaviors
  171. of all policies are deprecated and that projects should port to the
  172. NEW behaviors.
  173. * The :variable:`CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY` variable has been
  174. deprecated. Use the :variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY` variable
  175. instead.
  176. * The :module:`GetPrerequisites` module has been deprecated, as it has been
  177. superceded by :command:`file(GET_RUNTIME_DEPENDENCIES)`.
  178. * The ``CPACK_INSTALL_SCRIPT`` variable has been deprecated in favor of the
  179. new, more accurately named :variable:`CPACK_INSTALL_SCRIPTS` variable.
  180. Other Changes
  181. =============
  182. * The :manual:`cmake(1)` ``-C <initial-cache>`` option now evaluates the
  183. initial cache script with :variable:`CMAKE_SOURCE_DIR` and
  184. :variable:`CMAKE_BINARY_DIR` set to the top-level source and build trees.
  185. * The :manual:`cmake(1)` ``-E remove_directory`` command-line tool,
  186. when given the path to a symlink to a directory, now removes just
  187. the symlink. It no longer removes content of the linked directory.
  188. * The :manual:`ctest(1)` ``--build-makeprogram`` command-line option now
  189. specifies the make program used when configuring a project with the
  190. :generator:`Ninja` generator or the :ref:`Makefile Generators`.
  191. * The :module:`ExternalProject` module :command:`ExternalProject_Add` command
  192. has been updated so that ``GIT_SUBMODULES ""`` initializes no submodules.
  193. See policy :policy:`CMP0097`.
  194. * The :module:`FindGTest` module has been updated to recognize
  195. MSVC build trees generated by GTest 1.8.1.
  196. * The :command:`project` command no longer strips leading zeros in version
  197. components. See policy :policy:`CMP0096`.
  198. * The Qt Compressed Help file is now named ``CMake.qch``, which no longer
  199. contains the release version in the file name. When CMake is upgraded
  200. in-place, the name and location of this file will remain constant.
  201. Tools such as IDEs, help viewers, etc. should now be able to refer to this
  202. file at a fixed location that remains valid across CMake upgrades.
  203. * ``RPATH`` entries are properly escaped in the generated CMake scripts
  204. used for installation. See policy :policy:`CMP0095`.
  205. * When using :variable:`CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS` on Windows the
  206. auto-generated exports are now updated only when the object files
  207. providing the symbols are updated.
  208. Updates
  209. =======
  210. Changes made since CMake 3.16.0 include the following.
  211. 3.16.2
  212. ------
  213. * CMake 3.16.0 and 3.16.1 processed ``.hh`` files with :prop_tgt:`AUTOMOC`.
  214. This was a behavior change from CMake 3.15 and below that can break
  215. existing projects, so it has been reverted as of 3.16.2.
  216. 3.16.5
  217. ------
  218. * The :module:`FindPython`, :module:`FindPython2`, and :module:`FindPython3`
  219. modules no longer create cache entries for ``Python{,2,3}_LIBRARY_RELEASE``
  220. and ``Python{,2,3}_LIBRARY_DEBUG``. Those values are always computed from
  221. other results and so should not be cached. The entries were created by
  222. CMake 3.16.0 through 3.16.4 but were always ``FORCE``-set and could not
  223. be meaningfully edited by users.
  224. Additionally, the modules no longer expose their internal ``_Python*``
  225. cache entries publicly. CMake 3.16.0 through 3.16.4 accidentally
  226. made them visible as advanced cache entries.