From 2a4cf923f4022760f9ed0f5dc50f8b849433b3f9 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 13 Aug 2019 13:41:38 +0200 Subject: Do not prepend QMAKE_PREFIX_STATICLIB to TARGET for TEMPLATE aux This was introduced by accident in 4da47d0f. Fixes: QTBUG-77429 Change-Id: Ic3d9052e1fc83dab5ed3b8725629588208b0d7bb Reviewed-by: Oliver Wolff --- qmake/generators/unix/unixmake2.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'qmake') diff --git a/qmake/generators/unix/unixmake2.cpp b/qmake/generators/unix/unixmake2.cpp index c326692ded..9888b4816a 100644 --- a/qmake/generators/unix/unixmake2.cpp +++ b/qmake/generators/unix/unixmake2.cpp @@ -1206,8 +1206,10 @@ void UnixMakefileGenerator::init2() project->values("QMAKE_FRAMEWORK_VERSION").append(project->first("VER_MAJ")); if (project->first("TEMPLATE") == "aux") { - project->values("PRL_TARGET") = - project->values("TARGET").first().prepend(project->first("QMAKE_PREFIX_STATICLIB")); + project->values("PRL_TARGET") = { + project->first("QMAKE_PREFIX_STATICLIB") + + project->first("TARGET") + }; } else if (!project->values("QMAKE_APP_FLAG").isEmpty()) { if(!project->isEmpty("QMAKE_BUNDLE")) { ProString bundle_loc = project->first("QMAKE_BUNDLE_LOCATION"); -- cgit v1.2.3 From 97465b1540ebd095225679b5dd400b2d4d54e678 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 26 Aug 2019 13:48:03 +0200 Subject: Don't add default lib dirs to LIBRARY_SEARCH_PATHS in xcode projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Having hard-coded absolute paths in the xcode project breaks switching between iOS and simulator builds. Fixes: QTBUG-77804 Change-Id: Ib655bfc774b92c413a7b94ba4d005b6e1c4d2905 Reviewed-by: Tor Arne Vestbø --- qmake/generators/mac/pbuilder_pbx.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'qmake') diff --git a/qmake/generators/mac/pbuilder_pbx.cpp b/qmake/generators/mac/pbuilder_pbx.cpp index d5994639b3..1b2c68e430 100644 --- a/qmake/generators/mac/pbuilder_pbx.cpp +++ b/qmake/generators/mac/pbuilder_pbx.cpp @@ -825,6 +825,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) } if(!project->isActiveConfig("staticlib")) { //DUMP LIBRARIES + const ProStringList defaultLibDirs = project->values("QMAKE_DEFAULT_LIBDIRS"); ProStringList &libdirs = project->values("QMAKE_PBX_LIBPATHS"), &frameworkdirs = project->values("QMAKE_FRAMEWORKPATH"); static const char * const libs[] = { "LIBS", "LIBS_PRIVATE", @@ -943,8 +944,10 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) } if(slsh != -1) { const QString path = QFileInfo(library.left(slsh)).absoluteFilePath(); - if(!path.isEmpty() && !libdirs.contains(path)) + if (!path.isEmpty() && !libdirs.contains(path) + && !defaultLibDirs.contains(path)) { libdirs += path; + } } library = fileFixify(library, FileFixifyFromOutdir | FileFixifyAbsolute); QString key = keyFor(library); -- cgit v1.2.3 From fc6d569862e524cf46c322eb0cdcdd6ac641dcef Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 13 Aug 2019 13:41:38 +0200 Subject: Do not prepend QMAKE_PREFIX_STATICLIB to TARGET for TEMPLATE aux This was introduced by accident in 4da47d0f. Fixes: QTBUG-77429 Change-Id: Ic3d9052e1fc83dab5ed3b8725629588208b0d7bb Reviewed-by: Oliver Wolff (cherry picked from commit 2a4cf923f4022760f9ed0f5dc50f8b849433b3f9) Reviewed-by: Kai Koehne --- qmake/generators/unix/unixmake2.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'qmake') diff --git a/qmake/generators/unix/unixmake2.cpp b/qmake/generators/unix/unixmake2.cpp index abc37149a9..84f55ca689 100644 --- a/qmake/generators/unix/unixmake2.cpp +++ b/qmake/generators/unix/unixmake2.cpp @@ -1202,8 +1202,10 @@ void UnixMakefileGenerator::init2() project->values("QMAKE_FRAMEWORK_VERSION").append(project->first("VER_MAJ")); if (project->first("TEMPLATE") == "aux") { - project->values("PRL_TARGET") = - project->values("TARGET").first().prepend(project->first("QMAKE_PREFIX_STATICLIB")); + project->values("PRL_TARGET") = { + project->first("QMAKE_PREFIX_STATICLIB") + + project->first("TARGET") + }; } else if (!project->values("QMAKE_APP_FLAG").isEmpty()) { if(!project->isEmpty("QMAKE_BUNDLE")) { ProString bundle_loc = project->first("QMAKE_BUNDLE_LOCATION"); -- cgit v1.2.3 From 7b82d27429cde931114776f1a26f4c3850c8bb72 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 26 Aug 2019 15:21:03 +0200 Subject: Fix library suffix replacement for xcode projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In xcode projects we replace the _debug part of referenced libraries with the variable $(QT_LIBRARY_SUFFIX). This only worked for libraries passed with -l. Make the library suffix replacement work for libraries passed as absolute paths too. Fixes: QTBUG-77804 Change-Id: Iac2dbd2f67c3fa0f415ac43cbab5a906657164e5 Reviewed-by: Tor Arne Vestbø --- qmake/generators/mac/pbuilder_pbx.cpp | 110 +++++++++++++++++++++------------- qmake/generators/mac/pbuilder_pbx.h | 2 + 2 files changed, 69 insertions(+), 43 deletions(-) (limited to 'qmake') diff --git a/qmake/generators/mac/pbuilder_pbx.cpp b/qmake/generators/mac/pbuilder_pbx.cpp index d5994639b3..b7c3031b7b 100644 --- a/qmake/generators/mac/pbuilder_pbx.cpp +++ b/qmake/generators/mac/pbuilder_pbx.cpp @@ -514,6 +514,56 @@ static QList provisioningTeams() return flatTeams; } +bool ProjectBuilderMakefileGenerator::replaceLibrarySuffix(const QString &lib_file, + const ProString &opt, + QString &name, QString &library) +{ + /* This isn't real nice, but it is real useful. This looks in a prl + for what the library will ultimately be called so we can stick it + in the ProjectFile. If the prl format ever changes (not likely) then + this will not really work. However, more concerning is that it will + encode the version number in the Project file which might be a bad + things in days to come? --Sam + */ + if (lib_file.isEmpty()) + return false; + + QMakeMetaInfo libinfo; + if (!libinfo.readLib(lib_file) || libinfo.isEmpty("QMAKE_PRL_TARGET")) + return false; + + const QString libDir = fileInfo(lib_file).absolutePath(); + library = libDir + Option::dir_sep + libinfo.first("QMAKE_PRL_TARGET"); + + debug_msg(1, "pbuilder: Found library (%s) via PRL %s (%s)", + opt.toLatin1().constData(), lib_file.toLatin1().constData(), library.toLatin1().constData()); + + 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()) { + int pos = library.lastIndexOf(librarySuffix + '.'); + if (pos == -1) { + warn_msg(WarnLogic, "Failed to find expected suffix '%s' for library '%s'.", + qPrintable(librarySuffix), qPrintable(library)); + } else { + library.replace(pos, librarySuffix.length(), suffixSetting); + if (name.endsWith(librarySuffix)) + name.chop(librarySuffix.length()); + } + } else { + int pos = library.lastIndexOf(name); + if (pos != -1) + library.insert(pos + name.length(), suffixSetting); + } + } + } + + return true; +} + bool ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) { @@ -832,6 +882,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) for (int i = 0; libs[i]; i++) { tmp = project->values(libs[i]); for(int x = 0; x < tmp.count();) { + bool libSuffixReplaced = false; bool remove = false; QString library, name; ProString opt = tmp[x]; @@ -844,49 +895,12 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) QString lib("lib" + name); for (ProStringList::Iterator lit = libdirs.begin(); lit != libdirs.end(); ++lit) { if(project->isActiveConfig("link_prl")) { - /* This isn't real nice, but it is real useful. This looks in a prl - for what the library will ultimately be called so we can stick it - in the ProjectFile. If the prl format ever changes (not likely) then - this will not really work. However, more concerning is that it will - encode the version number in the Project file which might be a bad - things in days to come? --Sam - */ - QString lib_file = QMakeMetaInfo::checkLib(Option::normalizePath( - (*lit) + Option::dir_sep + lib + Option::prl_ext)); - if (!lib_file.isEmpty()) { - QMakeMetaInfo libinfo; - if(libinfo.readLib(lib_file)) { - if(!libinfo.isEmpty("QMAKE_PRL_TARGET")) { - library = (*lit) + Option::dir_sep + libinfo.first("QMAKE_PRL_TARGET"); - 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()) { - int pos = library.lastIndexOf(librarySuffix + '.'); - if (pos == -1) { - warn_msg(WarnLogic, "Failed to find expected suffix '%s' for library '%s'.", - qPrintable(librarySuffix), qPrintable(library)); - } else { - library.replace(pos, librarySuffix.length(), suffixSetting); - if (name.endsWith(librarySuffix)) - name.chop(librarySuffix.length()); - } - } else { - int pos = library.lastIndexOf(name); - if (pos != -1) - library.insert(pos + name.length(), suffixSetting); - } - } - } - } - } - } + const QString prlFilePath = QMakeMetaInfo::checkLib( + Option::normalizePath((*lit) + Option::dir_sep + lib + + Option::prl_ext)); + if (replaceLibrarySuffix(prlFilePath, opt, name, library)) + remove = true; + libSuffixReplaced = true; } if(!remove) { QString extns[] = { ".dylib", ".so", ".a", QString() }; @@ -936,6 +950,16 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) } } if(!library.isEmpty()) { + if (!libSuffixReplaced) { + const QFileInfo fi = fileInfo(library); + const QString prlFilePath = QMakeMetaInfo::checkLib( + Option::normalizePath(fi.absolutePath() + '/' + fi.completeBaseName() + + Option::prl_ext)); + if (!prlFilePath.isEmpty()) { + name = fi.completeBaseName().mid(3); + replaceLibrarySuffix(prlFilePath, opt, name, library); + } + } const int slsh = library.lastIndexOf(Option::dir_sep); if(name.isEmpty()) { if(slsh != -1) diff --git a/qmake/generators/mac/pbuilder_pbx.h b/qmake/generators/mac/pbuilder_pbx.h index f15c814cb4..a7b21a0dab 100644 --- a/qmake/generators/mac/pbuilder_pbx.h +++ b/qmake/generators/mac/pbuilder_pbx.h @@ -41,6 +41,8 @@ class ProjectBuilderMakefileGenerator : public UnixMakefileGenerator bool writeSubDirs(QTextStream &); bool writeMakeParts(QTextStream &); bool writeMakefile(QTextStream &) override; + bool replaceLibrarySuffix(const QString &lib_file, const ProString &opt, QString &name, + QString &library); QString pbxbuild(); QHash keys; -- cgit v1.2.3 From abfb1b8665923ce2824392f3a04e5e4ac3871017 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 26 Aug 2019 13:48:03 +0200 Subject: Don't add default lib dirs to LIBRARY_SEARCH_PATHS in xcode projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Having hard-coded absolute paths in the xcode project breaks switching between iOS and simulator builds. Fixes: QTBUG-77804 Change-Id: Ib655bfc774b92c413a7b94ba4d005b6e1c4d2905 (cherry picked from commit 97465b1540ebd095225679b5dd400b2d4d54e678) Reviewed-by: Tor Arne Vestbø --- qmake/generators/mac/pbuilder_pbx.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'qmake') diff --git a/qmake/generators/mac/pbuilder_pbx.cpp b/qmake/generators/mac/pbuilder_pbx.cpp index b7c3031b7b..8f3eb738b4 100644 --- a/qmake/generators/mac/pbuilder_pbx.cpp +++ b/qmake/generators/mac/pbuilder_pbx.cpp @@ -875,6 +875,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) } if(!project->isActiveConfig("staticlib")) { //DUMP LIBRARIES + const ProStringList defaultLibDirs = project->values("QMAKE_DEFAULT_LIBDIRS"); ProStringList &libdirs = project->values("QMAKE_PBX_LIBPATHS"), &frameworkdirs = project->values("QMAKE_FRAMEWORKPATH"); static const char * const libs[] = { "LIBS", "LIBS_PRIVATE", @@ -967,8 +968,10 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) } if(slsh != -1) { const QString path = QFileInfo(library.left(slsh)).absoluteFilePath(); - if(!path.isEmpty() && !libdirs.contains(path)) + if (!path.isEmpty() && !libdirs.contains(path) + && !defaultLibDirs.contains(path)) { libdirs += path; + } } library = fileFixify(library, FileFixifyFromOutdir | FileFixifyAbsolute); QString key = keyFor(library); -- cgit v1.2.3 From 4ac872639ed0dd3ae6627e05bdda821f7d128500 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Thu, 9 Nov 2017 18:00:46 +0100 Subject: Make Qt relocatable [ChangeLog][QtCore] Qt installations on the host system can now be relocated, i.e. moved to other directories. Add a new feature 'relocatable' that's by default enabled for non-static builds - on platforms where libdl is available, - on macOS when configured with -framework, - on Windows. If the feature is enabled, the directory where plugins, translations and other assets are loaded from is determined by the location of libQt5Core.so and the lib dir (bin dir on Windows) relative to the prefix. For static builds, the feature 'relocatable' is off by default. It can be turned on manually by passing -feature-relocatable to configure. In that case, QLibraryInfo::location(QLibraryInfo::TranslationsPaths) and friends will return paths rooted in the user application's directory. The installed and relocated qmake determines properties like QT_INSTALL_PREFIX and QT_HOST_PREFIX from the location of the qmake executable and the host bin dir relative to the host prefix. This is now always done, independent of the 'relocatable' feature. Note that qmake is currently only relocatable within an environment that has the same layout as the original build machine due to absolute paths to the original prefix in .prl, .pc and .la files. This will be addressed in a separate patch. Task-number: QTBUG-15234 Change-Id: I7319e2856d8fe17f277082d71216442f52580633 Reviewed-by: Alexandru Croitor --- qmake/option.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'qmake') diff --git a/qmake/option.cpp b/qmake/option.cpp index d8143468e6..9ec2fe6411 100644 --- a/qmake/option.cpp +++ b/qmake/option.cpp @@ -658,4 +658,9 @@ QString qmake_libraryInfoFile() return QString(); } +QString qmake_abslocation() +{ + return Option::globals->qmake_abslocation; +} + QT_END_NAMESPACE -- cgit v1.2.3