diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2021-03-23 17:47:58 +0100 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2021-03-25 12:59:20 +0100 |
commit | 59c3be711728ab0aa644bfdf50e91a1b020f95bb (patch) | |
tree | 1935268b6f3c21cf09ed92bb4fa42ce9f0bfeafe /cmake/QtQmakeHelpers.cmake | |
parent | 04df85bbecdc034876d509b9c96a4f17fc990293 (diff) |
CMake: Fix qconfig.cpp embedded prefix in the CI
In the CI on a windows we configure Qt with the following prefix
-DCMAKE_INSTALL_PREFIX:PATH=\Users\qt\work\install
Note the lack of the drive letter.
This is intentional, so that we can abuse CMake's DESTDIR installation
mechanism to install into a custom path.
This causes trouble for static Qt builds in the CI.
Specifically when there is no qt.conf file next to qmake, qmake -query
will report a
QT_INSTALL_PREFIX:/Users/qt/work/install
and ultimately qmake will fail to locate the module .pri files in such
a path, showing errors like:
Project ERROR: Unknown module(s) in QT: core gui?
If a qt.conf is placed next to qmake (even an empty one), a differenct
code path is used in qmake to resolve the prefix, which returns a path
with a drive letter.
In a shared build, because the 'relocatable' feature is enabled by
default, a different code path is used and thus the prefix is
also successfully resolved.
So the problem is specific to static Windows Qt builds that have no
qt.conf file next to qmake.
This is the exact scenario that we encounter when running static
Qt tests (tst_qmake in particular).
To circumvent the issue, prepend a drive letter to the prefix
hardcoded into qconfig.cpp. Do that with
get_filename_component(REALPATH) which apparently resolves
to a fully qualified path.
Pick-to: 6.1
Task-number: QTBUG-87580
Change-Id: I17c885f29bfdee45bec1d6aac7c3b26723e761a3
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'cmake/QtQmakeHelpers.cmake')
-rw-r--r-- | cmake/QtQmakeHelpers.cmake | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/cmake/QtQmakeHelpers.cmake b/cmake/QtQmakeHelpers.cmake index f64032a77d..0a2c5b1531 100644 --- a/cmake/QtQmakeHelpers.cmake +++ b/cmake/QtQmakeHelpers.cmake @@ -66,6 +66,23 @@ function(qt_generate_qconfig_cpp in_file out_file) "${lib_location_absolute_path}" "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}") set(QT_CONFIGURE_LIBLOCATION_TO_PREFIX_PATH "${from_lib_location_to_prefix}") + # Ensure Windows drive letter is prepended to the install prefix hardcoded + # into qconfig.cpp, otherwise qmake can't find Qt modules in a static Qt + # build if there's no qt.conf. Mostly relevant for CI. + # Given input like + # \work/qt/install + # or + # \work\qt\install + # Expected output is something like + # C:/work/qt/install + # so it includes a drive letter and forward slashes. + set(QT_CONFIGURE_PREFIX_PATH_STR "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}") + if(WIN32) + get_filename_component( + QT_CONFIGURE_PREFIX_PATH_STR + "${QT_CONFIGURE_PREFIX_PATH_STR}" REALPATH) + endif() + configure_file(${in_file} ${out_file} @ONLY) endfunction() |