summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2021-02-02 17:18:26 +0100
committerJoerg Bornemann <joerg.bornemann@qt.io>2021-02-03 09:22:21 +0100
commit74f549b4026710b484f17cd99dbafb074854bd11 (patch)
treeb531a063ae4edc645767fb81d9f76ad46c99ed7d /src
parent936d499ed4a27e6836e9525114830c57fbfd37f3 (diff)
Fix static build with tests
A static build of Qt with QT_BUILD_TESTS=ON would fail with errors like this: FAILED: tests/auto/corelib/io/qprocess/testProcessEcho2/testProcessEcho2 undefined reference to `qRegisterResourceData(...)' We create object libraries for resources. In this case, for the mimetypes of QtCore. For static builds we added the object files to INTERFACE_LINK_LIBRARIES of the Qt module the resource belongs to: target_link_libraries(Core INTERFACE "$<TARGET_OBJECTS:$<TARGET_NAME:${resource_target}>>") That is, however, a problem for projects that link only against QtCore, like testProcessEcho2 above. On the linker command line Qt6Core.a is before qrc_mimetypes.cpp.o and that doesn't work, because the latter needs symbols of the former. To have the resource object files before any other libraries on the linker's command line, we now treat them as source files. Pick-to: 6.0 Fixes: QTBUG-90582 Change-Id: Ia2786beb5f7c2eba194e8f00ae8785572df1cf6e Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/Qt6CoreMacros.cmake5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake
index 2a178de16c..c65203a969 100644
--- a/src/corelib/Qt6CoreMacros.cmake
+++ b/src/corelib/Qt6CoreMacros.cmake
@@ -1123,8 +1123,9 @@ function(__qt_propagate_generated_resource target resource_name generated_source
# Use TARGET_NAME genex to map to the correct prefixed target name when it is exported
# via qt_install(EXPORT), so that the consumers of the target can find the object library
# as well.
- target_link_libraries(${target} INTERFACE
- "$<TARGET_OBJECTS:$<TARGET_NAME:${resource_target}>>")
+ target_sources(${target} INTERFACE
+ "$<TARGET_OBJECTS:$<TARGET_NAME:${resource_target}>>")
+
set(${output_generated_target} "${resource_target}" PARENT_SCOPE)
# No need to compile Q_IMPORT_PLUGIN-containing files for non-executables.