summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2021-03-23 17:47:58 +0100
committerAlexandru Croitor <alexandru.croitor@qt.io>2021-03-26 13:31:21 +0100
commit9d1b1c71b29ed4c84195093c68c45f77796fb62f (patch)
tree18cad899d88c81ebb5d00ae57ebf3104fc77a5a1 /cmake
parent33fe70d5144af6daa141004a7bd4b2b7aa2002cc (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. Task-number: QTBUG-87580 Change-Id: I17c885f29bfdee45bec1d6aac7c3b26723e761a3 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 59c3be711728ab0aa644bfdf50e91a1b020f95bb)
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtQmakeHelpers.cmake17
1 files changed, 17 insertions, 0 deletions
diff --git a/cmake/QtQmakeHelpers.cmake b/cmake/QtQmakeHelpers.cmake
index cf15ada7b3..30db68170f 100644
--- a/cmake/QtQmakeHelpers.cmake
+++ b/cmake/QtQmakeHelpers.cmake
@@ -92,6 +92,23 @@ function(qt_generate_qconfig_cpp)
set(QT_CONFIGURE_HOSTBINDIR_TO_HOSTPREFIX_PATH "${from_bin_dir_to_prefix}")
set(QT_CONFIGURE_HOSTBINDIR_TO_EXTPREFIX_PATH "${from_bin_dir_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(global/qconfig.cpp.in global/qconfig.cpp @ONLY)
endfunction()