Xcode: Dynamically choose release/debug libs based on current configuration

Non-framework builds would automatically link to whatever Qt library
matched the config at the time of running qmake, eg hard-coded to
libQtCore_debug, while Xcode itself allowed the user to switch between
release and debug configurations.

We now append an Xcode settings variable to the library path, which gets
resolved at build time depending on the current config in Xcode.

Change-Id: I12873e38a28d9595ef3fd0ae0ad849e6744833a9
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Reviewed-by: Andy Shaw <andy.shaw@digia.com>
This commit is contained in:
Tor Arne Vestbø 2013-10-14 15:09:00 +02:00 committed by The Qt Project
parent 15ddb91bc7
commit 5c92a8b70a
3 changed files with 50 additions and 7 deletions

View File

@ -23,3 +23,9 @@ isEmpty(QMAKE_XCODE_VERSION) {
isEmpty(QMAKE_XCODE_VERSION): error("Could not resolve Xcode version.")
unset(xcode_version)
}
# These two variables are used by the xcode_dynamic_library_suffix
# feature, which allows Xcode to choose the Qt libraries to link to
# at build time, depending on the current Xcode SDK and configuration.
QMAKE_XCODE_LIBRARY_SUFFIX = $$qtPlatformTargetSuffix()
QMAKE_XCODE_LIBRARY_SUFFIX_SETTING = QT_LIBRARY_SUFFIX

View File

@ -36,11 +36,34 @@ CONFIG(debug, debug|release): \
else: \
CONFIG -= debug
debug_and_release {
!macx-xcode: addExclusiveBuilds(debug, Debug, release, Release)
} else: fix_output_dirs {
debug: \
fixExclusiveOutputDirs(debug, release)
else: \
fixExclusiveOutputDirs(release, debug)
!macx-xcode {
debug_and_release {
addExclusiveBuilds(debug, Debug, release, Release)
} else: fix_output_dirs {
debug: \
fixExclusiveOutputDirs(debug, release)
else: \
fixExclusiveOutputDirs(release, debug)
}
} else {
# The Xcode generator always generates project files with
# debug and release configurations, regardless of whether
# or not debug_and_release is active.
for(build, $$list(debug release)) {
suffix =
contains(QT_CONFIG, debug_and_release) {
equals(build, debug): \
suffix = _debug
} else {
contains(QT_CONFIG, debug): \
suffix = _debug
}
library_suffix_$${build}.name = $$QMAKE_XCODE_LIBRARY_SUFFIX_SETTING
library_suffix_$${build}.value = $$suffix
library_suffix_$${build}.build = $$build
QMAKE_MAC_XCODE_SETTINGS += library_suffix_$${build}
CONFIG *= xcode_dynamic_library_suffix
}
}

View File

@ -874,6 +874,20 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
debug_msg(1, "pbuilder: Found library (%s) via PRL %s (%s)",
opt.toLatin1().constData(), lib_file.toLatin1().constData(), library.toLatin1().constData());
remove = true;
if (project->isActiveConfig("xcode_dynamic_library_suffix")) {
QString suffixSetting = project->first("QMAKE_XCODE_LIBRARY_SUFFIX_SETTING").toQString();
if (!suffixSetting.isEmpty()) {
QString librarySuffix = project->first("QMAKE_XCODE_LIBRARY_SUFFIX").toQString();
suffixSetting = "$(" + suffixSetting + ")";
if (!librarySuffix.isEmpty()) {
library = library.replace(librarySuffix, suffixSetting);
name = name.remove(librarySuffix);
} else {
library = library.replace(name, name + suffixSetting);
}
}
}
}
}
}