summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2020-06-15 16:48:54 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2020-06-15 20:58:19 +0200
commitf626c73b28b52ecf3a3fb20592f2134337f89d35 (patch)
treec0c97bbd299b2a23f69970755680f002eab9260e /cmake
parent9e51974d9bace46c40ebe585102d3102eedc8a35 (diff)
CMake: Fix many failing qtdeclarative MinGW tests
A lot of qtdeclarative tests fail due to not finding the QtTest qml plugin in ${prefix}/qml. This is just the symptom, the problem is that the combination of CMake + MinGW + Qt relocatability behaves incorrectly. The value returned by QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath) for the qmltestrunner executable is ${prefix}/bin/qml which is incorrect. This happens due to a combination of things. The c33916a279ef5908e1ebd44644c873933f6a7c77 change in qtbase introduced checks to figure out whether an application is a windeployqt-ed app to adjust the prefix path. This check tries to find the import library libQt6Core.a in the lib subfolder whenever the executed app dir path is equal to the computed prefix path. If it's found, the code assumes we are running a tool in ${prefix}/bin. If it's not found, the code assumes it's a windeployqt'ed app, where the Qt .dlls are next to the executable. Currently when QtCore is built with CMake targeting MinGW, we actually create a libQt6Core.dll file instead of a Qt6Core.dll file, and also an import library called libQt6Core.dll.a, instead of libQt6Core.a. The prefix check code actually prepends an additional "lib", thus trying to find the liblibQt6Core.a import library. This fails, the code assumes a windeployqt'ed app, and returns the currently executed app path dir as the prefix aka ${prefix}/bin in the case of qmltestrunner, and thus none of the qml plugins are found. To fix this, generated the shared library and the import library names as qmake expects them, aka Qt6Core.dll and libQt6Core.a. Some of this renaming was done for MinGW plugins and shared libraries, but not for modules in 9b0e23ef8a915a8c58808fa356f771ecdb6f020c. Extract the duplicate code and apply it to all shared libraries built by Qt on Windows. Adjust the prefix and suffix accordingly, depending on whether we use MinGW or not. Amends 9b0e23ef8a915a8c58808fa356f771ecdb6f020c Task-number: QTBUG-84886 Change-Id: I5a8618597df5f57ce256739adced3f24eb13dac7 Reviewed-by: Cristian Adam <cristian.adam@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtBuild.cmake27
1 files changed, 19 insertions, 8 deletions
diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake
index e4d501f1f6..3ab3e80e0d 100644
--- a/cmake/QtBuild.cmake
+++ b/cmake/QtBuild.cmake
@@ -2395,6 +2395,8 @@ function(qt_add_module target)
)
endif()
+ qt_internal_apply_win_prefix_and_suffix("${target}")
+
if (WIN32 AND BUILD_SHARED_LIBS)
qt6_generate_win32_rc_file(${target})
endif()
@@ -3230,10 +3232,7 @@ function(qt_internal_add_plugin target)
# but Qt plugins are actually suffixed with .dylib.
set_property(TARGET "${target}" PROPERTY SUFFIX ".dylib")
endif()
- if(WIN32)
- # CMake sets for Windows-GNU platforms the suffix "lib"
- set_property(TARGET "${target}" PROPERTY PREFIX "")
- endif()
+ qt_internal_apply_win_prefix_and_suffix("${target}")
endif()
qt_set_common_target_properties(${target})
@@ -3999,6 +3998,7 @@ function(qt_add_cmake_library target)
add_library("${target}" STATIC)
elseif(${arg_SHARED})
add_library("${target}" SHARED)
+ qt_internal_apply_win_prefix_and_suffix("${target}")
elseif(${arg_MODULE})
add_library("${target}" MODULE)
set_property(TARGET ${name} PROPERTY C_VISIBILITY_PRESET default)
@@ -4009,10 +4009,7 @@ function(qt_add_cmake_library target)
# but Qt plugins are actually suffixed with .dylib.
set_property(TARGET "${target}" PROPERTY SUFFIX ".dylib")
endif()
- if(WIN32)
- # CMake sets for Windows-GNU platforms the suffix "lib"
- set_property(TARGET "${target}" PROPERTY PREFIX "")
- endif()
+ qt_internal_apply_win_prefix_and_suffix("${target}")
else()
add_library("${target}")
endif()
@@ -5438,6 +5435,20 @@ function(qt_internal_set_up_sanitizer_features)
endif()
endfunction()
+function(qt_internal_apply_win_prefix_and_suffix target)
+ if(WIN32)
+ # CMake sets for Windows-GNU platforms the prefix "lib", whereas qmake expects
+ # no prefix.
+ set_property(TARGET "${target}" PROPERTY PREFIX "")
+
+ # CMake sets for Windows-GNU platforms the import suffix "dll.a", whereas qmake
+ # expects an ".a" import suffix.
+ if(MINGW)
+ set_property(TARGET "${target}" PROPERTY IMPORT_SUFFIX ".a")
+ endif()
+ endif()
+endfunction()
+
# Compatibility macros that should be removed once all their usages are removed.
function(extend_target)
qt_extend_target(${ARGV})