From d3be87ff1d558f05309b1f29f7e71f291498584f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 20 Jun 2024 12:48:26 +0200 Subject: [PATCH] Apple: Don't `_debug`-suffix libraries in single config framework builds As part of fee15182949e88682131399c50b679be83a75385 we enabled framework debug builds, which left us with an inconsistent library naming. The framework libraries are always unsuffixed, e.g. QtGui.framework/QtGui, while we were adding _debug suffixes to the plugins and static libs. This was confusing macdeployqt, as it uses simple string matching logic for "_debug_" to detect that a Qt build is a debug build, and since the framework library didn't have a suffix it then failed to deploy the suffixed plugins. We now follow the requirement from the framework naming and skip the suffixing for all libraries in this configuration. Pick-to: 6.8 Change-Id: I982253fc46c65aa3fab52f8658f62ef63cdac49f Reviewed-by: Alexandru Croitor --- cmake/QtTargetHelpers.cmake | 10 +++++++++- configure.cmake | 2 ++ .../corelib/plugin/qpluginloader/tst/CMakeLists.txt | 2 +- .../corelib/plugin/qpluginloader/tst_qpluginloader.cpp | 8 +++++--- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/cmake/QtTargetHelpers.cmake b/cmake/QtTargetHelpers.cmake index 32e00d030b2..32081eb1f62 100644 --- a/cmake/QtTargetHelpers.cmake +++ b/cmake/QtTargetHelpers.cmake @@ -494,7 +494,15 @@ function(qt_internal_setup_cmake_config_postfix) set(default_cmake_debug_postfix "d") endif() elseif(APPLE) - set(default_cmake_debug_postfix "_debug") + # Only add a suffix for explicit no-framework builds. + # For framework builds the library inside the framework + # is always unsuffixed, and we want to match that for + # plugins and other non-framework (static) libraries. + if(NOT (QT_FEATURE_framework OR FEATURE_framework + # Account for default in configure.json being ON + OR (NOT DEFINED QT_FEATURE_framework AND NOT DEFINED FEATURE_framework))) + set(default_cmake_debug_postfix "_debug") + endif() endif() set(custom_postfix_vars "") diff --git a/configure.cmake b/configure.cmake index 411a6f9f39e..db358bb7048 100644 --- a/configure.cmake +++ b/configure.cmake @@ -643,6 +643,8 @@ qt_feature("force_asserts" PUBLIC qt_feature("framework" PUBLIC LABEL "Build Apple Frameworks" AUTODETECT ON + # If changing this, please align with logic in + # qt_internal_setup_cmake_config_postfix. CONDITION APPLE ) qt_feature_definition("framework" "QT_MAC_FRAMEWORK_BUILD") diff --git a/tests/auto/corelib/plugin/qpluginloader/tst/CMakeLists.txt b/tests/auto/corelib/plugin/qpluginloader/tst/CMakeLists.txt index 16dd1cf9cfa..30931b4b28e 100644 --- a/tests/auto/corelib/plugin/qpluginloader/tst/CMakeLists.txt +++ b/tests/auto/corelib/plugin/qpluginloader/tst/CMakeLists.txt @@ -50,7 +50,7 @@ endif() ## Scopes: ##################################################################### -qt_internal_extend_target(tst_qpluginloader CONDITION QT_FEATURE_private_tests +qt_internal_extend_target(tst_qpluginloader LIBRARIES Qt::CorePrivate ) diff --git a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp index f4ecf5bfb35..4ff93f9de49 100644 --- a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp +++ b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp @@ -12,6 +12,8 @@ #include #include "theplugin/plugininterface.h" +#include + #if defined(QT_BUILD_INTERNAL) && defined(Q_OF_MACH_O) # include #endif @@ -33,10 +35,10 @@ using namespace Qt::StringLiterals; # define bundle_VALID true # define dylib_VALID true # define so_VALID true -# ifdef QT_NO_DEBUG -# define SUFFIX ".dylib" -# else +# if QT_CONFIG(debug) && !QT_CONFIG(framework) # define SUFFIX "_debug.dylib" +# else +# define SUFFIX ".dylib" # endif # define PREFIX "lib"