CMakeExpandImportedTargets — CMake 4.4.0 Documentation

# CMakeExpandImportedTargets

Deprecated since version 3.4: This module should no longer be used.

It was once needed to replace Imported Targets with their underlying libraries referenced on disk for use with the `try_compile()` and `try_run()` commands. These commands now support imported targets in their `LINK_LIBRARIES` options (since CMake 2.8.11 for `try_compile()` command and since CMake 3.2 for `try_run()` command).

Load this module in a CMake project with:

    include(CMakeExpandImportedTargets)

Note

This module does not support the policy `CMP0022` `NEW` behavior, nor does it use the `INTERFACE_LINK_LIBRARIES` property, because `generator expressions` cannot be evaluated at the configuration phase.

## Commands

This module provides the following command:

cmake_expand_imported_targets

  Expands all imported targets in a given list of libraries to their corresponding file paths on disk and stores the resulting list in a local variable:

      cmake_expand_imported_targets(
        <result-var>
        LIBRARIES <libs>...
        [CONFIGURATION <config>]
      )

  The arguments are:

  `<result-var>`

    Name of a CMake variable containing the resulting list of file paths.

  `LIBRARIES <libs>...`

    A semicolon-separated list of system and imported targets. Imported targets in this list are replaced with their corresponding library file paths, including libraries from their link interfaces.

  `CONFIGURATION <config>`

    If this option is given, it uses the respective build configuration `<config>` of the imported targets if it exists. If omitted, it defaults to the first entry in the `CMAKE_CONFIGURATION_TYPES` variable, or falls back to `CMAKE_BUILD_TYPE` if `CMAKE_CONFIGURATION_TYPES` is not set.

## Examples

Using this module to get a list of library paths:

    include(CMakeExpandImportedTargets)
    cmake_expand_imported_targets(
      expandedLibs
      LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}
      CONFIGURATION "${CMAKE_TRY_COMPILE_CONFIGURATION}"
    )