MAP_IMPORTED_CONFIG_CONFIG.rst 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. MAP_IMPORTED_CONFIG_<CONFIG>
  2. ----------------------------
  3. Map from project configuration to
  4. :ref:`imported target <IMPORTED targets>`'s configuration.
  5. Set this to the list of configurations of an imported target that may
  6. be used for the current project's ``<CONFIG>`` configuration. Targets
  7. imported from another project may not provide the same set of
  8. configuration names available in the current project. Setting this
  9. property tells CMake what imported configurations are suitable for use
  10. when building the ``<CONFIG>`` configuration. The first configuration in
  11. the list found to be provided by the imported target (i.e. via
  12. :prop_tgt:`IMPORTED_LOCATION_<CONFIG>` for the mapped-to ``<CONFIG>``)
  13. is selected. As a special case, an empty list element refers to the
  14. configuration-less imported target location
  15. (i.e. :prop_tgt:`IMPORTED_LOCATION`).
  16. If this property is set and no matching configurations are available,
  17. then the imported target is considered to be not found. This property
  18. is ignored for non-imported targets.
  19. This property is initialized by the value of the
  20. :variable:`CMAKE_MAP_IMPORTED_CONFIG_<CONFIG>` variable if it is set when a
  21. target is created.
  22. Example
  23. ^^^^^^^
  24. For example creating imported C++ library ``foo``:
  25. .. code-block:: cmake
  26. add_library(foo STATIC IMPORTED)
  27. Use ``foo_debug`` path for ``Debug`` build type:
  28. .. code-block:: cmake
  29. set_property(
  30. TARGET foo APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG
  31. )
  32. set_target_properties(foo PROPERTIES
  33. IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "CXX"
  34. IMPORTED_LOCATION_DEBUG "${foo_debug}"
  35. )
  36. Use ``foo_release`` path for ``Release`` build type:
  37. .. code-block:: cmake
  38. set_property(
  39. TARGET foo APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE
  40. )
  41. set_target_properties(foo PROPERTIES
  42. IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX"
  43. IMPORTED_LOCATION_RELEASE "${foo_release}"
  44. )
  45. Use ``Release`` version of library for ``MinSizeRel`` and ``RelWithDebInfo``
  46. build types:
  47. .. code-block:: cmake
  48. set_target_properties(foo PROPERTIES
  49. MAP_IMPORTED_CONFIG_MINSIZEREL Release
  50. MAP_IMPORTED_CONFIG_RELWITHDEBINFO Release
  51. )