Simplify prefix-related functionality of qmake

Since the QT_CONFIGURE_HOSTBINDIR_TO_HOSTPREFIX_PATH and
QT_CONFIGURE_HOSTBINDIR_TO_EXTPREFIX_PATH definitions keep the same
value in modern CMake build, no need to have special handling in cases
where these values are used in qmake. Also it will be useful to
specify the relative path to the prefix directory from the directories
different of 'bin' when use QMakeLibraryInfo.

Task-number: QTBUG-75870
Change-Id: I5a777001eb334dcf05e22853a514d4257352d59b
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Alexey Edelev 2021-03-01 15:31:42 +01:00
parent 93f55570c4
commit d1101c460e
4 changed files with 12 additions and 29 deletions

View File

@ -83,15 +83,6 @@ function(qt_generate_qconfig_cpp in_file out_file)
"${lib_location_absolute_path}" "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}") "${lib_location_absolute_path}" "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}")
set(QT_CONFIGURE_LIBLOCATION_TO_PREFIX_PATH "${from_lib_location_to_prefix}") set(QT_CONFIGURE_LIBLOCATION_TO_PREFIX_PATH "${from_lib_location_to_prefix}")
# The QT_CONFIGURE_HOSTBINDIR_TO_*PREFIX_PATH defines are exclusively used by qmake to determine
# the prefix from the location of the qmake executable. In our build of qmake host_prefix is
# always the same as ext_prefix, and we can just use CMAKE_INSTALL_PREFIX for the calculation of
# the relative path between <ext_prefix>/bin and <ext_prefix>.
set(bin_dir_absolute_path "${CMAKE_INSTALL_PREFIX}/${INSTALL_BINDIR}")
file(RELATIVE_PATH from_bin_dir_to_prefix "${bin_dir_absolute_path}" "${CMAKE_INSTALL_PREFIX}")
set(QT_CONFIGURE_HOSTBINDIR_TO_HOSTPREFIX_PATH "${from_bin_dir_to_prefix}")
set(QT_CONFIGURE_HOSTBINDIR_TO_EXTPREFIX_PATH "${from_bin_dir_to_prefix}")
configure_file(${in_file} ${out_file} @ONLY) configure_file(${in_file} ${out_file} @ONLY)
endfunction() endfunction()

View File

@ -21,6 +21,14 @@ Required features:
return() return()
endif() endif()
# The QT_CONFIGURE_HOSTBINDIR_TO_*PREFIX_PATH defines are exclusively used by qmake to determine
# the prefix from the location of the qmake executable. In our build of qmake host_prefix is
# always the same as ext_prefix, and we can just use CMAKE_INSTALL_PREFIX for the calculation of
# the relative path between <ext_prefix>/bin and <ext_prefix>.
file(RELATIVE_PATH QT_CONFIGURE_RELATIVE_PREFIX_PATH
"${CMAKE_INSTALL_PREFIX}/${INSTALL_BINDIR}" "${CMAKE_INSTALL_PREFIX}"
)
qt_get_tool_target_name(target_name qmake) qt_get_tool_target_name(target_name qmake)
qt_internal_add_tool(${target_name} qt_internal_add_tool(${target_name}
TOOLS_TARGET Core # special case TOOLS_TARGET Core # special case
@ -65,6 +73,7 @@ qt_internal_add_tool(${target_name}
QT_VERSION_MAJOR=${PROJECT_VERSION_MAJOR} # special case QT_VERSION_MAJOR=${PROJECT_VERSION_MAJOR} # special case
QT_VERSION_MINOR=${PROJECT_VERSION_MINOR} # special case QT_VERSION_MINOR=${PROJECT_VERSION_MINOR} # special case
QT_VERSION_PATCH=${PROJECT_VERSION_PATCH} # special case QT_VERSION_PATCH=${PROJECT_VERSION_PATCH} # special case
QT_CONFIGURE_RELATIVE_PREFIX_PATH="${QT_CONFIGURE_RELATIVE_PREFIX_PATH}"
INCLUDE_DIRECTORIES INCLUDE_DIRECTORIES
generators generators
generators/mac generators/mac

View File

@ -139,26 +139,11 @@ void QMakeLibraryInfo::sysrootify(QString &path)
} }
} }
static QString getPrefixFromHostBinDir(const char *hostBinDirToPrefixPath) static QString getPrefix()
{ {
const QString canonicalQMakePath = QFileInfo(qmake_abslocation()).canonicalPath(); const QString canonicalQMakePath = QFileInfo(qmake_abslocation()).canonicalPath();
return QDir::cleanPath(canonicalQMakePath + QLatin1Char('/') return QDir::cleanPath(canonicalQMakePath + QLatin1Char('/')
+ QLatin1String(hostBinDirToPrefixPath)); + QLatin1String(QT_CONFIGURE_RELATIVE_PREFIX_PATH));
}
static QString getExtPrefixFromHostBinDir()
{
return getPrefixFromHostBinDir(QT_CONFIGURE_HOSTBINDIR_TO_EXTPREFIX_PATH);
}
static QString getHostPrefixFromHostBinDir()
{
return getPrefixFromHostBinDir(QT_CONFIGURE_HOSTBINDIR_TO_HOSTPREFIX_PATH);
}
static QString getPrefix()
{
return getExtPrefixFromHostBinDir();
} }
QString QMakeLibraryInfo::path(int loc) QString QMakeLibraryInfo::path(int loc)
@ -271,7 +256,7 @@ QString QMakeLibraryInfo::rawLocation(int loc, QMakeLibraryInfo::PathGroup group
path = QT_CONFIGURE_SETTINGS_PATH; path = QT_CONFIGURE_SETTINGS_PATH;
#endif #endif
} else if (loc == HostPrefixPath) { } else if (loc == HostPrefixPath) {
static const QByteArray hostPrefixPath = getHostPrefixFromHostBinDir().toLatin1(); static const QByteArray hostPrefixPath = getPrefix().toLatin1();
path = hostPrefixPath.constData(); path = hostPrefixPath.constData();
} }

View File

@ -36,8 +36,6 @@ static const char qt_configure_strs[] =
; ;
#define QT_CONFIGURE_SETTINGS_PATH "@QT_SYS_CONF_DIR@" #define QT_CONFIGURE_SETTINGS_PATH "@QT_SYS_CONF_DIR@"
#define QT_CONFIGURE_LIBLOCATION_TO_PREFIX_PATH "@QT_CONFIGURE_LIBLOCATION_TO_PREFIX_PATH@" #define QT_CONFIGURE_LIBLOCATION_TO_PREFIX_PATH "@QT_CONFIGURE_LIBLOCATION_TO_PREFIX_PATH@"
#define QT_CONFIGURE_HOSTBINDIR_TO_EXTPREFIX_PATH "@QT_CONFIGURE_HOSTBINDIR_TO_EXTPREFIX_PATH@"
#define QT_CONFIGURE_HOSTBINDIR_TO_HOSTPREFIX_PATH "@QT_CONFIGURE_HOSTBINDIR_TO_HOSTPREFIX_PATH@"
#define QT_CONFIGURE_PREFIX_PATH qt_configure_prefix_path_str + 12 #define QT_CONFIGURE_PREFIX_PATH qt_configure_prefix_path_str + 12
#ifdef QT_BUILD_QMAKE #ifdef QT_BUILD_QMAKE
# define QT_CONFIGURE_EXT_PREFIX_PATH qt_configure_ext_prefix_path_str + 12 # define QT_CONFIGURE_EXT_PREFIX_PATH qt_configure_ext_prefix_path_str + 12