Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect QtInstallPaths for debug configuration #43975

Open
Cortana4 opened this issue Feb 22, 2025 · 1 comment
Open

Incorrect QtInstallPaths for debug configuration #43975

Cortana4 opened this issue Feb 22, 2025 · 1 comment
Labels
category:community-triplet A PR or issue related to community triplets not officially validated by the vcpkg team.

Comments

@Cortana4
Copy link

Cortana4 commented Feb 22, 2025

Describe the bug
The qtbase package includes a QtInstallPaths.cmake, where the relative path to the Qt plugins directory is hard coded to "Qt6/plugins". But this is only correct for the release configuration of Qt. In the debug configuration the plugins are instead located at "debug/Qt6/plugins". This results in an incorrect evaluated install path for the Qt plugins when running the generic Qt deploy tool via the cmake API in linux.

Environment

  • OS: Ubuntu 22.04.5 LTS running in WSL on Windows 10

To Reproduce
Steps to reproduce the behavior:

  1. download the attached files into any folder
  2. remove the .txt extension from main.h and main.cpp (.h and .cpp files could not be uploaded)
  3. change toolchainFile in CMakePresets.json according to your vcpkg installation
  4. run "cmake --preset=linux-x64-dynamic-debug"
  5. run "cmake --build --preset=linux-x64-dynamic-debug --target install"
  6. inspect the installed directory structure

Expected behavior
The plugins should be installed to "install/x64-dynamic-debug/plugins" but are actually installed to "install/debug/Qt6/plugins".

Failure logs
none

Additional context
Instead of deploying to "install/plugins" (just like it deploys .so files to "install/lib"), the plugins are deployed to "install/plugins/../../debug/Qt6/plugins". I have traced this down to the _qt_internal_generic_deployqt function, which is defined in Qt6CoreDeploySupport.cmake. In this function, the install path for a plugin file is constructed by determining its relative path to "Qt6/plugins". But since the debug version of the plugin file is specified, the
constructed path is not relative to a file within "Qt6/plugins" as intended. Instead, it leaves the scope of "Qt6/plugins", to reach the actual file in "../../debug/Qt6/plugins".

In _qt_internal_generic_deployqt, the path "Qt6/plugins" is contained in __QT_DEPLOY_QT_INSTALL_PLUGINS. This variable is set in the QtDeploySupport.cmake, which is contained in the .qt folder of the cmake build directory. I have figured out, that this is an auto generated script, which is written by the _qt_internal_setup_deploy_support function defined in Qt6CoreMacros.cmake. Here, the value of the variable QT6_INSTALL_PLUGINS is used to set __QT_DEPLOY_QT_INSTALL_PLUGINS. And the value for QT6_INSTALL_PLUGINS is set in QtInstallPaths.cmake as mentioned.

So I think the different locations for debug and release configuration should be respected in QtInstallPaths.cmake.

Here are the paths of the mentioned files for investigation:
vcpkg_installed\x64-linux-dynamic\share\Qt6\QtInstallPaths.cmake
vcpkg_installed\x64-linux-dynamic\share\Qt6Core\Qt6CoreDeploySupport.cmake
vcpkg_installed\x64-linux-dynamic\share\Qt6Core\Qt6CoreMacros.cmake
build.qt\QtDeploySupport.cmake

I have also found a dirty hack to work around this issue. You can manually overwrite the internal __QT_DEPLOY_QT_INSTALL_PLUGINS variable to use the correct path:

qt_generate_deploy_script(
TARGET ${TARGET_FILE}
OUTPUT_SCRIPT DEPLOY_SCRIPT
CONTENT "
set(__QT_DEPLOY_QT_INSTALL_PLUGINS "debug/Qt6/plugins")

qt_deploy_runtime_dependencies(
EXECUTABLE "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$<TARGET_FILE_NAME:${TARGET_FILE}>"
)")

@Cortana4
Copy link
Author

@JonLiu1993 JonLiu1993 added the category:community-triplet A PR or issue related to community triplets not officially validated by the vcpkg team. label Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:community-triplet A PR or issue related to community triplets not officially validated by the vcpkg team.
Projects
None yet
Development

No branches or pull requests

2 participants