Skip to content

Commit 36fbca4

Browse files
droidmonkeyCopilot
andauthored
Fix running windeployqt for Qt6 (#13356)
--------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: droidmonkey <2809491+droidmonkey@users.noreply.github.com>
1 parent 86fec5c commit 36fbca4

1 file changed

Lines changed: 24 additions & 6 deletions

File tree

src/CMakeLists.txt

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,10 @@ install(TARGETS ${PROGNAME}
452452
if(WIN32)
453453
# Deploy used libraries into build directory for debugging
454454
add_custom_command(TARGET ${PROGNAME} POST_BUILD
455-
COMMAND ${WINDEPLOYQT_EXE} --dir $<TARGET_FILE_DIR:${PROGNAME}> $<TARGET_FILE:${PROGNAME}>)
455+
COMMAND ${WINDEPLOYQT_EXE}
456+
--dir $<TARGET_FILE_DIR:${PROGNAME}>
457+
$<IF:$<CONFIG:Debug>,--debug,--release>
458+
$<TARGET_FILE:${PROGNAME}>)
456459

457460
# We have to copy the license file in the configuration phase.
458461
# CMake checks that CPACK_RESOURCE_FILE_LICENSE actually exists and
@@ -471,7 +474,7 @@ if(WIN32)
471474
set(CPACK_GENERATOR "ZIP;WIX")
472475
set(CPACK_COMPONENTS_ALL "")
473476
set(CPACK_STRIP_FILES OFF)
474-
set(CPACK_PACKAGE_FILE_NAME "${PROGNAME}-${KEEPASSXC_VERSION}-${OUTPUT_FILE_POSTFIX}")
477+
set(CPACK_PACKAGE_FILE_NAME "${PROGNAME}-${KEEPASSXC_VERSION}-${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}")
475478
set(CPACK_PACKAGE_INSTALL_DIRECTORY ${PROGNAME})
476479
set(CPACK_PACKAGE_VERSION ${KEEPASSXC_VERSION_CLEAN})
477480
set(CPACK_PACKAGE_VENDOR "${PROGNAME} Team")
@@ -507,6 +510,25 @@ if(WIN32)
507510
set(CPACK_WIX_EXTENSIONS "WixUtilExtension.dll")
508511
include(CPack)
509512

513+
514+
# Use windeployqt.exe to setup Qt dependencies
515+
install(CODE "
516+
if(\"\${CMAKE_INSTALL_CONFIG_NAME}\" STREQUAL \"Debug\")
517+
set(_wdqt_mode --debug)
518+
else()
519+
set(_wdqt_mode --release)
520+
endif()
521+
execute_process(
522+
COMMAND ${WINDEPLOYQT_EXE} ${PROGNAME}.exe \${_wdqt_mode}
523+
WORKING_DIRECTORY \${CMAKE_INSTALL_PREFIX}
524+
OUTPUT_QUIET
525+
RESULT_VARIABLE _wdqt_result
526+
)
527+
if(NOT \${_wdqt_result} EQUAL 0)
528+
message(FATAL_ERROR \"windeployqt failed with exit code \${_wdqt_result}\")
529+
endif()"
530+
COMPONENT Runtime)
531+
510532
if(NOT VCPKG_INSTALLED_DIR)
511533
install(CODE "set(gp_tool \"objdump\")" COMPONENT Runtime)
512534

@@ -515,10 +537,6 @@ if(WIN32)
515537
fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/${PROGNAME}.exe\" \"\" \"\")"
516538
COMPONENT Runtime)
517539

518-
# Use windeployqt.exe to setup Qt dependencies
519-
install(CODE "execute_process(COMMAND ${WINDEPLOYQT_EXE} ${PROGNAME}.exe ${WINDEPLOYQT_MODE} WORKING_DIRECTORY \${CMAKE_INSTALL_PREFIX} OUTPUT_QUIET)"
520-
COMPONENT Runtime)
521-
522540
# install OpenSSL library
523541
if(KPXC_FEATURE_NETWORK)
524542
find_file(OPENSSL_DLL

0 commit comments

Comments
 (0)