From e67829e6556300f1ec281d635a12fae188ca55d0 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Wed, 17 Jun 2020 12:31:40 +0200 Subject: [PATCH] CMake: Fix MinGW prefixes / suffixes again Document what qmake expects and what CMake creates by default. This change should fix qmake mixing for MinGW, where the WinMain library was called qtmain.a instead of libqtmain.a. Amends f626c73b28b52ecf3a3fb20592f2134337f89d35 and 9b0e23ef8a915a8c58808fa356f771ecdb6f020c Task-number: QTBUG-84781 Change-Id: I059db13f8d8a0aab8bd3fc69d4537a2b63687394 Reviewed-by: Cristian Adam Reviewed-by: Joerg Bornemann --- cmake/QtBuild.cmake | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index 46442b9e96..c9c667f35c 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -5520,14 +5520,37 @@ 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 "") + # Table of prefix / suffixes for MSVC libraries as qmake expects them to be created. + # static - Qt6EdidSupport.lib (platform support libraries / or static QtCore, etc) + # shared - Qt6Core.dll + # shared import library - Qt6Core.lib + # module aka Qt plugin - qwindows.dll + # module import library - qwindows.lib + # + # The CMake defaults are fine for us. - # CMake sets for Windows-GNU platforms the import suffix "dll.a", whereas qmake - # expects an ".a" import suffix. - if(MINGW) + # Table of prefix / suffixes for MinGW libraries as qmake expects them to be created. + # static - libQt6EdidSupport.a (platform support libraries / or static QtCore, etc) + # shared - Qt6Core.dll + # shared import library - libQt6Core.a + # module aka Qt plugin - qwindows.dll + # module import library - libqwindows.a + # + # CMake for Windows-GNU platforms defaults the prefix to "lib". + # CMake for Windows-GNU platforms defaults the import suffix to ".dll.a". + # These CMake defaults are not ok for us. + + # This should cover both MINGW with GCC and CLANG. + if(NOT MSVC) set_property(TARGET "${target}" PROPERTY IMPORT_SUFFIX ".a") + + get_target_property(target_type ${target} TYPE) + if(target_type STREQUAL "STATIC_LIBRARY") + set_property(TARGET "${target}" PROPERTY PREFIX "lib") + else() + set_property(TARGET "${target}" PROPERTY PREFIX "") + set_property(TARGET "${target}" PROPERTY IMPORT_PREFIX "lib") + endif() endif() endif() endfunction()