CMAKE_GENERATOR_INSTANCE.rst 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. CMAKE_GENERATOR_INSTANCE
  2. ------------------------
  3. .. versionadded:: 3.11
  4. Generator-specific instance specification provided by user.
  5. Some CMake generators support selection of an instance of the native build
  6. system when multiple instances are available. If the user specifies an
  7. instance (e.g. by setting this cache entry or via the
  8. :envvar:`CMAKE_GENERATOR_INSTANCE` environment variable), or after a default
  9. instance is chosen when a build tree is first configured, the value will be
  10. available in this variable.
  11. The value of this variable should never be modified by project code.
  12. A toolchain file specified by the :variable:`CMAKE_TOOLCHAIN_FILE`
  13. variable may initialize ``CMAKE_GENERATOR_INSTANCE`` as a cache entry.
  14. Once a given build tree has been initialized with a particular value
  15. for this variable, changing the value has undefined behavior.
  16. Instance specification is supported only on specific generators.
  17. Visual Studio Instance Selection
  18. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  19. :ref:`Visual Studio Generators` support instance specification for
  20. Visual Studio 2017 and above. The ``CMAKE_GENERATOR_INSTANCE`` variable
  21. may be set as a cache entry selecting an instance of Visual Studio
  22. via one of the following forms:
  23. * ``location``
  24. * ``location[,key=value]*``
  25. * ``key=value[,key=value]*``
  26. The ``location`` specifies the absolute path to the top-level directory
  27. of the VS installation.
  28. The ``key=value`` pairs form a comma-separated list of options to
  29. specify details of the instance selection.
  30. Supported pairs are:
  31. ``version=<major>.<minor>.<MMMDD>.<BBB>``
  32. .. versionadded:: 3.23
  33. Specify the 4-component VS Build Version.
  34. If the value of ``CMAKE_GENERATOR_INSTANCE`` is not specified explicitly
  35. by the user or a toolchain file, CMake queries the Visual Studio Installer
  36. to locate VS instances, chooses one, and sets the variable as a cache entry
  37. to hold the value persistently. If an environment variable of the form
  38. ``VS##0COMNTOOLS``, where ``##`` the Visual Studio major version number,
  39. is set and points to the ``Common7/Tools`` directory within one of the
  40. VS instances, that instance will be used. Otherwise, if more than one
  41. VS instance is installed we do not define which one is chosen by default.