summaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorJose Fonseca <jfonseca@vmware.com>2016-03-22 10:42:21 +0000
committerJose Fonseca <jfonseca@vmware.com>2016-03-22 10:49:26 +0000
commiteb887363d0bc7be574ac6cc2bc9329a6a0952511 (patch)
treef0eaa0cc131b37e636c62ab380c4aa7f1ac03f3b /gui
parente8d4f67ef63851ddd0e1fcb238557197baf760b0 (diff)
cmake: Run windeployqt when installing/packaging.
Diffstat (limited to 'gui')
-rw-r--r--gui/CMakeLists.txt29
1 files changed, 29 insertions, 0 deletions
diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt
index 2746711a..1b19824b 100644
--- a/gui/CMakeLists.txt
+++ b/gui/CMakeLists.txt
@@ -133,3 +133,32 @@ endif ()
install (TARGETS qapitrace RUNTIME DESTINATION bin)
install_pdb (qapitrace RUNTIME DESTINATION bin)
#install (FILES qapitrace.desktop DESTINATION ${XDG_APPS_INSTALL_DIR})
+
+# Deployt Qt dependencies
+#
+# See:
+# - http://doc.qt.io/qt-5/windows-deployment.html
+#
+# XXX: windeployqt can fail if there's weird stuff in the Path env var, so we
+# invoke it with a sanitized Path, via `cmake -E env` that was introduced in
+# CMake 3.1.
+if (WIN32 AND NOT CMAKE_CROSSCOMPILING AND NOT CMAKE_VERSION VERSION_LESS 3.1)
+ # http://stackoverflow.com/a/24676432
+ get_target_property (QT_QMAKE_EXECUTABLE Qt5::qmake IMPORTED_LOCATION)
+ get_filename_component (QT_BIN_DIR "${QT_QMAKE_EXECUTABLE}" DIRECTORY)
+ find_program (QT_WINDEPLOYQT_EXECUTABLE windeployqt HINTS "${QT_BIN_DIR}")
+ if (QT_WINDEPLOYQT_EXECUTABLE)
+ file (TO_NATIVE_PATH "${QT_BIN_DIR}" QT_BIN_DIR_NATIVE)
+ # It's safer to use `\` separateors in the Path, but we need to escape them
+ string (REPLACE "\\" "\\\\" QT_BIN_DIR_NATIVE "${QT_BIN_DIR_NATIVE}")
+ install (CODE "
+ message (STATUS \"Running Qt Deploy Tool...\")
+ execute_process (COMMAND
+ \"${CMAKE_COMMAND}\" -E env
+ \"Path=${QT_BIN_DIR_NATIVE};\$ENV{SystemRoot}\\\\System32;\$ENV{SystemRoot}\"
+ \"${QT_WINDEPLOYQT_EXECUTABLE}\"
+ \"\${CMAKE_INSTALL_PREFIX}/bin/qapitrace.exe\"
+ --verbose 0)
+ ")
+ endif ()
+endif ()