title: CMake copy dependencies to executable output path
body: <p>I have the following simple CMake project. It's basically an executable which links dynamically to Qt Widgets (I'm using Qt just as an example). What I'm trying to figure out is whether it is possible to copy all the linked libraries (not only the ones built by the current project) to the executable output directory using CMake.</p>
  
  <pre><code>cmake_minimum_required(VERSION 3.12)
  project(MyProject)
  
  set(CMAKE_CXX_STANDARD 14)
  
  set(QT_CMAKE_DIR "/Users/huser/Qt/5.11.1/clang_64/lib/cmake")
  set(CMAKE_PREFIX_PATH ${CMAKE_MODULE_PATH} ${QT_CMAKE_DIR})
  find_package(Qt5 REQUIRED COMPONENTS Widgets)
  
  add_executable(${PROJECT_NAME} main.cpp)
  target_link_libraries(${PROJECT_NAME} PUBLIC Qt5::Widgets)
  
  set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_LIST_DIR}/build)
  </code></pre>
  
  <p>The issue is that the output directory only contains the MyProject executable (which is the expected behaviour). However, if I were to distribute that executable to someone who doesn't have Qt installed, they would not be able to open it. Hence, I would like to bundle only the necessary libraries/ frameworks with the executable.</p>
  
  <p>Running <code>otool -L MyProject</code> lists the dependencies:</p>
  
  <pre><code>MyProject:
      @rpath/QtWidgets.framework/Versions/5/QtWidgets
      @rpath/QtGui.framework/Versions/5/QtGui
      @rpath/QtCore.framework/Versions/5/QtCore
      /usr/lib/libc++.1.dylib
      /usr/lib/libSystem.B.dylib
  </code></pre>
  
  <p>What I'm looking for is a common way through CMake to get these 3 frameworks copied in the output directory right after the build step. That would result in the following directory structure:</p>
  
  <pre><code>build/
      MyProject
      QtWidgets.framework
      QtGui.framework
      QtCore.framework
  </code></pre>
  
  <p>Any help would be greatly appreciated!</p>