diff --git a/CMakeLists.txt b/CMakeLists.txt index f8e3387..e076fc0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -129,6 +129,42 @@ else() message(FATAL_ERROR "Vendored FreeRDP targets were not produced as expected.") endif() +# Qt loads platform integration and SQL driver plugins dynamically at +# runtime (QFactoryLoader), so they never appear in orbithub.exe's import +# table. vcpkg's automatic DLL deployment only follows the import table, so +# these plugins have to be copied out explicitly or the app fails to start +# with "Could not find the Qt platform plugin" / "can not load requested +# driver 'QSQLITE'". +if(WIN32) + if(TARGET Qt6::QWindowsIntegrationPlugin) + add_custom_command(TARGET orbithub POST_BUILD + COMMAND ${CMAKE_COMMAND} -E make_directory + "$/platforms" + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "$" + "$/platforms/" + COMMENT "Deploying Qt Windows platform plugin" + ) + install(FILES "$" + DESTINATION "${CMAKE_INSTALL_BINDIR}/platforms" + ) + endif() + + if(TARGET Qt6::QSQLiteDriverPlugin) + add_custom_command(TARGET orbithub POST_BUILD + COMMAND ${CMAKE_COMMAND} -E make_directory + "$/sqldrivers" + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "$" + "$/sqldrivers/" + COMMENT "Deploying Qt SQLite driver plugin" + ) + install(FILES "$" + DESTINATION "${CMAKE_INSTALL_BINDIR}/sqldrivers" + ) + endif() +endif() + set_target_properties(orbithub PROPERTIES BUILD_RPATH_USE_ORIGIN ON INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}/orbithub"