From f753b6e9b322b72b0fd14ee8c1a6bd4c21388007 Mon Sep 17 00:00:00 2001 From: jkriege2 Date: Sun, 18 Jun 2023 15:15:36 +0200 Subject: [PATCH] IMPROCED windeployqt-handling in CMake-scripts (works better for Qt6.5) --- cmake/jkqtplotter_common_qtsettings.cmake | 17 +++++++++++++++++ cmake/jkqtplotter_deployqt.cmake | 20 +------------------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/cmake/jkqtplotter_common_qtsettings.cmake b/cmake/jkqtplotter_common_qtsettings.cmake index 5b17bd9f78..150b1d09b5 100644 --- a/cmake/jkqtplotter_common_qtsettings.cmake +++ b/cmake/jkqtplotter_common_qtsettings.cmake @@ -50,3 +50,20 @@ if (JKQtPlotter_ENABLED_CXX20) endif(JKQtPlotter_ENABLED_CXX20) set(JKQtPlotter_QT_BINDIR $) # ${QT_DIR}../../../../bin + +if (WIN32) + get_target_property(_qmake_executable Qt${QT_VERSION_MAJOR}::qmake IMPORTED_LOCATION) + get_filename_component(_qt_bin_dir "${_qmake_executable}" DIRECTORY) + find_program(JKQtPlotter_WINDEPLOYQT_ENV_SETUP qtenv2.bat HINTS "${_qt_bin_dir}") + if (CMAKE_BUILD_TYPE STREQUAL "Debug") + find_program(JKQtPlotter_WINDEPLOYQT_EXECUTABLE NAMES windeployqt.debug.bat HINTS "${_qt_bin_dir}") + else() + find_program(JKQtPlotter_WINDEPLOYQT_EXECUTABLE NAMES windeployqt HINTS "${_qt_bin_dir}") + endif() + if (NOT EXISTS ${JKQtPlotter_WINDEPLOYQT_EXECUTABLE}) + find_program(JKQtPlotter_WINDEPLOYQT_EXECUTABLE NAMES windeployqt HINTS "${_qt_bin_dir}") + endif() + if (NOT EXISTS ${WINDEPLOYQT_EXECUTABLE}) + find_program(JKQtPlotter_WINDEPLOYQT_EXECUTABLE NAMES windeployqt.exe HINTS "${_qt_bin_dir}") + endif() +endif(WIN32) diff --git a/cmake/jkqtplotter_deployqt.cmake b/cmake/jkqtplotter_deployqt.cmake index 2de9638015..5a85745910 100644 --- a/cmake/jkqtplotter_deployqt.cmake +++ b/cmake/jkqtplotter_deployqt.cmake @@ -1,24 +1,6 @@ function(jkqtplotter_deployqt TARGET_NAME) #use windeploy if (WIN32) - get_target_property(_qmake_executable Qt${QT_VERSION_MAJOR}::qmake IMPORTED_LOCATION) - get_filename_component(_qt_bin_dir "${_qmake_executable}" DIRECTORY) - find_program(WINDEPLOYQT_ENV_SETUP qtenv2.bat HINTS "${_qt_bin_dir}") - if (CMAKE_BUILD_TYPE STREQUAL "Debug") - find_program(WINDEPLOYQT_EXECUTABLE NAMES windeployqt.debug.bat HINTS "${_qt_bin_dir}") - else() - find_program(WINDEPLOYQT_EXECUTABLE NAMES windeployqt HINTS "${_qt_bin_dir}") - endif() - if (NOT EXISTS ${WINDEPLOYQT_EXECUTABLE}) - find_program(WINDEPLOYQT_EXECUTABLE NAMES windeployqt HINTS "${_qt_bin_dir}") - endif() - if (NOT EXISTS ${WINDEPLOYQT_EXECUTABLE}) - find_program(WINDEPLOYQT_EXECUTABLE NAMES windeployqt.exe HINTS "${_qt_bin_dir}") - endif() - - - - # install system runtime lib include( InstallRequiredSystemLibraries ) if( CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS ) @@ -27,7 +9,7 @@ function(jkqtplotter_deployqt TARGET_NAME) get_filename_component(CMAKE_CXX_COMPILER_BINPATH ${CMAKE_CXX_COMPILER} DIRECTORY ) add_custom_command(TARGET ${TARGET_NAME} POST_BUILD - COMMAND "${WINDEPLOYQT_ENV_SETUP}" && "${WINDEPLOYQT_EXECUTABLE}" \"$\" + COMMAND "${CMAKE_COMMAND}" -E env PATH="${JKQtPlotter_QT_BINDIR}" "${JKQtPlotter_WINDEPLOYQT_EXECUTABLE}" \"$\" --verbose 0 --no-translations --no-compiler-runtime COMMENT "Running windeployqt ... " ) endif(WIN32)