3.12.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. CMake 3.12 Release Notes
  2. ************************
  3. .. only:: html
  4. .. contents::
  5. Changes made since CMake 3.11 include the following.
  6. New Features
  7. ============
  8. Generators
  9. ----------
  10. * The :ref:`Visual Studio Generators` for VS 2017 learned to support a
  11. ``version=14.##`` option in the :variable:`CMAKE_GENERATOR_TOOLSET`
  12. value (e.g. via the :manual:`cmake(1)` ``-T`` option) to specify a
  13. toolset version number.
  14. Command-Line
  15. ------------
  16. * The :manual:`cmake(1)` :ref:`Build Tool Mode` (``cmake --build``) gained
  17. ``--parallel [<jobs>]`` and ``-j [<jobs>]`` options to specify a parallel
  18. build level. They map to corresponding options of the native build tool.
  19. Commands
  20. --------
  21. * The :command:`add_compile_definitions` command was added to set preprocessor
  22. definitions at directory level. This supersedes :command:`add_definitions`.
  23. * The :command:`cmake_minimum_required` and :command:`cmake_policy(VERSION)`
  24. commands now accept a version range using the form ``<min>[...<max>]``.
  25. The ``<min>`` version is required but policies are set based on the
  26. older of the running CMake version and the version specified by
  27. ``<max>``. This allows projects to specify a range of versions
  28. for which they have been updated and avoid explicit policy settings.
  29. * The :command:`file(GLOB)` and :command:`file(GLOB_RECURSE)` commands
  30. learned a new flag ``CONFIGURE_DEPENDS`` which enables expression of
  31. build system dependency on globbed directory's contents.
  32. * The :command:`file(TOUCH)` and :command:`file(TOUCH_NOCREATE)` commands
  33. were added to expose ``TOUCH`` functionality without having to use
  34. CMake's command-line tool mode with :command:`execute_process`.
  35. * The :command:`find_package` command now searches prefixes specified by
  36. the :variable:`<PackageName>_ROOT` CMake variable and the
  37. :envvar:`<PackageName>_ROOT` environment variable. Package roots are
  38. maintained as a stack so nested calls to all ``find_*`` commands inside
  39. find modules also search the roots as prefixes.
  40. See policy :policy:`CMP0074`.
  41. * The :command:`install` command learned an optional ``NAMELINK_COMPONENT``
  42. parameter, which allows you to change the component for a shared library's
  43. namelink. If none is specified, the value of ``COMPONENT`` is used by
  44. default.
  45. * The :command:`list` command learned a ``JOIN`` sub-command
  46. to concatenate list's elements separated by a glue string.
  47. * The :command:`list` command learned a ``SUBLIST`` sub-command
  48. to get a sublist of the list.
  49. * The :command:`list` command learned a ``TRANSFORM`` sub-command
  50. to apply various string transformation to list's elements.
  51. * The :command:`project` command learned an optional ``HOMEPAGE_URL``
  52. parameter which has the effect of setting variables like
  53. :variable:`PROJECT_HOMEPAGE_URL`, :variable:`<PROJECT-NAME>_HOMEPAGE_URL`
  54. and :variable:`CMAKE_PROJECT_HOMEPAGE_URL`.
  55. * The :command:`string` command learned a ``JOIN`` sub-command
  56. to concatenate input strings separated by a glue string.
  57. * :command:`target_compile_options` and :command:`add_compile_options`
  58. commands gained a ``SHELL:`` prefix to specify a group of related
  59. options using shell-like quoting.
  60. * The :command:`target_link_libraries` command now supports
  61. :ref:`Object Libraries`. Linking to an object library uses its object
  62. files in direct dependents and also propagates usage requirements.
  63. Variables
  64. ---------
  65. * The :variable:`CMAKE_FOLDER` variable was added to initialize the
  66. :prop_tgt:`FOLDER` property on all targets.
  67. * The :variable:`CMAKE_DOTNET_TARGET_FRAMEWORK_VERSION` variable
  68. was defined to initialize all
  69. :prop_tgt:`DOTNET_TARGET_FRAMEWORK_VERSION` target properties.
  70. * ``CMAKE_PROJECT_VERSION*`` variables have been introduced:
  71. - :variable:`CMAKE_PROJECT_VERSION`
  72. - :variable:`CMAKE_PROJECT_VERSION_MAJOR`
  73. - :variable:`CMAKE_PROJECT_VERSION_MINOR`
  74. - :variable:`CMAKE_PROJECT_VERSION_PATCH`
  75. - :variable:`CMAKE_PROJECT_VERSION_TWEAK`
  76. * The :variable:`CMAKE_SUPPRESS_REGENERATION` variable was extended to
  77. support the :generator:`Ninja` and :ref:`Makefile Generators`.
  78. It is also now documented.
  79. * ``CMAKE_VS_SDK_*_DIRECTORIES`` variables were defined to tell
  80. :ref:`Visual Studio Generators` for VS 2010 and above how to populate
  81. fields in ``.vcxproj`` files that specify SDK directories. The
  82. variables are:
  83. - :variable:`CMAKE_VS_SDK_EXCLUDE_DIRECTORIES`
  84. - :variable:`CMAKE_VS_SDK_EXECUTABLE_DIRECTORIES`
  85. - :variable:`CMAKE_VS_SDK_INCLUDE_DIRECTORIES`
  86. - :variable:`CMAKE_VS_SDK_LIBRARY_DIRECTORIES`
  87. - :variable:`CMAKE_VS_SDK_LIBRARY_WINRT_DIRECTORIES`
  88. - :variable:`CMAKE_VS_SDK_REFERENCE_DIRECTORIES`
  89. - :variable:`CMAKE_VS_SDK_SOURCE_DIRECTORIES`
  90. * A :variable:`MSVC_TOOLSET_VERSION` variable was added to provide the
  91. MSVC toolset version associated with the current MSVC compiler version
  92. in :variable:`MSVC_VERSION`.
  93. Properties
  94. ----------
  95. * The :prop_tgt:`COMMON_LANGUAGE_RUNTIME` target property was introduced
  96. to configure the use of managed C++ for :ref:`Visual Studio Generators`
  97. for VS 2010 and above.
  98. A corresponding :prop_tgt:`IMPORTED_COMMON_LANGUAGE_RUNTIME` target
  99. property was added to support ``C++/CLI`` for imported targets.
  100. * The :prop_tgt:`DOTNET_TARGET_FRAMEWORK_VERSION` target property
  101. was introduced as replacement for
  102. :prop_tgt:`VS_DOTNET_TARGET_FRAMEWORK_VERSION`, which is considered
  103. deprecated now.
  104. * An :prop_tgt:`EXPORT_PROPERTIES` target property was added to specify a
  105. custom list of target properties to include in targets exported by the
  106. :command:`install(EXPORT)` and :command:`export` commands.
  107. * The :prop_tgt:`PDB_OUTPUT_DIRECTORY` property learned to support
  108. :manual:`generator expressions <cmake-generator-expressions(7)>`.
  109. * A :prop_dir:`TESTS` directory property was added to hold the list of
  110. tests defined by the :command:`add_test` command.
  111. * A :prop_tgt:`VS_DEBUGGER_COMMAND` target property was created to set the
  112. debugging command line with :ref:`Visual Studio Generators` for VS 2010
  113. and above.
  114. * HLSL source file properties :prop_sf:`VS_SHADER_DISABLE_OPTIMIZATIONS`
  115. and :prop_sf:`VS_SHADER_ENABLE_DEBUG` gained support for generator
  116. expressions.
  117. * HLSL source file property :prop_sf:`VS_SHADER_OBJECT_FILE_NAME` has been
  118. added to the :ref:`Visual Studio Generators` for VS 2010 and above.
  119. The property specifies the file name of the compiled shader object.
  120. Modules
  121. -------
  122. * The :module:`FindALSA` module now provides imported targets.
  123. * The :module:`FindCURL` module now provides imported targets.
  124. * The :module:`FindJPEG` module now provides imported targets.
  125. * The :module:`FindLibXml2` module now provides imported targets.
  126. * The :module:`FindMatlab` module now supports the Matlab Runtime
  127. Compiler (MCR) for compiling and linking matlab extensions.
  128. * A :module:`FindODBC` module was added to find an Open Database Connectivity
  129. (ODBC) library.
  130. * The :module:`FindPkgConfig` module has learned to export the found
  131. libraries with full path for direct consumption with the
  132. :command:`target_link_libraries` command.
  133. * New :module:`FindPython3` and :module:`FindPython2` modules, as well as
  134. a new :module:`FindPython` module, have been added to provide a new way
  135. to locate python environments.
  136. * The :module:`UseSWIG` module gained a whole refresh and is now more
  137. consistent with standard CMake commands to generate libraries and is
  138. fully configurable through properties.
  139. * The :module:`UseSWIG` module learned to manage multiple behaviors through
  140. ``UseSWIG_MODULE_VERSION`` variable to ensure legacy support as well as more
  141. robust handling of ``SWIG`` advanced features (like ``%template``).
  142. * The :module:`UseSWIG` module learned to support CSHARP variant
  143. wrapper files.
  144. * The :module:`WriteCompilerDetectionHeader` module gained a ``BARE_FEATURES``
  145. option to add a compatibility define for the exact keyword of a new language
  146. feature.
  147. Generator Expressions
  148. ---------------------
  149. * A new ``$<GENEX_EVAL:...>`` and ``$<TARGET_GENEX_EVAL:target,...>``
  150. :manual:`generator expression <cmake-generator-expressions(7)>`
  151. has been added to enable consumption of generator expressions whose
  152. evaluation results itself in generator expressions.
  153. * A new ``$<IN_LIST:...>``
  154. :manual:`generator expression <cmake-generator-expressions(7)>`
  155. has been added.
  156. * A new ``$<TARGET_EXISTS:...>``
  157. :manual:`generator expression <cmake-generator-expressions(7)>`
  158. has been added.
  159. * A new ``$<TARGET_NAME_IF_EXISTS:...>``
  160. :manual:`generator expression <cmake-generator-expressions(7)>`
  161. has been added.
  162. CTest
  163. -----
  164. * The :command:`ctest_start` command has been reworked so that you can simply
  165. call ``ctest_start(APPEND)`` and it will read all the needed information from
  166. the TAG file. The argument parsing has also been relaxed so that the order of
  167. the arguments is less significant.
  168. * A :prop_test:`PROCESSOR_AFFINITY` test property was added to request
  169. that CTest run a test with CPU affinity for a set of processors
  170. disjoint from other concurrently running tests with the property set.
  171. CPack
  172. -----
  173. * The :module:`CPack` module now uses variables
  174. :variable:`CMAKE_PROJECT_VERSION_MAJOR`,
  175. :variable:`CMAKE_PROJECT_VERSION_MINOR` and
  176. :variable:`CMAKE_PROJECT_VERSION_PATCH`
  177. to initialize corresponding CPack variables.
  178. * A :cpack_gen:`CPack NuGet Generator` was was added with basic
  179. support for `NuGet`_.
  180. .. _NuGet: https://learn.microsoft.com/en-us/nuget/what-is-nuget
  181. Other
  182. -----
  183. * The :manual:`Compile Features <cmake-compile-features(7)>` functionality
  184. is now aware of C++ 20. No specific features are yet enumerated besides
  185. the ``cxx_std_20`` meta-feature.
  186. * The :manual:`Compile Features <cmake-compile-features(7)>` functionality
  187. is now aware of the availability of C features in MSVC since VS 2010.
  188. * The :manual:`Compile Features <cmake-compile-features(7)>` functionality
  189. is now aware of C language standards supported by Texas Instruments C
  190. compilers.
  191. Deprecated and Removed Features
  192. ===============================
  193. * The :generator:`Visual Studio 8 2005` generator has been removed.
  194. * CMake no longer produces ``<tgt>_LIB_DEPENDS`` cache entries
  195. for library targets. See policy :policy:`CMP0073`.
  196. Other Changes
  197. =============
  198. * Include flags for directories marked as ``SYSTEM`` are now moved after
  199. non-system directories. The ``-isystem`` flag does this automatically,
  200. so moving them explicitly to the end makes the behavior consistent on
  201. compilers that do not have any ``-isystem`` flag.
  202. * Fortran dependency scanning now supports dependencies implied by
  203. `Fortran Submodules`_.
  204. * The existence and functionality of the file
  205. ``${CMAKE_BINARY_DIR}/cmake_install.cmake`` has now been documented in the
  206. :command:`install` documentation so that external packaging software can take
  207. advantage of CPack-style component installs.
  208. * The :module:`CheckIncludeFile` module ``check_include_file()`` command
  209. learned to honor the ``CMAKE_REQUIRED_LIBRARIES`` variable.
  210. See policy :policy:`CMP0075`.
  211. * The :module:`CheckIncludeFileCXX` module ``check_include_file_cxx()`` command
  212. learned to honor the ``CMAKE_REQUIRED_LIBRARIES`` variable.
  213. See policy :policy:`CMP0075`.
  214. * The :module:`CheckIncludeFiles` module ``check_include_files()`` command
  215. learned to honor the ``CMAKE_REQUIRED_LIBRARIES`` variable.
  216. See policy :policy:`CMP0075`.
  217. * The :manual:`cmake(1)` ``-E copy_directory`` tool now fails when the
  218. source directory does not exist. Previously it succeeded by creating
  219. an empty destination directory.
  220. * The :module:`UseSWIG` module :command:`swig_add_library` command
  221. (and legacy ``swig_add_module`` command) now set the prefix of
  222. Java modules to ``""`` for MINGW, MSYS, and CYGWIN environments.
  223. .. _Fortran Submodules: https://fortranwiki.org/fortran/show/Submodules