microsoft / vcpkg

C++ Library Manager for Windows, Linux, and MacOS
MIT License
22.64k stars 6.25k forks source link

[qttools] Install error. #38936

Closed reitowo closed 2 months ago

reitowo commented 2 months ago

Qt 6.7.0 doesn't handle CMake scripts properly at install command. When using qt_generate_deploy_app_script in my CMakeLists and install, it can't find qtpaths.exe. It is trying to find under vcpkg_installed/x64-windows/bin but it is in vcpkg_installed/x64_windows/tools/Qt6/bin. Also, when setting the qtpaths manually to correct path, it also trying to find all debug dlls under vcpkg_installed/x64-windows/bin instead of vcpkg_installed/x64_windows/debug/bin.

At least 6.4.3 version was working normally.

Qt really just don't like vcpkg's model, huh?

Neumann-A commented 2 months ago

can you give me an expanded trace with --trace-expand?

Probably an easy fix by adjusting the script

reitowo commented 2 months ago

--trace-expand which command this arg is apply to?

-- Running Qt deploy tool for E:/VTSLink/Client/VTSLink/out/build/x64-RelWithDebInfo/bin/VTSLink.exe in working directory 'E:/VTSLink/Client/VTSLink/out/install/x64-RelWithDebInfo'
'E:/VTSLink/Client/VTSLink/out/build/x64-RelWithDebInfo/vcpkg_installed/x64-windows/tools/Qt6/bin/windeployqt.exe' 'E:/VTSLink/Client/VTSLink/out/build/x64-RelWithDebInfo/bin/VTSLink.exe' '--dir' '.' '--libdir' 'bin' '--plugindir' 'plugins' '--qml-deploy-dir' 'qml' '--translationdir' 'translations' '--force' '--qtpaths' 'E:/VTSLink/Client/VTSLink/out/build/x64-RelWithDebInfo/vcpkg_installed/x64-windows/bin/qtpaths.exe'
Error: "E:\VTSLink\Client\VTSLink\out\build\x64-RelWithDebInfo\vcpkg_installed\x64-windows\bin\qtpaths.exe" does not exist.
CMake Error at vcpkg_installed/x64-windows/share/Qt6Core/Qt6CoreDeploySupport.cmake:528 (message):
  Executing
  E:/VTSLink/Client/VTSLink/out/build/x64-RelWithDebInfo/vcpkg_installed/x64-windows/tools/Qt6/bin/windeployqt.exe
  failed: 1
Call Stack (most recent call first):
  .qt/deploy_VTSLink_bfe1574f6c.cmake:5 (qt6_deploy_runtime_dependencies)
  cmake_install.cmake:58 (include)

vcpkg.json

{
  "name": "vts-link-client",
  "license": "GPL-2.0-only",
  "dependencies": [
    {
      "name": "libdatachannel",
      "default-features": true,
      "features": [ "ws", "stdcall" ]
    },
    {
      "name": "ffmpeg",
      "default-features": true,
      "features": [ "nvcodec", "qsv", "amf" ]
    },
    {
      "name": "grpc",
      "default-features": true,
      "features": [ "codegen" ]
    },
    "amd-amf",
    "mfx-dispatch",
    "protobuf",
    "concurrentqueue",
    "crashpad",
    "libqrencode",
    "detours",
    "pthreads",
    {
      "name": "spout2",
      "default-features": true,
      "features": [ "dx" ]
    },
    {
      "name": "qtbase",
      "default-features": false,
      "features": [
        "gui",
        "network",
        "thread",
        "widgets",
        "png"
      ]
    },
    "qttools",
    "qttranslations",
    "directxtk",
    {
      "name": "opencv2",
      "default-features": true,
      "features": [ "png" ]
    }
  ],
  "overrides": [
    {
      "name": "openssl",
      "version-string": "1.1.1m#2"
    },
    {
      "name": "qtbase",
      "version-string": "6.7.0"
    },
    {
      "name": "qttools",
      "version-string": "6.7.0#1"
    },
    {
      "name": "qttranslations",
      "version-string": "6.7.0"
    }
  ],
  "supports": "windows",
  "vcpkg-configuration": {
    "default-registry": {
      "kind": "git",
      "repository": "https://github.com/cnSchwarzer/vcpkg",
      "baseline": "bee2447e324d4a59fe460640683adbd2df3d8373",
      "reference": "reito"
    },
    "registries": [
    ]
  }
}
Neumann-A commented 2 months ago

Patch 1:

diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake
index 8a0d07feac..0e6a720c20 100644
--- a/src/corelib/Qt6CoreMacros.cmake   
+++ b/src/corelib/Qt6CoreMacros.cmake
@@ -2977,13 +2977,15 @@ function(_qt_internal_setup_deploy_support)
     if(CMAKE_HOST_WIN32)
         if(CMAKE_CROSSCOMPILING)
             set(qt_paths_ext ".bat")
+        elseif(CMAKE_BUILD_TYPE STREQUAL "Debug")
+            set(qt_paths_ext ".debug.bat")
         else()
             set(qt_paths_ext ".exe")
         endif()
     else()
         set(qt_paths_ext "")
     endif()
-    set(target_qtpaths_path "${QT6_INSTALL_PREFIX}/${QT6_INSTALL_BINS}/qtpaths${qt_paths_ext}")
+    set(target_qtpaths_path "${QT6_INSTALL_PREFIX}/tools/Qt6/bin/qtpaths${qt_paths_ext}")

     file(GENERATE OUTPUT "${QT_DEPLOY_SUPPORT}" CONTENT
 "cmake_minimum_required(VERSION 3.16...3.21)
Neumann-A commented 2 months ago

it also trying to find all debug dlls under vcpkg_installed/x64-windows/bin instead of vcpkg_installed/x64_windows/debug/bin.

For debug libs it needs to use windeployqt.debug.bat. The target should be setup accordingly. Did you call find_package with CoreTools ?

Neumann-A commented 2 months ago

And for testing you can just manually edit the installed tree with the patch above. That avoids reinstalling all of qt.

reitowo commented 2 months ago

The patch works! Thanks. Would you submit a PR?