3.18.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. CMake 3.18 Release Notes
  2. ************************
  3. .. only:: html
  4. .. contents::
  5. Changes made since CMake 3.17 include the following.
  6. New Features
  7. ============
  8. Languages
  9. ---------
  10. * The ``CUDA`` language can now be compiled using Clang on non-Windows
  11. platforms. Separable compilation is not yet supported on any platform.
  12. Command-Line
  13. ------------
  14. * :manual:`cmake(1)` gained support for profiling of CMake scripts through
  15. the parameters ``--profiling-output`` and ``--profiling-format``.
  16. * :manual:`cmake(1)` gained a ``cat`` command line
  17. option that can be used to concatenate files and print them
  18. on standard output.
  19. Commands
  20. --------
  21. * The :command:`add_library` and :command:`add_executable` commands
  22. learned to create :ref:`Alias Targets` referencing non-``GLOBAL``
  23. :ref:`Imported Targets`.
  24. * The :command:`cmake_language()` command was added for meta-operations on
  25. scripted or built-in commands, starting with a mode to ``CALL`` other
  26. commands, and ``EVAL CODE`` to inplace evaluate a CMake script.
  27. * The :command:`execute_process` command gained the ``ECHO_OUTPUT_VARIABLE``
  28. and ``ECHO_ERROR_VARIABLE`` options.
  29. * The :command:`export` command now raise an error if used multiple times with
  30. same ``FILE`` without ``APPEND``. See policy :policy:`CMP0103`.
  31. * The :command:`file` command gained the ``ARCHIVE_CREATE`` and
  32. ``ARCHIVE_EXTRACT`` subcommands to expose the :manual:`cmake(1)` ``-E tar``
  33. functionality to CMake scripting code.
  34. * The :command:`file(CONFIGURE)` subcommand was created in order to replicate
  35. the :command:`configure_file` functionality without resorting to a
  36. pre-existing file on disk as input. The content is instead passed as a
  37. string.
  38. * The :command:`file(UPLOAD)` command gained ``TLS_VERIFY`` and ``TLS_CAINFO``
  39. options to control server certificate verification.
  40. * The :command:`find_program`, :command:`find_library`, :command:`find_path`
  41. and :command:`find_file` commands gained a new ``REQUIRED`` option that will
  42. stop processing with an error message if nothing is found.
  43. * The :command:`get_property` command with ``SOURCE`` scope gained the
  44. ``DIRECTORY`` and ``TARGET_DIRECTORY`` options to get a property
  45. from the provided directory scope.
  46. * The :command:`get_source_file_property` command gained the ``DIRECTORY``
  47. and ``TARGET_DIRECTORY`` options to get a property from the
  48. provided directory scope.
  49. * The :command:`list` operation ``SORT`` gained the ``NATURAL`` sort
  50. option to sort using natural order (see ``strverscmp(3)`` manual).
  51. * The :command:`set_property` command with the ``SOURCE`` scope gained the
  52. ``DIRECTORY`` and ``TARGET_DIRECTORY`` options to set properties
  53. in the provided directory scopes.
  54. * The :command:`set_source_files_properties` command gained the ``DIRECTORY``
  55. and ``TARGET_DIRECTORY`` options to set properties in the provided
  56. directory scopes.
  57. * The :command:`string` command learned a new ``HEX`` sub-command, which
  58. converts strings into their hexadecimal representation.
  59. Variables
  60. ---------
  61. * A :variable:`CMAKE_CUDA_ARCHITECTURES` variable was added to specify
  62. CUDA output architectures. Users are encouraged to use this instead of
  63. specifying options manually, as this approach is compiler-agnostic.
  64. The variable is initialized automatically when
  65. :variable:`CMAKE_CUDA_COMPILER_ID <CMAKE_<LANG>_COMPILER_ID>` is ``NVIDIA``.
  66. The variable is used to initialize the new :prop_tgt:`CUDA_ARCHITECTURES`
  67. target property. See policy :policy:`CMP0104`.
  68. * The :variable:`CMAKE_PCH_WARN_INVALID` variable was added to initialize the
  69. :prop_tgt:`PCH_WARN_INVALID` target property to allow the removal of the
  70. precompiled header invalid warning.
  71. Properties
  72. ----------
  73. * The :prop_tgt:`CUDA_ARCHITECTURES` target property was added to specify
  74. CUDA output architectures. Users are encouraged to use this instead of
  75. specifying options manually, as this approach is compiler-agnostic.
  76. The property is initialized by the new :variable:`CMAKE_CUDA_ARCHITECTURES`
  77. variable. See policy :policy:`CMP0104`.
  78. * The :prop_tgt:`Fortran_PREPROCESS` target property and
  79. :prop_sf:`Fortran_PREPROCESS` source-file property were added to
  80. control preprocessing of Fortran source files.
  81. * The :prop_tgt:`FRAMEWORK_MULTI_CONFIG_POSTFIX_<CONFIG>` target property
  82. and associated :variable:`CMAKE_FRAMEWORK_MULTI_CONFIG_POSTFIX_<CONFIG>`
  83. variable were created to allow adding a postfix to the name of a
  84. framework file name when using a multi-config generator.
  85. * The :prop_sf:`OBJECT_OUTPUTS` source file property now supports
  86. :manual:`generator expressions <cmake-generator-expressions(7)>`.
  87. * The :prop_tgt:`PCH_WARN_INVALID` target property was added to allow the
  88. removal of the precompiled header invalid warning.
  89. * The :prop_tgt:`UNITY_BUILD_MODE` target property was added to tell
  90. generators which algorithm to use for grouping included source
  91. files.
  92. * The :prop_tgt:`VS_SOURCE_SETTINGS_<tool>` target property was added
  93. to tell :ref:`Visual Studio Generators` for VS 2010 and above to add
  94. metadata to non-built source files using ``<tool>``.
  95. * The :prop_sf:`VS_SETTINGS` source file property was added to tell
  96. :ref:`Visual Studio Generators` for VS 2010 and above to add
  97. metadata to a non-built source file.
  98. * The :prop_tgt:`VS_PLATFORM_TOOLSET` target property was added to tell
  99. :ref:`Visual Studio Generators` for VS 2010 and above to override
  100. the platform toolset.
  101. * The :prop_tgt:`VS_SOLUTION_DEPLOY` target property was added to tell
  102. :ref:`Visual Studio Generators` for VS 2010 and above to mark a
  103. target for deployment even when not building for Windows Phone/Store/CE.
  104. Modules
  105. -------
  106. * The :module:`CheckLinkerFlag` module has been added to provide a
  107. facility to check validity of link flags.
  108. * The :module:`ExternalProject` module :command:`ExternalProject_Add` command
  109. gained a new ``GIT_REMOTE_UPDATE_STRATEGY`` keyword. This can be used to
  110. specify how failed rebase operations during a git update should be handled.
  111. The ``CMAKE_EP_GIT_REMOTE_UPDATE_STRATEGY`` variable was also added as a
  112. global default and is honored by both the :module:`ExternalProject` and
  113. :module:`FetchContent` modules.
  114. * The :module:`FetchContent` module :command:`FetchContent_Declare` command
  115. now supports a ``SOURCE_SUBDIR`` option. It can be used to direct
  116. :command:`FetchContent_MakeAvailable` to look in a different location
  117. for the ``CMakeLists.txt`` file.
  118. * The :module:`FindBLAS` module now provides an imported target.
  119. * The :module:`FindCUDAToolkit` module:
  120. * gained the variable
  121. ``CUDAToolkit_LIBRARY_ROOT``, which is the directory containing the
  122. ``nvvm`` directory and ``version.txt``.
  123. * uses toolkit and library root found during ``CUDA`` compiler detection.
  124. * The :module:`FindLAPACK` module now provides an imported target.
  125. * The :module:`FindPython3`, :module:`FindPython2` and :module:`FindPython`
  126. modules:
  127. * gained the possibility to create per-artifact cache variables for
  128. interactive editing in :manual:`cmake-gui(1)` and :manual:`ccmake(1)`.
  129. * gained sub-components ``Development.Module`` and
  130. ``Development.Embed`` under the ``Development`` component.
  131. * gained the capability to specify which Python implementations to find,
  132. including ``IronPython`` and ``PyPy``.
  133. * The :module:`FindRuby` module input and output variables were all renamed
  134. from ``RUBY_`` to ``Ruby_`` for consistency with other find modules.
  135. Input variables of the old case will be honored if provided, and output
  136. variables of the old case are always provided.
  137. * The :module:`FindSWIG` module now accepts target languages as ``COMPONENTS``
  138. and ``OPTIONAL_COMPONENTS`` arguments to ``find_package``.
  139. * The :module:`GoogleTest` module :command:`gtest_discover_tests` command:
  140. * gained a new ``DISCOVERY_MODE`` option to control when the test
  141. discovery step is run. It offers a new ``PRE_TEST`` setting to
  142. run the discovery at test time instead of build time. A new
  143. ``CMAKE_GTEST_DISCOVER_TESTS_DISCOVERY_MODE`` variable can be used
  144. to change the default globally.
  145. * gained a new optional parameter ``XML_OUTPUT_DIR``. When set the
  146. JUnit XML test results are stored in that directory.
  147. * The :module:`FindLibXslt` module now provides imported targets.
  148. * The :module:`UseSWIG` module now supports Fortran as a target language if
  149. the ``SWIG_EXECUTABLE`` is SWIG-Fortran_.
  150. .. _`SWIG-Fortran`: https://github.com/swig-fortran/swig
  151. Generator Expressions
  152. ---------------------
  153. * The ``$<DEVICE_LINK:...>`` and ``$<HOST_LINK:...>``
  154. :manual:`generator expressions <cmake-generator-expressions(7)>` were added
  155. to manage device and host link steps.
  156. * The ``$<LINK_LANGUAGE:...>`` and ``$<LINK_LANG_AND_ID:...>``
  157. :manual:`generator expressions <cmake-generator-expressions(7)>` were added.
  158. CTest
  159. -----
  160. * :manual:`ctest(1)` gained a new :variable:`CTEST_RESOURCE_SPEC_FILE`
  161. variable, which can be used to specify a
  162. :ref:`resource specification file <ctest-resource-specification-file>`.
  163. * :manual:`ctest(1)` gained a ``--stop-on-failure`` option,
  164. which can be used to stop running the tests once one has failed.
  165. * The :command:`ctest_test` command gained a ``STOP_ON_FAILURE`` option
  166. which can be used to stop running the tests once one has failed.
  167. * The :module:`CTestCoverageCollectGCOV` module
  168. :command:`ctest_coverage_collect_gcov` command gained a
  169. ``TARBALL_COMPRESSION`` option to control compression of the
  170. tarball of collected results.
  171. CPack
  172. -----
  173. * The :cpack_gen:`CPack Archive Generator`'s ``TXZ`` format learned the
  174. :variable:`CPACK_ARCHIVE_THREADS` variable to enable parallel compression.
  175. Requires support in the ``liblzma`` used by CMake.
  176. * The :cpack_gen:`CPack NSIS Generator` gained a new variable
  177. :variable:`CPACK_NSIS_MANIFEST_DPI_AWARE` to declare that the
  178. installer is DPI-aware.
  179. * The :cpack_gen:`CPack RPM Generator` gained
  180. :variable:`CPACK_RPM_PRE_TRANS_SCRIPT_FILE` and
  181. :variable:`CPACK_RPM_POST_TRANS_SCRIPT_FILE`
  182. variables to specify pre- and post-transaction scripts.
  183. Other
  184. -----
  185. * :manual:`cmake-gui(1)` now populates its generator selection
  186. widget default value from the :envvar:`CMAKE_GENERATOR` environment
  187. variable. Additionally, environment variables
  188. :envvar:`CMAKE_GENERATOR_PLATFORM` and :envvar:`CMAKE_GENERATOR_TOOLSET`
  189. are used to populate their respective widget defaults.
  190. * :manual:`ccmake(1)` learned to read a :envvar:`CCMAKE_COLORS`
  191. environment variable to customize colors.
  192. Deprecated and Removed Features
  193. ===============================
  194. * The :module:`Documentation` module has been deprecated via
  195. :policy:`CMP0106`. This module was essentially VTK code that CMake should
  196. not be shipping anymore.
  197. * An explicit deprecation diagnostic was added for policy ``CMP0070``
  198. and policy ``CMP0071`` (``CMP0069`` and below were already deprecated).
  199. The :manual:`cmake-policies(7)` manual explains that the OLD behaviors
  200. of all policies are deprecated and that projects should port to the
  201. NEW behaviors.
  202. Other Changes
  203. =============
  204. * On Windows, the :generator:`Ninja` and :generator:`Ninja Multi-Config`
  205. generators, when a compiler is not explicitly specified, now select
  206. the first compiler (of any name) found in directories listed by the
  207. ``PATH`` environment variable.
  208. * The :prop_tgt:`LINK_OPTIONS` and :prop_tgt:`INTERFACE_LINK_OPTIONS` target
  209. properties are now used for the device link step.
  210. See policy :policy:`CMP0105`.
  211. * Creation of an ``ALIAS`` target overwriting an existing target now raises an
  212. error. See policy :policy:`CMP0107`.
  213. * Linking a target to itself through an alias now raises an error.
  214. See policy :policy:`CMP0108`.
  215. * The :module:`FindPackageHandleStandardArgs` module option ``REQUIRED_VARS``
  216. is now optional if ``HANDLE_COMPONENTS`` is specified.
  217. * The :command:`source_group` command now also recognizes forward slashes
  218. as subgroup delimiters, not just backslashes.
  219. * :manual:`ctest(1)` now logs environment variables that it sets for each test,
  220. either due to the :prop_test:`ENVIRONMENT` property or the
  221. :ref:`resource allocation <ctest-resource-allocation>` feature, and submits
  222. this log to CDash. It does not log environment variables that were set
  223. outside of CTest.
  224. * When building CMake itself from source and not using a system-provided
  225. libcurl, HTTP/2 support is now enabled for commands supporting
  226. network communication via ``http(s)``, such as :command:`file(DOWNLOAD)`,
  227. :command:`file(UPLOAD)`, and :command:`ctest_submit`.
  228. The precompiled binaries provided on ``cmake.org`` now support HTTP/2.
  229. * The :manual:`cmake-file-api(7)` "codemodel" version 2 ``version`` field has
  230. been updated to 2.1.
  231. * The :manual:`cmake-file-api(7)` "codemodel" version 2 "target" object gained
  232. a new ``precompileHeaders`` field in the ``compileGroups`` objects.