Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-92878

[qt6/cmake] Qt Resource object libraries not found in sibling scopes due to not being global

    XMLWordPrintable

Details

    • 561fc8107f38b93808343e35c62d7d06704f8eb6 (qt/qtbase/dev) a4e53acc0c7a0a54302cd0ba42a188caf4640d9a (qt/qtbase/6.2)

    Description

      i'm having troubles with setting up a scalable setup:

      i define a library in subdir/CMakeLists.txt:

      add_library(lib lib.cpp)
      
      find_package(Qt6 COMPONENTS Core Gui Widgets Qml Quick REQUIRED)
      target_link_libraries(lib Qt6::Gui Qt6::QCocoaIntegrationPlugin)
      

      this library links to qt6 libraries.

      my executable in the root `CMakeLists.txt` consumes the library:

      project(foo)
      cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
      add_subdirectory(subdir)
      add_executable(exe main.cpp)
      target_link_libraries(exe lib)
      

      this gives me the following cmake configuration error:

      CMake Error at CMakeLists.txt:8 (target_link_libraries):
        Error evaluating generator expression:
      
          $<TARGET_OBJECTS:Qt6::Gui_resources_1>
      
        Objects of target "Qt6::Gui_resources_1" referenced but no such target
        exists.
      
      
      CMake Error at CMakeLists.txt:8 (target_link_libraries):
        Error evaluating generator expression:
      
          $<TARGET_OBJECTS:Qt6::QCocoaIntegrationPlugin_resources_1>
      
        Objects of target "Qt6::QCocoaIntegrationPlugin_resources_1" referenced but
        no such target exists.
      
      
      CMake Error at CMakeLists.txt:8 (target_link_libraries):
        Error evaluating generator expression:
      
          $<TARGET_OBJECTS:Qt6::Gui_resources_1>
      
        Objects of target "Qt6::Gui_resources_1" referenced but no such target
        exists.
      
      
      CMake Error at CMakeLists.txt:8 (target_link_libraries):
        Error evaluating generator expression:
      
          $<TARGET_OBJECTS:Qt6::QCocoaIntegrationPlugin_resources_1>
      
        Objects of target "Qt6::QCocoaIntegrationPlugin_resources_1" referenced but
        no such target exists.
      
      
      -- Generating done
      

      afaict the qt/cmake targets are IMPORTED targets, which are not GLOBAL. therefore the generator expression expands in a context where this target does not exist anymore. things work again once i move the `find_package` expression to the root CMakeLists.txt. unfortunately this is not a solution that i can easily apply to my whole codebase, which is rather modular and as many different consuming endpoints

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              alexandru.croitor Alexandru Croitor
              timblechmann tim blechmann
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews