3.18.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  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:`UNITY_BUILD_MODE` target property was added to tell
  88. generators which algorithm to use for grouping included source
  89. files.
  90. * The :prop_tgt:`VS_SOURCE_SETTINGS_<tool>` target property was added
  91. to tell :ref:`Visual Studio Generators` for VS 2010 and above to add
  92. metadata to non-built source files using ``<tool>``.
  93. * The :prop_sf:`VS_SETTINGS` source file property was added to tell
  94. :ref:`Visual Studio Generators` for VS 2010 and above to add
  95. metadata to a non-built source file.
  96. * The :prop_tgt:`VS_PLATFORM_TOOLSET` target property was added to tell
  97. :ref:`Visual Studio Generators` for VS 2010 and above to override
  98. the platform toolset.
  99. * The :prop_tgt:`VS_SOLUTION_DEPLOY` target property was added to tell
  100. :ref:`Visual Studio Generators` for VS 2010 and above to mark a
  101. target for deployment even when not building for Windows Phone/Store/CE.
  102. Modules
  103. -------
  104. * The :module:`CheckLinkerFlag` module has been added to provide a
  105. facility to check validity of link flags.
  106. * The :module:`ExternalProject` module :command:`ExternalProject_Add` command
  107. gained a new ``GIT_REMOTE_UPDATE_STRATEGY`` keyword. This can be used to
  108. specify how failed rebase operations during a git update should be handled.
  109. The ``CMAKE_EP_GIT_REMOTE_UPDATE_STRATEGY`` variable was also added as a
  110. global default and is honored by both the :module:`ExternalProject` and
  111. :module:`FetchContent` modules.
  112. * The :module:`FetchContent` module :command:`FetchContent_Declare` command
  113. now supports a ``SOURCE_SUBDIR`` option. It can be used to direct
  114. :command:`FetchContent_MakeAvailable` to look in a different location
  115. for the ``CMakeLists.txt`` file.
  116. * The :module:`FindBLAS` module now provides an imported target.
  117. * The :module:`FindLAPACK` module now provides an imported target.
  118. * The :module:`FindPython3`, :module:`FindPython2` and :module:`FindPython`
  119. modules:
  120. * gained the possibility to create per-artifact cache variables for
  121. interactive editing in :manual:`cmake-gui(1)` and :manual:`ccmake(1)`.
  122. * gained sub-components ``Development.Module`` and
  123. ``Development.Embed`` under the ``Development`` component.
  124. * gained the capability to specify which Python implementations to find,
  125. including ``IronPython`` and ``PyPy``.
  126. * The :module:`FindRuby` module input and output variables were all renamed
  127. from ``RUBY_`` to ``Ruby_`` for consistency with other find modules.
  128. Input variables of the old case will be honored if provided, and output
  129. variables of the old case are always provided.
  130. * The :module:`FindSWIG` module now accepts target languages as ``COMPONENTS``
  131. and ``OPTIONAL_COMPONENTS`` arguments to ``find_package``.
  132. * The :module:`GoogleTest` module :command:`gtest_discover_tests` command:
  133. * gained a new ``DISCOVERY_MODE`` option to control when the test
  134. discovery step is run. It offers a new ``PRE_TEST`` setting to
  135. run the discovery at test time instead of build time.
  136. * gained a new optional parameter ``XML_OUTPUT_DIR``. When set the
  137. JUnit XML test results are stored in that directory.
  138. * The :module:`FindLibXslt` module now provides imported targets.
  139. * The :module:`UseSWIG` module now supports Fortran as a target language if
  140. the ``SWIG_EXECUTABLE`` is SWIG-Fortran_.
  141. .. _`SWIG-Fortran`: https://github.com/swig-fortran/swig
  142. * The :module:`FindCUDAToolkit` module:
  143. * gained the variable
  144. ``CUDAToolkit_LIBRARY_ROOT``, which is the directory containing the
  145. ``nvvm`` directory and ``version.txt``.
  146. * uses toolkit and library root found during ``CUDA`` compiler detection.
  147. Generator Expressions
  148. ---------------------
  149. * The ``$<DEVICE_LINK:...>`` and ``$<HOST_LINK:...>``
  150. :manual:`generator expressions <cmake-generator-expressions(7)>` were added
  151. to manage device and host link steps.
  152. * The ``$<LINK_LANGUAGE:...>`` and ``$<LINK_LANG_AND_ID:...>``
  153. :manual:`generator expressions <cmake-generator-expressions(7)>` were added.
  154. CTest
  155. -----
  156. * :manual:`ctest(1)` gained a new :variable:`CTEST_RESOURCE_SPEC_FILE`
  157. variable, which can be used to specify a
  158. :ref:`resource specification file <ctest-resource-specification-file>`.
  159. * :manual:`ctest(1)` gained a ``--stop-on-failure`` option,
  160. which can be used to stop running the tests once one has failed.
  161. * The :command:`ctest_test` command gained a ``STOP_ON_FAILURE`` option
  162. which can be used to stop running the tests once one has failed.
  163. * The :module:`CTestCoverageCollectGCOV` module
  164. :command:`ctest_coverage_collect_gcov` command gained a
  165. ``TARBALL_COMPRESSION`` option to control compression of the
  166. tarball of collected results.
  167. CPack
  168. -----
  169. * The :cpack_gen:`CPack Archive Generator`'s ``TXZ`` format learned the
  170. :variable:`CPACK_ARCHIVE_THREADS` variable to enable parallel compression.
  171. Requires support in the ``liblzma`` used by CMake.
  172. * The :cpack_gen:`CPack NSIS Generator` gained a new variable
  173. :variable:`CPACK_NSIS_MANIFEST_DPI_AWARE` to declare that the
  174. installer is DPI-aware.
  175. * The :cpack_gen:`CPack RPM Generator` gained
  176. :variable:`CPACK_RPM_PRE_TRANS_SCRIPT_FILE`
  177. :variable:`CPACK_RPM_POST_TRANS_SCRIPT_FILE`
  178. variables to specify pre- and post-trans scripts.
  179. Other
  180. -----
  181. * :manual:`cmake-gui(1)` now populates its generator selection
  182. widget default value from the :envvar:`CMAKE_GENERATOR` environment
  183. variable. Additionally, environment variables
  184. :envvar:`CMAKE_GENERATOR_PLATFORM` and :envvar:`CMAKE_GENERATOR_TOOLSET`
  185. are used to populate their respective widget defaults.
  186. * :manual:`ccmake(1)` learned to read a :envvar:`CCMAKE_COLORS`
  187. environment variable to customize colors.
  188. Deprecated and Removed Features
  189. ===============================
  190. * The :module:`Documentation` module has been deprecated via
  191. :policy:`CMP0106`. This module was essentially VTK code that CMake should
  192. not be shipping anymore.
  193. * An explicit deprecation diagnostic was added for policy ``CMP0070``
  194. and policy ``CMP0071`` (``CMP0069`` and below were already deprecated).
  195. The :manual:`cmake-policies(7)` manual explains that the OLD behaviors
  196. of all policies are deprecated and that projects should port to the
  197. NEW behaviors.
  198. Other Changes
  199. =============
  200. * On Windows, the :generator:`Ninja` and :generator:`Ninja Multi-Config`
  201. generators, when a compiler is not explicitly specified, now select
  202. the first compiler (of any name) found in directories listed by the
  203. ``PATH`` environment variable.
  204. * The :prop_tgt:`LINK_OPTIONS` and :prop_tgt:`INTERFACE_LINK_OPTIONS` target
  205. properties are now used for the device link step.
  206. See policy :policy:`CMP0105`.
  207. * Creation of an ``ALIAS`` target overwriting an existing target now raises an
  208. error. See policy :policy:`CMP0107`.
  209. * Linking a target to itself through an alias now raises an error.
  210. See policy :policy:`CMP0108`.
  211. * The :module:`FindPackageHandleStandardArgs` module option ``REQUIRED_VARS``
  212. is now optional if ``HANDLE_COMPONENTS`` is specified.
  213. * The :command:`source_group` command now also recognizes forward slashes
  214. as subgroup delimiters, not just backslashes.
  215. * :manual:`ctest(1)` now logs environment variables that it sets for each test,
  216. either due to the :prop_test:`ENVIRONMENT` property or the
  217. :ref:`resource allocation <ctest-resource-allocation>` feature, and submits
  218. this log to CDash. It does not log environment variables that were set
  219. outside of CTest.
  220. * When building CMake itself from source and not using a system-provided
  221. libcurl, HTTP/2 support is now enabled for commands supporting
  222. network communication via ``http(s)``, such as :command:`file(DOWNLOAD)`,
  223. :command:`file(UPLOAD)`, and :command:`ctest_submit`.
  224. The precompiled binaries provided on ``cmake.org`` now support HTTP/2.