4.0.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. CMake 4.0 Release Notes
  2. ***********************
  3. .. only:: html
  4. .. contents::
  5. Changes made since CMake 3.31 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.8.
  12. * The :manual:`cmake-file-api(7)` "codemodel" version 2 "target" object
  13. gained a new ``debugger`` field.
  14. Command-Line
  15. ------------
  16. * The :option:`cmake --link-no-warning-as-error` option was added to suppress
  17. the effects of the :prop_tgt:`LINK_WARNING_AS_ERROR` target property and
  18. :variable:`CMAKE_LINK_WARNING_AS_ERROR` variable.
  19. * The :option:`cmake --project-file` option was added to specify an alternate
  20. filename for ``CMakeLists.txt`` files. This is intended for temporary use
  21. by developers during an incremental transition and not for publication of a
  22. final product. CMake will always emit a warning when the project file is
  23. anything other than ``CMakeLists.txt``.
  24. Commands
  25. --------
  26. * The :command:`target_link_libraries` command now supports the ``LINKER:``
  27. prefix.
  28. Variables
  29. ---------
  30. * The :variable:`AIX` and :variable:`CMAKE_HOST_AIX` variables are
  31. now set to true when the target or host system is AIX, respectively.
  32. * Linker flag variables learned to support the ``LINKER:`` prefix:
  33. * :variable:`CMAKE_EXE_LINKER_FLAGS`
  34. * :variable:`CMAKE_EXE_LINKER_FLAGS_<CONFIG>`
  35. * :variable:`CMAKE_SHARED_LINKER_FLAGS`
  36. * :variable:`CMAKE_SHARED_LINKER_FLAGS_<CONFIG>`
  37. * :variable:`CMAKE_MODULE_LINKER_FLAGS`
  38. * :variable:`CMAKE_MODULE_LINKER_FLAGS_<CONFIG>`
  39. See policy :policy:`CMP0181`.
  40. * The :variable:`CMAKE_EXECUTE_PROCESS_COMMAND_ERROR_IS_FATAL` variable
  41. was added to specify the :command:`execute_process` command's
  42. default ``COMMAND_ERROR_IS_FATAL`` behavior.
  43. * The :variable:`CMAKE_<LANG>_LINK_MODE` and
  44. :variable:`CMAKE_<LANG>_DEVICE_LINK_MODE` variables were added to provide
  45. information on how the link step is done.
  46. * The :variable:`CMAKE_LINK_WARNING_AS_ERROR` variable and corresponding
  47. :prop_tgt:`LINK_WARNING_AS_ERROR` target property were added to link
  48. using a linker-specific flag to treat warnings as errors.
  49. * The :variable:`CMAKE_MSVC_RUNTIME_CHECKS` variable and
  50. :prop_tgt:`MSVC_RUNTIME_CHECKS` target property were introduced
  51. to select runtime checks for compilers targeting the MSVC ABI.
  52. See policy :policy:`CMP0184`.
  53. * The :variable:`CMAKE_POLICY_VERSION_MINIMUM` variable was added to
  54. help packagers and end users try to configure existing projects that
  55. have not been updated to work with supported CMake versions.
  56. The :envvar:`CMAKE_POLICY_VERSION_MINIMUM` environment variable was
  57. added to initialize it.
  58. * The :variable:`CMAKE_UNITY_BUILD_RELOCATABLE` variable and corresponding
  59. :prop_tgt:`UNITY_BUILD_RELOCATABLE` target property were added to make
  60. sources generated for :variable:`CMAKE_UNITY_BUILD` to ``#include`` the
  61. original source files using relative paths where possible.
  62. * The :variable:`CMAKE_XCODE_SCHEME_LLDB_INIT_FILE` variable and corresponding
  63. :prop_tgt:`XCODE_SCHEME_LLDB_INIT_FILE` target property were added to tell
  64. the :generator:`Xcode` generator what to put in the scheme's "LLDB Init File"
  65. setting.
  66. * The :variable:`CMAKE_XCODE_SCHEME_TEST_CONFIGURATION` variable and corresponding
  67. :prop_tgt:`XCODE_SCHEME_TEST_CONFIGURATION` target property were added to tell
  68. the :generator:`Xcode` generator what to put in the scheme's "Build Configuration"
  69. setting for the test action.
  70. Properties
  71. ----------
  72. * The :prop_tgt:`DEBUGGER_WORKING_DIRECTORY` target property and corresponding
  73. :variable:`CMAKE_DEBUGGER_WORKING_DIRECTORY` variable were added to tell
  74. generators what debugger working directory should be set for targets.
  75. * The :prop_tgt:`STATIC_LIBRARY_OPTIONS` target property now supports an
  76. ``ARCHIVER:`` prefix to pass options to the archiver through the compiler
  77. driver in a portable way.
  78. * The :prop_tgt:`Swift_MODULE_DIRECTORY` target property now supports
  79. :manual:`generator expressions <cmake-generator-expressions(7)>`.
  80. * The :prop_sf:`VS_CUSTOM_COMMAND_DISABLE_PARALLEL_BUILD` source file property
  81. was added to tell :ref:`Visual Studio Generators` not to run a custom command
  82. in parallel.
  83. * The :prop_dir:`VS_SOLUTION_ITEMS` directory property was added
  84. to tell :ref:`Visual Studio Generators` to attach files directly
  85. to the Solution (``.sln``).
  86. Modules
  87. -------
  88. * The :module:`ExternalData` module gained a
  89. :variable:`ExternalData_HTTPHEADERS` variable to specify HTTP headers.
  90. * The :module:`ExternalProject` module's :command:`ExternalProject_Add`
  91. command gained an ``INSTALL_JOB_SERVER_AWARE`` option to enable
  92. integration of the GNU Make job server when using an explicit
  93. ``INSTALL_COMMAND`` with :ref:`Makefile Generators`.
  94. * The :module:`FeatureSummary` module :command:`add_feature_info`
  95. command now supports full :ref:`Condition Syntax`.
  96. See policy :policy:`CMP0183`.
  97. * The :module:`FindBISON` module :command:`bison_target` command gained an
  98. ``OPTIONS`` option to specify Bison command-line options.
  99. * The :module:`FindCURL` module now provides a ``CURL_VERSION`` result
  100. variable to match upstream cURL's CMake package.
  101. * The :module:`FindFLEX` module :command:`flex_target` command gained an
  102. ``OPTIONS`` option to specify Flex command-line options.
  103. * The :module:`FindPatch` module now supports running in
  104. :ref:`cmake -P <Script Processing Mode>` script mode by skipping
  105. the creation of the imported target.
  106. * The :module:`FindProtobuf` module :command:`protobuf_generate` command
  107. gained a ``PROTOC_EXE`` option to specify a custom ``protoc`` executable.
  108. * The :module:`FindPython`, :module:`FindPython2`, and :module:`FindPython3`
  109. modules gained the possibility to do multiple calls in the same directory by
  110. using, respectively, the variables ``Python_ARTIFACTS_PREFIX``,
  111. ``Python2_ARTIFACTS_PREFIX``, and ``Python3_ARTIFACTS_PREFIX``.
  112. * The :module:`FindRuby` module learned to find rbenv-provided installations.
  113. Generator Expressions
  114. ---------------------
  115. * The :genex:`$<PATH>` generator expression gained the ``NATIVE_PATH``
  116. operation to convert a CMake path into a native one.
  117. CTest
  118. -----
  119. * The :option:`ctest --interactive-debug-mode` option on Windows
  120. now enables Windows Error Reporting by default in test processes,
  121. allowing them to creating debug popup windows and core dumps.
  122. This restores behavior previously removed by CMake 3.11 after
  123. updates to ``libuv`` made it possible.
  124. CPack
  125. -----
  126. * The :cpack_gen:`CPack Archive Generator` learned to generate ``.tar``
  127. packages without compression.
  128. * The :cpack_gen:`CPack Archive Generator` now honors the
  129. :variable:`CPACK_ARCHIVE_FILE_NAME` variable for all packages.
  130. Previously, this variable worked only for component-based packages.
  131. Deprecated and Removed Features
  132. ===============================
  133. * Compatibility with versions of CMake older than 3.5 has been removed.
  134. Calls to :command:`cmake_minimum_required` or :command:`cmake_policy`
  135. that set the policy version to an older value now issue an error.
  136. Note that calls to those commands can still support older versions of
  137. CMake by using their ``VERSION`` arguments' ``<min>...<max>`` syntax.
  138. This requires only the ``<min>`` version of CMake, but when running a
  139. newer version, sets policies up to the ``<max>`` version.
  140. * The :generator:`Visual Studio 14 2015` and :generator:`Visual Studio 15 2017`
  141. generators no longer support specifying a platform as part of the generator
  142. name. See :ref:`Visual Studio Platform Selection`.
  143. * The :variable:`CMAKE_<LANG>_USING_LINKER_MODE` variable is no longer used to
  144. determine the type of the contents of the
  145. :variable:`CMAKE_<LANG>_USING_LINKER_<TYPE>` variable. The
  146. :variable:`CMAKE_<LANG>_LINK_MODE` variable, set by CMake, is used instead.
  147. * The :module:`FindGDAL` module is now deprecated in favor of upstream
  148. GDAL's official CMake package configuration file. Port projects to
  149. the latter by calling ``find_package(GDAL CONFIG)``. For further
  150. details, see `GDAL's documentation on CMake integration
  151. <https://gdal.org/en/latest/development/cmake.html>`_.
  152. * The :module:`FindRuby` module no longer provides variables with the
  153. upper-case ``RUBY_`` prefix. See policy :policy:`CMP0185`.
  154. * CTest's undocumented declarative scripting mode has been removed.
  155. This mode used to be triggered by a :option:`ctest -S` script which did not
  156. call any :ref:`CTest Commands` unless :variable:`CTEST_RUN_CURRENT_SCRIPT`
  157. was explicitly set to ``OFF``.
  158. * The :command:`ctest_run_script` command may no longer be called without any
  159. arguments.
  160. Other Changes
  161. =============
  162. * On macOS with :ref:`Ninja Generators` and :ref:`Makefile Generators`, when
  163. a compiler is found in ``/usr/bin``, it is now used as-is and is no longer
  164. mapped to the corresponding compiler inside Xcode. The mapping was
  165. introduced by CMake 3.2 to allow build trees to continue to work with their
  166. original compiler even when ``xcode-select`` switches to a different
  167. Xcode installation. However, the compilers inside Xcode cannot be used
  168. without explicit ``-isysroot`` flags and are therefore not suitable for
  169. passing to arbitrary third-party build systems. Furthermore, the mapping
  170. behavior can override user-specified compiler paths. Therefore, this
  171. behavior has been reverted.
  172. * In builds targeting macOS, :variable:`CMAKE_OSX_SYSROOT` now defaults to
  173. empty, deferring to the compiler's default macOS SDK selection. In order
  174. to pass an explicit macOS SDK via the compiler's ``-isysroot`` flag, users
  175. may configure their build tree with ``-DCMAKE_OSX_SYSROOT=macosx``, or
  176. ``export SDKROOT="$(xcrun --sdk macosx --show-sdk-path)"`` in their
  177. environment.
  178. Notes:
  179. * macOS compilers in ``/usr/bin``, when not invoked with ``-isysroot``,
  180. search for headers in ``/usr/local/include`` before system SDK paths,
  181. matching the convention on many platforms. Users on macOS-x86_64 hosts
  182. with Homebrew installed in ``/usr/local`` should pass an explicit SDK,
  183. as described above, when not building with Homebrew tools.
  184. * Some Clang compilers have no default macOS SDK selection. For these,
  185. if :variable:`CMAKE_OSX_SYSROOT` is empty, CMake will automatically pass
  186. ``-isysroot`` with the macOS SDK printed by ``xcrun --show-sdk-path``.
  187. * On Windows, file paths named in project code, e.g., in ``CMakeLists.txt``,
  188. are no longer automatically converted to their on-disk upper/lower case.
  189. Projects are expected to spell source file paths consistently using
  190. their canonical case, e.g., in calls to :command:`add_library`,
  191. :command:`set_property(SOURCE)`, or :command:`set_source_files_properties`.
  192. This matches the behavior on platforms with case-sensitive filesystems.
  193. * On AIX, ``SHARED`` library targets now produce a shared library archive
  194. by default. See policy :policy:`CMP0182`.
  195. * The :option:`cmake --preset` command no longer outputs a summary of the
  196. preset's CMake cache and environment variables by default. That summary is
  197. now only shown when the message log level is set to ``VERBOSE``, ``DEBUG``,
  198. or ``TRACE`` via the :option:`cmake --log-level` option or the
  199. :variable:`CMAKE_MESSAGE_LOG_LEVEL` cache variable.
  200. * Precompiled SunOS ``sparc64`` and ``x86_64`` binaries are now provided
  201. on `cmake.org`_.
  202. .. _`cmake.org`: https://cmake.org/download/
  203. Updates
  204. =======
  205. Changes made since CMake 4.0.0 include the following.
  206. 4.0.1
  207. -----
  208. * This version made no changes to documented features or interfaces.
  209. Some implementation updates were made to support ecosystem changes
  210. and/or fix regressions.
  211. 4.0.2
  212. -----
  213. * When building for macOS with a Clang that has no default macOS SDK,
  214. if :variable:`CMAKE_OSX_SYSROOT` is empty, CMake now automatically passes
  215. ``-isysroot`` with the macOS SDK printed by ``xcrun --show-sdk-path``.
  216. This restores support for using LLVM/Clang on macOS without manually
  217. setting ``CMAKE_OSX_SYSROOT``, which was broken by CMake 4.0.0's
  218. removal of a default value.
  219. * The :prop_tgt:`DEBUGGER_WORKING_DIRECTORY` target property is now
  220. used by the :generator:`Xcode` generator as a fallback for the
  221. :prop_tgt:`XCODE_SCHEME_WORKING_DIRECTORY` target property.
  222. 4.0.3, 4.0.4
  223. ------------
  224. * These versions made no changes to documented features or interfaces.
  225. Some implementation updates were made to support ecosystem changes
  226. and/or fix regressions.