TARGET_RUNTIME_DLLS¶
This generator expression belongs to the Target Artifacts family. See that section for related generator expressions.
Syntax¶
$<TARGET_RUNTIME_DLLS:tgt>
Added in version 3.21.
List of DLLs that the target depends on at runtime. This is determined by the
locations of all the SHARED targets in the target's transitive dependencies.
If only the directories of the DLLs are needed, see the
TARGET_RUNTIME_DLL_DIRS generator expression. Using this generator
expression on targets other than executables, SHARED libraries, and
MODULE libraries is an error. On non-DLL platforms, this expression always
evaluates to an empty string.
This generator expression can be used to copy all of the DLLs that a target
depends on into its output directory in a POST_BUILD custom command using
the cmake -E copy -t command. For example:
find_package(foo CONFIG REQUIRED) # package generated by install(EXPORT)
add_executable(exe main.c)
target_link_libraries(exe PRIVATE foo::foo foo::bar)
add_custom_command(TARGET exe POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy -t $<TARGET_FILE_DIR:exe> $<TARGET_RUNTIME_DLLS:exe>
COMMAND_EXPAND_LISTS
)
Note
Imported Targets are supported only if they know the location
of their .dll files. An imported SHARED library must have
IMPORTED_LOCATION set to its .dll file. See the
add_library imported libraries
section for details. Many Find Modules produce imported targets
with the UNKNOWN type and therefore will be ignored.
On platforms that support runtime paths (RPATH), refer to the
INSTALL_RPATH target property. On Apple platforms, refer to the
INSTALL_NAME_DIR target property.