From 5b8fa72bdc81e10bce4ebc896f10853c73949276 Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Tue, 13 Jan 2015 13:32:12 -0800 Subject: [PATCH] CMake: Copy Qt DLLs to the target directory. Add a "copy_qt_dlls" target similar to "copy_cli_dlls". Wireshark.exe must exist before windeployqt can be run, so we can't create a PRE_BUILD target. Add copy_qt_dlls to the default target instead. Change-Id: If85d89478472b10b31229413465955fe98b0ef02 Reviewed-on: https://code.wireshark.org/review/6529 Petri-Dish: Gerald Combs Reviewed-by: Graham Bloice Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs --- CMakeLists.txt | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index c52c948e7e..7a64bcfc26 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -534,6 +534,7 @@ if(BUILD_wireshark) set( WS_ALL_LIBS ${WS_ALL_LIBS} ${QT5_DLL_PATH} ) endif() set(PACKAGELIST ${PACKAGELIST} + Qt5Core Qt5LinguistTools Qt5MultimediaWidgets Qt5PrintSupport @@ -1414,6 +1415,29 @@ if(BUILD_wireshark AND QT_FOUND) $ ) endif() + + if(WIN32 AND Qt5Core_FOUND) + # Use windeployqt to copy our required DLLs to the run path. + # Ideally one of the modules in ${QTDIR}/lib/cmake/Qt5WinExtras + # would give us the path to windeployqt. For that matter a + # reliable path to qmake would be amazingly convenient. As it + # is we derive the location from Qt5::qmake, which is provided + # by Qt5Core. + get_target_property(_qmake_location Qt5::qmake IMPORTED_LOCATION) + get_filename_component(_qt_bindir "${_qmake_location}" DIRECTORY) + find_program(_windeployqt windeployqt PATHS "${_qmake_location}") + if (NOT "${_windeployqt}" STREQUAL "_windeployqt-NOTFOUND") + add_custom_target(copy_qt_dlls ALL) + # Will we ever need to use --debug? Windeployqt seems to + # be smart enough to copy debug DLLs when needed. + add_custom_command(TARGET copy_qt_dlls POST_BUILD + COMMAND "${_windeployqt}" + --release --no-compiler-runtime + "$" + ) + add_dependencies(copy_qt_dlls wireshark) + endif() + endif(WIN32) endif() # Common properties for CLI executables