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

CMake configuration fails with Qt v6.8.1 #104

Open
petrmanek opened this issue Jan 6, 2025 · 1 comment
Open

CMake configuration fails with Qt v6.8.1 #104

petrmanek opened this issue Jan 6, 2025 · 1 comment
Assignees
Labels

Comments

@petrmanek
Copy link
Contributor

Describe the bug

When configuring QtUsb included in a cmake project using add_subdirectory, configuration fails with the following error message:

CMake Error at /usr/lib/cmake/Qt6/QtPublicTargetHelpers.cmake:307 (set_property):
  Attempt to promote imported target "Threads::Threads" to global scope (by
  setting IMPORTED_GLOBAL) which is not built in this directory.
Call Stack (most recent call first):
  /usr/lib/cmake/Qt6/QtPublicTargetHelpers.cmake:348 (__qt_internal_promote_target_to_global)
  /usr/lib/cmake/Qt6/QtPublicTargetHelpers.cmake:332 (_qt_internal_promote_3rd_party_target_to_global)
  /usr/lib/cmake/Qt6/QtPublicDependencyHelpers.cmake:59 (_qt_internal_promote_3rd_party_provided_target_and_3rd_party_deps_to_global)
  /usr/lib/cmake/Qt6/Qt6Dependencies.cmake:34 (_qt_internal_find_third_party_dependencies)
  /usr/lib/cmake/Qt6/Qt6Config.cmake:146 (include)
  lib/qtusb/CMakeLists.txt:13 (find_package)

Platform:

  • OS: Arch Linux (latest packages as of 2025-01-06)
  • Qt v6.8.1
  • cmake v3.31.3
  • QtUsb 4484292

To Reproduce
Steps to reproduce the behavior:

  1. Use specified versions of the toolchain.
  2. Create a Hello World cmake project that depends on QtUsb.
  3. Configure the cmake project.
  4. See error

Expected behavior

The cmake project should configure without any error messages.

Additional context

Did not find any

@petrmanek
Copy link
Contributor Author

I got more information. It seems that QtUsb manages to fool Qt into thinking that it is a part of the Qt repository.

In my /usr/lib/cmake/Qt6/QtPublicTargetHelpers.cmake I found the following snippet:

function(_qt_internal_promote_3rd_party_provided_target_and_3rd_party_deps_to_global target)
    # Return early if building a user project, and not Qt.
    # QT_BUILDING_QT is set when building a qt repo, but we also check for QT_REPO_MODULE_VERSION,
    # which is set in .cmake.conf, because _qt_internal_find_third_party_dependencies is called
    # before QT_BUILDING_QT is set.
    if(NOT (QT_BUILDING_QT OR QT_REPO_MODULE_VERSION))
        return()
    endif()

It seems that the variable QT_REPO_MODULE_VERSION is set to 6.4.2 from here and here, which prevents return() from being invoked in the referenced clause above.

I would recommend a patch along the following lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 31bb763..3a5c1dc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,7 +2,9 @@

 cmake_minimum_required(VERSION 3.16)

-include(.cmake.conf)
+if(QTUSB_MODULE)
+    include(.cmake.conf)
+endif()
 project(QtUsb
     VERSION         6.4.0 # FIXME: this needs to match host's Qt version
     DESCRIPTION     "A cross-platform USB Module for Qt."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants