3.12.rst 12 KB

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