4.2.rst 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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.
  34. * The :generator:`FASTBuild` generator was added.
  35. Platforms
  36. ---------
  37. * CMake now supports :ref:`Cross Compiling for Emscripten` with simple
  38. toolchain files.
  39. Command-Line
  40. ------------
  41. * The :manual:`cmake(1)` command-line tool now supports
  42. ``cmake -E copy_if_newer`` and ``cmake -E copy_directory_if_newer``
  43. subcommands to copy files based on timestamp comparison instead of
  44. content comparison. These commands copy files only if the source is
  45. newer than the destination, providing better performance for build
  46. systems compared to ``copy_if_different`` which compares file contents.
  47. Commands
  48. --------
  49. * The :command:`cmake_language(TRACE)` command was added to enable or
  50. disable tracing during script execution.
  51. * The :command:`set(CACHE{<variable>}) <set(CACHE)>` and
  52. :command:`unset(CACHE{<variable>}) <unset(CACHE)>` commands were added to
  53. explicitly set and unset cache entries.
  54. * The :command:`string(REGEX QUOTE)` command was added to
  55. generate a regular expression exactly matching a string.
  56. Variables
  57. ---------
  58. * The :variable:`CMAKE_CXX_STDLIB_MODULES_JSON` variable was added to set
  59. the path to the ``import std`` metadata file for the standard library
  60. rather than using the compiler to discover its location.
  61. * The :variable:`CMAKE_INTERMEDIATE_DIR_STRATEGY` variable and corresponding
  62. :envvar:`CMAKE_INTERMEDIATE_DIR_STRATEGY` environment variable were added
  63. to change the strategy used to name intermediate directories used for
  64. object files and other associated target metadata.
  65. * The :variable:`CMAKE_AUTOGEN_INTERMEDIATE_DIR_STRATEGY` variable and
  66. corresponding :envvar:`CMAKE_AUTOGEN_INTERMEDIATE_DIR_STRATEGY` environment
  67. variable were added to change the strategy used to name intermediate
  68. directories used for :manual:`Qt Autogen <cmake-qt(7)>` files.
  69. * The :variable:`CMAKE_SKIP_LINTING` variable and corresponding
  70. :prop_tgt:`SKIP_LINTING` target property were added to tell the
  71. :ref:`Command-Line Build Tool Generators` to skip linting all
  72. sources in a target.
  73. Properties
  74. ----------
  75. * The :prop_sf:`INSTALL_OBJECT_NAME` source file property was added to
  76. control names of installed object files for specific compiled sources.
  77. * The :prop_tgt:`INSTALL_OBJECT_NAME_STRATEGY` target property was added
  78. to control the naming strategy for installed object files.
  79. * The :prop_tgt:`INSTALL_OBJECT_ONLY_USE_DESTINATION` target property was
  80. added to more precisely control the installation path for object files.
  81. * The :prop_sf:`JOB_POOL_COMPILE` source file property was added
  82. to assign individual source compilations to :prop_gbl:`JOB_POOLS`.
  83. * The :prop_sf:`OBJECT_NAME` source file property was added to control
  84. object names of compiled source files.
  85. * The :prop_tgt:`UNITY_BUILD_FILENAME_PREFIX` target property was added
  86. to control names of source files generated by :prop_tgt:`UNITY_BUILD`.
  87. Modules
  88. -------
  89. * Nearly all find modules now provide a ``<PackageName>_VERSION`` result
  90. variable matching the casing of its module name. Existing variants such as
  91. ``<PackageName>_VERSION_STRING`` and uppercased ``<PACKAGENAME>_VERSION``
  92. are deprecated. See documentation of each find module for details.
  93. * The :module:`CheckTypeSize` module's :command:`check_type_size` command
  94. gained a new ``RESULT_VARIABLE`` keyword to customize the result variable
  95. name instead of the default ``HAVE_<size-var>``.
  96. * The :module:`ExternalProject` module's :command:`ExternalProject_Add`
  97. and :command:`ExternalProject_Add_Step` commands now provide options to set
  98. environment variables on the configure, build, install, and test steps.
  99. * The :module:`FindPython3`, :module:`FindPython2`, and :module:`FindPython`
  100. modules no longer make ``NumPy`` depend on ``Development.Module``.
  101. See policy :policy:`CMP0201`.
  102. * The :module:`GoogleTest` module's :command:`gtest_discover_tests()`
  103. command now sets the ``DEF_SOURCE_LINE`` test property for each
  104. discovered test if gtest supports the ``--gtest_output=json`` option.
  105. This test property is used by some IDEs to locate the source for each test.
  106. * The :module:`UseSWIG` module's :command:`swig_add_library` command gained a
  107. ``DEBUG_POSTFIX`` option to control the :prop_tgt:`DEBUG_POSTFIX` target
  108. property.
  109. Generator Expressions
  110. ---------------------
  111. * The :genex:`<LANG>_COMPILER_LINKER_ID <C_COMPILER_LINKER_ID>` and
  112. :genex:`<LANG>_COMPILER_LINKER_FRONTEND_VARIANT <C_COMPILER_LINKER_FRONTEND_VARIANT>`
  113. families of generator expressions were added to access the value of the
  114. associated :variable:`CMAKE_<LANG>_COMPILER_LINKER_ID` and
  115. :variable:`CMAKE_<LANG>_COMPILER_LINKER_FRONTEND_VARIANT` variables.
  116. * The :genex:`TARGET_FILE_BASE_NAME`, :genex:`TARGET_IMPORT_FILE_BASE_NAME`,
  117. :genex:`TARGET_LINKER_FILE_BASE_NAME`,
  118. :genex:`TARGET_LINKER_LIBRARY_FILE_BASE_NAME`,
  119. :genex:`TARGET_LINKER_IMPORT_FILE_BASE_NAME`, and
  120. :genex:`TARGET_PDB_FILE_BASE_NAME`
  121. generator expressions gained a ``POSTFIX`` option to control the inclusion
  122. of the :prop_tgt:`<CONFIG>_POSTFIX` target property as part of the base
  123. names of the corresponding files.
  124. * The :genex:`TARGET_INTERMEDIATE_DIR` generator expression was
  125. added to refer to a target's intermediate files directory in
  126. the build tree.
  127. CPack
  128. -----
  129. * The :cpack_gen:`CPack AppImage Generator` was added.
  130. * The :variable:`CPACK_PACKAGE_CHECKSUM` variable now supports multiple values.
  131. * The :cpack_gen:`CPack NSIS Generator` gained a
  132. :variable:`CPACK_NSIS_CRC_CHECK` variable for setting the ``CRCCheck``
  133. attribute.
  134. * The :cpack_gen:`CPack WIX Generator` gained a
  135. :variable:`CPACK_WIX_CAB_PER_COMPONENT` variable to enable one ``.cab``
  136. per component.
  137. Deprecated and Removed Features
  138. ===============================
  139. * All find modules now provide a ``<PackageName>_FOUND`` result variable
  140. matching the casing of its module name. Existing variants, such as the
  141. uppercased ``<PACKAGENAME>_FOUND``, are deprecated where appropriate.
  142. See documentation of each find module for details.
  143. * The :module:`FindwxWidgets` module's result variable
  144. ``wxWidgets_USE_FILE`` is now deprecated in favor of including the
  145. :module:`UsewxWidgets` module directly.
  146. * The :generator:`Visual Studio 14 2015` generator is now deprecated
  147. and will be removed in a future version of CMake.
  148. Other Changes
  149. =============
  150. * The :genex:`$<CONFIG:cfgs>` generator expression, when appearing on an
  151. imported target, has been fixed to only match the configuration actually
  152. being consumed. 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`.