From a1752276e0f71f29df12317eaa81798ccbe2fa91 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Mon, 29 Apr 2019 13:14:22 +0200 Subject: [PATCH] CMake: Do not link qmake against Qt (not even the bootstrap one) Qmake should not rebuild all the code in QtCore, but currently it does. When linking against QtCore, all the symbols get duplicated. A clever linker will "deduplicate" the symbols again, so this actually works with shared Qt builds, but it fails for static builds. Do not rely on the linker being clever and just do not link Qt at all for qmake. Change-Id: I0f79ed9176a19ee884dd425e5f23c26cf69dc422 Reviewed-by: Tobias Hunger --- cmake/QtBuild.cmake | 18 +++++++++++++----- qmake/CMakeLists.txt | 1 + 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index ba70e82ce7..6f178e2e58 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -924,14 +924,22 @@ function(add_qt_tool name) return() endif() - qt_parse_all_arguments(arg "add_qt_tool" "BOOTSTRAP;NO_INSTALL" "" "${__default_private_args}" ${ARGN}) + qt_parse_all_arguments(arg "add_qt_tool" "BOOTSTRAP;NO_QT;NO_INSTALL" "" "${__default_private_args}" ${ARGN}) set(disable_autogen_tools "${arg_DISABLE_AUTOGEN_TOOLS}") - if (arg_BOOTSTRAP) - set(corelib ${QT_CMAKE_EXPORT_NAMESPACE}::Bootstrap) - list(APPEND disable_autogen_tools "uic" "moc" "rcc") + if (arg_NO_QT) + # FIXME: Remove NO_QT again once qmake can use a "normal" Qt! + if (arg_BOOTSTRAP) + message(FATAL_ERROR "Tool can not be NO_QT and BOOTSTRAP at the same time!") + endif() + set(corelib "") else() - set(corelib ${QT_CMAKE_EXPORT_NAMESPACE}::Core) + if (arg_BOOTSTRAP) + set(corelib ${QT_CMAKE_EXPORT_NAMESPACE}::Bootstrap) + list(APPEND disable_autogen_tools "uic" "moc" "rcc") + else() + set(corelib ${QT_CMAKE_EXPORT_NAMESPACE}::Core) + endif() endif() set(bootstrap "") diff --git a/qmake/CMakeLists.txt b/qmake/CMakeLists.txt index d40ec9119b..fc6e4ceea3 100644 --- a/qmake/CMakeLists.txt +++ b/qmake/CMakeLists.txt @@ -12,6 +12,7 @@ find_library(FWFoundation Foundation) # special case ##################################################################### add_qt_tool(qmake # special case + NO_QT # special case # GUI # special case: remove this SOURCES ../src/corelib/codecs/qutfcodec.cpp ../src/corelib/codecs/qutfcodec_p.h