summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2022-02-08 17:23:20 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-02-09 14:56:10 +0000
commit4445fe17f1f4b0cbe4349e85eb31eca68e2716e9 (patch)
tree6a8a55b92c647ec7a3dd7b07515fd33cabac5271 /cmake
parente3de262b601a82813cd59b86acd32b1ae110a3e4 (diff)
CMake: Assign proper postfixes in multi-config builds
In a single-config build on Linux, we usually don't want a debug postfix in library names (as opposed to Windows/macOS). But when doing a multi-config build on Linux, assigning no postfixes causes CMake to generate rules for a single config only, the first one specified in CMAKE_CONFIGURATION_TYPES. This leads to being unable to build all configurations from the same build.ninja file as well as other obscure issues like race-conditions when generating prl files. To address this, when doing a multi-config build, always assign a postfix for each config except the first release-like one, while preserving the existing rules we had for debug postfix names. Fixes: QTBUG-100493 Change-Id: Ie9c88e074abdcf2961d7b3dee19a5694292717b8 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> (cherry picked from commit 90b07054f6de3ad101416b1ab5a10d7fee801a1c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtSetup.cmake31
1 files changed, 29 insertions, 2 deletions
diff --git a/cmake/QtSetup.cmake b/cmake/QtSetup.cmake
index ee42e9e785..7db9612cd9 100644
--- a/cmake/QtSetup.cmake
+++ b/cmake/QtSetup.cmake
@@ -39,8 +39,35 @@ else()
message(STATUS "CMAKE_BUILD_TYPE was set to: '${CMAKE_BUILD_TYPE}'")
endif()
-# Appends a 'debug postfix' to library targets (not executables)
-# e.g. lib/libQt6DBus_debug.5.12.0.dylib
+# Append a config-specific postfix to library names to ensure distinct names
+# in a multi-config build.
+# e.g. lib/libQt6DBus_relwithdebinfo.6.3.0.dylib
+# Don't apply the postfix to the first encountered release-like config, so we have at least one
+# config without a postifx.
+if(QT_GENERATOR_IS_MULTI_CONFIG AND CMAKE_CONFIGURATION_TYPES)
+ set(__qt_setup_release_configs Release RelWithDebInfo MinSizeRel)
+ set(__qt_setup_found_first_release_config FALSE)
+ foreach(__qt_setup_config_type IN LISTS CMAKE_CONFIGURATION_TYPES)
+ # Skip assigning postfix for the first release-like config.
+ if(NOT __qt_setup_found_first_release_config
+ AND __qt_setup_config_type IN_LIST __qt_setup_release_configs)
+ set(__qt_setup_found_first_release_config TRUE)
+ continue()
+ endif()
+
+ string(TOLOWER "${__qt_setup_config_type}" __qt_setup_config_type_lower)
+ string(TOUPPER "${__qt_setup_config_type}" __qt_setup_config_type_upper)
+ set(CMAKE_${__qt_setup_config_type_upper}_POSTFIX "_${__qt_setup_config_type_lower}")
+ if(APPLE)
+ set(CMAKE_FRAMEWORK_MULTI_CONFIG_POSTFIX_${__qt_setup_config_type_upper}
+ "_${__qt_setup_config_type_lower}")
+ endif()
+ endforeach()
+endif()
+
+# Override the generic debug postfixes above with custom debug postfixes (even in a single config
+# build) to follow the conventions we had since Qt 5.
+# e.g. lib/libQt6DBus_debug.6.3.0.dylib
if(WIN32)
if(MINGW)
# On MinGW we don't have "d" suffix for debug libraries like on Linux,