1# - Copy shared libraries from imported targets to the target build directory
2# on Windows during post-build. Install them in all cases.
3#
4#  copy_imported_targets(<target_name> [<imported target name> ...])
5#
6#  install_imported_target(<imported target name> <arguments to pass to install(FILES))
7#
8# Likely requires CMake 2.8.12 or newer to work well.
9#
10# Original Author:
11# 2015 Ryan Pavlik <ryan.pavlik@gmail.com> <abiryan@ryand.net>
12#
13# Copyright Sensics, Inc. 2015.
14# Distributed under the Boost Software License, Version 1.0.
15# (See accompanying file LICENSE_1_0.txt or copy at
16# http://www.boost.org/LICENSE_1_0.txt)
17
18function(copy_imported_targets _target)
19    foreach(_dep ${ARGN})
20        if(WIN32)
21            add_custom_command(TARGET ${_target} POST_BUILD
22                COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${_dep}> $<TARGET_FILE_DIR:${_target}>
23                COMMENT "Copying required DLL for dependency ${_dep}"
24                VERBATIM)
25        endif()
26    endforeach()
27endfunction()
28
29
30function(install_imported_target _dep)
31    install(FILES $<TARGET_FILE:${_dep}> ${ARGN})
32endfunction()
33