Skip to content

Commit 4cba171

Browse files
committed
Warn when Qt deployment is not supported for the installation in use (affects packaged Qt on Linux)
1 parent f64a069 commit 4cba171

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

packages/helper-qtdeploy.cmake

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,29 @@ if (WIN32)
7272

7373
elseif(UNIX)
7474

75+
# Putting UNIX deployment into a function to be able to safely abort it.
76+
function(deploy_qt_for_unix)
77+
78+
# Check Qt plugins first: if related CMake modules are not available, we should skip everything else here
79+
# NOTE: For Qt downloaded+installed from their website, the Qt5::Gui component lists all the
80+
# input, platform, etc. plugins. in Qt5Gui_PLUGINS. On the packaged Qt5 versions (e.g., in
81+
# Ubuntu 17.10), Qt5Gui_PLUGINS is empty, and no CMake modules are available that would
82+
# facilitate plugin deployment.
83+
# TODO: All that stuff could be manually deployed, too. But that's error-prone and hard to maintain.
84+
set(_allPlugins)
85+
foreach(_component ${PROJECT_QT_COMPONENTS})
86+
list(APPEND _allPlugins ${Qt5${_component}_PLUGINS})
87+
endforeach()
88+
89+
if (NOT Qt5::QXcbGlxIntegrationPlugin IN_LIST _allPlugins)
90+
message(WARNING "Binary deployment if Qt5 plugins is not supported with your Qt \
91+
installation. If you require a self-contained binary package, consider switching to a manual Qt \
92+
installation downloaded from https://www1.qt.io/download-open-source/
93+
See notes in helper-qtdeploy.cmake for details of this problem.
94+
SKIPPING DEPLOYMENT OF Qt LIBRARIES AND PLUGINS!")
95+
return()
96+
endif()
97+
7598
# qt.conf: setup deploy folder structure
7699
install(FILES qt.conf.linux
77100
DESTINATION ${INSTALL_BIN}
@@ -110,11 +133,6 @@ elseif(UNIX)
110133
)
111134
endforeach()
112135

113-
set(_allPlugins)
114-
foreach(_component ${PROJECT_QT_COMPONENTS})
115-
list(APPEND _allPlugins ${Qt5${_component}_PLUGINS})
116-
endforeach()
117-
118136
# Plugins: copy as is [can't check what is actually needed]
119137
foreach(_plugin ${_allPlugins})
120138
get_target_property(_locationRelease ${_plugin} IMPORTED_LOCATION_RELEASE)
@@ -191,6 +209,10 @@ elseif(UNIX)
191209
DESTINATION ${INSTALL_SHARED}
192210
RENAME ${_XcbQpa_pathTruncated}
193211
)
212+
endfunction()
213+
214+
deploy_qt_for_unix()
215+
194216
endif()
195217

196218
function(deployQtBinariesForTarget TARGET_NAME)

0 commit comments

Comments
 (0)