Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
6.0.3
-
None
-
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
- relates to
-
QTBUG-92933 Rework automatic static plugin linkage
- Closed
For Gerrit Dashboard: QTBUG-92878 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
350279,11 | CMake: Allow promoting the Qt libraries to be global targets | dev | qt/qtbase | Status: MERGED | +2 | 0 |
353726,6 | CMake: Promote all targets to global within a scope when possible | dev | qt/qtbase | Status: MERGED | +2 | 0 |
354827,2 | CMake: Allow promoting the Qt libraries to be global targets | 6.2 | qt/qtbase | Status: MERGED | +2 | 0 |
354828,2 | CMake: Promote all targets to global within a scope when possible | 6.2 | qt/qtbase | Status: MERGED | +2 | 0 |