4.2.rst 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. CMake 4.2 Release Notes
  2. ***********************
  3. .. only:: html
  4. .. contents::
  5. Changes made since CMake 4.1 include the following.
  6. New Features
  7. ============
  8. File-Based API
  9. --------------
  10. * The :manual:`cmake-file-api(7)` "codemodel" version 2 ``version`` field has
  11. been updated to 2.9.
  12. * The :manual:`cmake-file-api(7)` "codemodel" version 2 "target" and
  13. "directory" objects gained a new ``codemodelVersion`` field.
  14. * The :manual:`cmake-file-api(7)` "codemodel" version 2 now includes imported
  15. targets and all interface library targets in its replies. Previously,
  16. imported targets were omitted, and only those interface targets that
  17. participated in the build system were included. The following changes
  18. support these new additions:
  19. * The "target" object gained ``imported``, ``local``, and ``abstract`` fields.
  20. * The "target" object's ``type`` field can now also hold the value
  21. ``UNKNOWN_LIBRARY``.
  22. * The "codemodel" object's ``configurations`` entries gained a new
  23. ``abstractTargets`` array.
  24. * Entries in the ``directories`` and ``projects`` arrays of the "codemodel"
  25. object's ``configurations`` entries gained a new ``abstractTargetIndexes``
  26. array.
  27. * The :manual:`cmake-file-api(7)` "codemodel" version 2 "target" object gained
  28. new ``linkLibraries``, ``interfaceLinkLibraries``, ``compileDependencies``,
  29. ``interfaceCompileDependencies``, ``objectDependencies``, and
  30. ``orderDependencies`` fields.
  31. Generators
  32. ----------
  33. * The :generator:`Visual Studio 18 2026` generator was added. This is
  34. experimental and based on "Visual Studio 2026 Insiders" because this
  35. version of VS has not been released.
  36. * The :generator:`FASTBuild` generator was added.
  37. Platforms
  38. ---------
  39. * CMake now supports :ref:`Cross Compiling for Emscripten` with simple
  40. toolchain files.
  41. Command-Line
  42. ------------
  43. * The :manual:`cmake(1)` command-line tool now supports
  44. ``cmake -E copy_if_newer`` and ``cmake -E copy_directory_if_newer``
  45. subcommands to copy files based on timestamp comparison instead of
  46. content comparison. These commands copy files only if the source is
  47. newer than the destination, providing better performance for build
  48. systems compared to ``copy_if_different`` which compares file contents.
  49. Commands
  50. --------
  51. * The :command:`cmake_language(TRACE)` command was added to enable or
  52. disable tracing during script execution.
  53. * The :command:`set(CACHE{<variable>}) <set(CACHE)>` and
  54. :command:`unset(CACHE{<variable>}) <unset(CACHE)>` commands were added to
  55. explicitly set and unset cache entries.
  56. * The :command:`string(REGEX QUOTE)` command was added to
  57. generate a regular expression exactly matching a string.
  58. Variables
  59. ---------
  60. * The :variable:`CMAKE_CXX_STDLIB_MODULES_JSON` variable was added to set
  61. the path to the ``import std`` metadata file for the standard library
  62. rather than using the compiler to discover its location.
  63. * The :variable:`CMAKE_INTERMEDIATE_DIR_STRATEGY` variable and corresponding
  64. :envvar:`CMAKE_INTERMEDIATE_DIR_STRATEGY` environment variable were added
  65. to change the strategy used to name intermediate directories used for
  66. object files and other associated target metadata.
  67. * The :variable:`CMAKE_AUTOGEN_INTERMEDIATE_DIR_STRATEGY` variable and
  68. corresponding :envvar:`CMAKE_AUTOGEN_INTERMEDIATE_DIR_STRATEGY` environment
  69. variable were added to change the strategy used to name intermediate
  70. directories used for :manual:`Qt Autogen <cmake-qt(7)>` files.
  71. * The :variable:`CMAKE_SKIP_LINTING` variable and corresponding
  72. :prop_tgt:`SKIP_LINTING` target property were added to tell the
  73. :ref:`Command-Line Build Tool Generators` to skip linting all
  74. sources in a target.
  75. Properties
  76. ----------
  77. * The :prop_sf:`INSTALL_OBJECT_NAME` source file property was added to
  78. control names of installed object files for specific compiled sources.
  79. * The :prop_tgt:`INSTALL_OBJECT_NAME_STRATEGY` target property was added
  80. to control the naming strategy for installed object files.
  81. * The :prop_tgt:`INSTALL_OBJECT_ONLY_USE_DESTINATION` target property was
  82. added to more precisely control the installation path for object files.
  83. * The :prop_sf:`JOB_POOL_COMPILE` source file property was added
  84. to assign individual source compilations to :prop_gbl:`JOB_POOLS`.
  85. * The :prop_sf:`OBJECT_NAME` source file property was added to control
  86. object names of compiled source files.
  87. * The :prop_tgt:`UNITY_BUILD_FILENAME_PREFIX` target property was added
  88. to control names of source files generated by :prop_tgt:`UNITY_BUILD`.
  89. Modules
  90. -------
  91. * Nearly all find modules now provide a ``<PackageName>_VERSION`` result
  92. variable matching the casing of its module name. Existing variants such as
  93. ``<PackageName>_VERSION_STRING`` and uppercased ``<PACKAGENAME>_VERSION``
  94. are deprecated. See documentation of each find module for details.
  95. * The :module:`CheckTypeSize` module's :command:`check_type_size` command
  96. gained a new ``RESULT_VARIABLE`` keyword to customize the result variable
  97. name instead of the default ``HAVE_<size-var>``.
  98. * The :module:`ExternalProject` module's :command:`ExternalProject_Add`
  99. and :command:`ExternalProject_Add_Step` commands now provide options to set
  100. environment variables on the configure, build, install, and test steps.
  101. * The :module:`FindPython3`, :module:`FindPython2`, and :module:`FindPython`
  102. modules no longer make ``NumPy`` depend on ``Development.Module``.
  103. See policy :policy:`CMP0201`.
  104. * The :module:`GoogleTest` module's :command:`gtest_discover_tests()`
  105. command now sets the ``DEF_SOURCE_LINE`` test property for each
  106. discovered test if gtest supports the ``--gtest_output=json`` option.
  107. This test property is used by some IDEs to locate the source for each test.
  108. * The :module:`UseSWIG` module's :command:`swig_add_library` command gained a
  109. ``DEBUG_POSTFIX`` option to control the :prop_tgt:`DEBUG_POSTFIX` target
  110. property.
  111. Generator Expressions
  112. ---------------------
  113. * The :genex:`<LANG>_COMPILER_LINKER_ID <C_COMPILER_LINKER_ID>` and
  114. :genex:`<LANG>_COMPILER_LINKER_FRONTEND_VARIANT <C_COMPILER_LINKER_FRONTEND_VARIANT>`
  115. families of generator expressions were added to access the value of the
  116. associated :variable:`CMAKE_<LANG>_COMPILER_LINKER_ID` and
  117. :variable:`CMAKE_<LANG>_COMPILER_LINKER_FRONTEND_VARIANT` variables.
  118. * The :genex:`TARGET_FILE_BASE_NAME`, :genex:`TARGET_IMPORT_FILE_BASE_NAME`,
  119. :genex:`TARGET_LINKER_FILE_BASE_NAME`,
  120. :genex:`TARGET_LINKER_LIBRARY_FILE_BASE_NAME`,
  121. :genex:`TARGET_LINKER_IMPORT_FILE_BASE_NAME`, and
  122. :genex:`TARGET_PDB_FILE_BASE_NAME`
  123. generator expressions gained a ``POSTFIX`` option to control the inclusion
  124. of the :prop_tgt:`<CONFIG>_POSTFIX` target property as part of the base
  125. names of the corresponding files.
  126. * The :genex:`TARGET_INTERMEDIATE_DIR` generator expression was
  127. added to refer to a target's intermediate files directory in
  128. the build tree.
  129. CPack
  130. -----
  131. * The :variable:`CPACK_PACKAGE_CHECKSUM` variable now supports multiple values.
  132. * The :cpack_gen:`CPack NSIS Generator` gained a
  133. :variable:`CPACK_NSIS_CRC_CHECK` variable for setting the ``CRCCheck``
  134. attribute.
  135. * The :cpack_gen:`CPack WIX Generator` gained a
  136. :variable:`CPACK_WIX_CAB_PER_COMPONENT` variable to enable one ``.cab``
  137. per component.
  138. Deprecated and Removed Features
  139. ===============================
  140. * All find modules now provide a ``<PackageName>_FOUND`` result variable
  141. matching the casing of its module name. Existing variants, such as the
  142. uppercased ``<PACKAGENAME>_FOUND``, are deprecated where appropriate.
  143. See documentation of each find module for details.
  144. * The :module:`FindwxWidgets` module's result variable
  145. ``wxWidgets_USE_FILE`` is now deprecated in favor of including the
  146. :module:`UsewxWidgets` module directly.
  147. * The :generator:`Visual Studio 14 2015` generator is now deprecated
  148. and will be removed in a future version of CMake.
  149. Other Changes
  150. =============
  151. * The :genex:`$<CONFIG:cfgs>` generator expression no longer matches multiple
  152. configurations. See policy :policy:`CMP0199`.
  153. * Selection of configuration and location of imported targets is now more
  154. consistent. See policy :policy:`CMP0200`.
  155. * The :variable:`CMAKE_PARENT_LIST_FILE` variable is no longer defined when
  156. processing a ``CMakeLists.txt`` file. See policy :policy:`CMP0198`.
  157. * For builds targeting the MSVC ABI, all generators now add the ``_MBCS``
  158. preprocessor definition when compiling sources unless ``_UNICODE`` or
  159. ``_SBCS`` is found. See policy :policy:`CMP0204`.
  160. * For builds targeting the MSVC ABI, all generators now add the ``_WINDLL``
  161. preprocessor definition when compiling sources in shared libraries.
  162. See policy :policy:`CMP0203`.