From 5ab173c6ee597e09eecf53411ec3726c19a40ce5 Mon Sep 17 00:00:00 2001
From: Martchus <martchus@gmx.net>
Date: Thu, 5 Nov 2020 22:08:10 +0100
Subject: [PATCH 01/17] Use CMake's default import library suffix

Change-Id: I3dbedaec74683e5bfd008f7f2fd1e046dfb921b2
---
 cmake/QtPriHelpers.cmake          | 12 ++++++++++--
 cmake/QtPrlHelpers.cmake          |  8 +++++++-
 mkspecs/common/g++-win32.conf     |  1 +
 mkspecs/features/create_cmake.prf |  5 +++--
 src/corelib/Qt6CoreMacros.cmake   |  1 -
 5 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/cmake/QtPriHelpers.cmake b/cmake/QtPriHelpers.cmake
index f1d45cdcf6c..32ca0589699 100644
--- a/cmake/QtPriHelpers.cmake
+++ b/cmake/QtPriHelpers.cmake
@@ -523,9 +523,13 @@ QT.${config_module_name}_private.disabled_features = ${disabled_private_features
         qt_path_join(private_pri_file_path "${target_path}" "${private_pri_file_name}")
         list(APPEND pri_files "${private_pri_file_path}")
 
-        set(library_prefixes ${CMAKE_SHARED_LIBRARY_PREFIX} ${CMAKE_STATIC_LIBRARY_PREFIX})
+        set(library_prefixes
+            ${CMAKE_SHARED_LIBRARY_PREFIX}
+            ${CMAKE_IMPORT_LIBRARY_PREFIX}
+            ${CMAKE_STATIC_LIBRARY_PREFIX})
         set(library_suffixes
             ${CMAKE_SHARED_LIBRARY_SUFFIX}
+            ${CMAKE_CMAKE_IMPORT_LIBRARY_SUFFIX}
             ${CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES}
             ${CMAKE_STATIC_LIBRARY_SUFFIX})
         if(MSVC)
@@ -976,9 +980,13 @@ CONFIG += ${private_config_joined}
         list(APPEND inputs "${preliminary_pri_root}/${cfg}/${pri_data_cmake_file}")
     endforeach()
 
-    set(library_prefixes ${CMAKE_SHARED_LIBRARY_PREFIX} ${CMAKE_STATIC_LIBRARY_PREFIX})
+    set(library_prefixes
+        ${CMAKE_SHARED_LIBRARY_PREFIX}
+        ${CMAKE_IMPORT_LIBRARY_PREFIX}
+        ${CMAKE_STATIC_LIBRARY_PREFIX})
     set(library_suffixes
         ${CMAKE_SHARED_LIBRARY_SUFFIX}
+        ${CMAKE_CMAKE_IMPORT_LIBRARY_SUFFIX}
         ${CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES}
         ${CMAKE_STATIC_LIBRARY_SUFFIX})
     if(MSVC)
diff --git a/cmake/QtPrlHelpers.cmake b/cmake/QtPrlHelpers.cmake
index 45bfaedcdf6..a433c98fe8c 100644
--- a/cmake/QtPrlHelpers.cmake
+++ b/cmake/QtPrlHelpers.cmake
@@ -123,11 +123,17 @@ ${prl_step1_content_libs}
          CONTENT
          "FINAL_PRL_FILE_PATH = ${final_prl_file_path}")
 
-    set(library_prefixes ${CMAKE_SHARED_LIBRARY_PREFIX} ${CMAKE_STATIC_LIBRARY_PREFIX})
+    set(library_prefixes
+        ${CMAKE_SHARED_LIBRARY_PREFIX}
+        ${CMAKE_IMPORT_LIBRARY_PREFIX}
+        ${CMAKE_STATIC_LIBRARY_PREFIX})
     set(library_suffixes
         ${CMAKE_SHARED_LIBRARY_SUFFIX}
+        ${CMAKE_CMAKE_IMPORT_LIBRARY_SUFFIX}
         ${CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES}
         ${CMAKE_STATIC_LIBRARY_SUFFIX})
+    list(REMOVE_DUPLICATES library_prefixes)
+    list(REMOVE_DUPLICATES library_suffixes)
 
     if(QT_GENERATOR_IS_MULTI_CONFIG)
         set(configs ${CMAKE_CONFIGURATION_TYPES})
diff --git a/mkspecs/common/g++-win32.conf b/mkspecs/common/g++-win32.conf
index 67ad1e3b8c1..b98c7121f6f 100644
--- a/mkspecs/common/g++-win32.conf
+++ b/mkspecs/common/g++-win32.conf
@@ -54,6 +54,7 @@ QMAKE_PREFIX_SHLIB      =
 QMAKE_EXTENSION_SHLIB   = dll
 QMAKE_PREFIX_STATICLIB  = lib
 QMAKE_EXTENSION_STATICLIB = a
+QMAKE_EXTENSION_IMPORTLIB = dll.a
 QMAKE_LIB_EXTENSIONS    = a dll.a
 
 QMAKE_LIBS              =
diff --git a/mkspecs/features/create_cmake.prf b/mkspecs/features/create_cmake.prf
index 24ed125f12b..73ebe453d3d 100644
--- a/mkspecs/features/create_cmake.prf
+++ b/mkspecs/features/create_cmake.prf
@@ -332,8 +332,9 @@ mac {
         CMAKE_WINMAIN_FILE_LOCATION_DEBUG = libqtmain$${QT_LIBINFIX}$${debug_suffix}.a
         CMAKE_WINMAIN_FILE_LOCATION_RELEASE = libqtmain$${QT_LIBINFIX}.a
 
-        CMAKE_IMPLIB_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}$${debug_suffix}.a
-        CMAKE_IMPLIB_FILE_LOCATION_RELEASE = lib$${CMAKE_QT_STEM}.a
+        isEmpty(QMAKE_EXTENSION_IMPORTLIB): QMAKE_EXTENSION_IMPORTLIB = a
+        CMAKE_IMPLIB_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}$${debug_suffix}.$${QMAKE_EXTENSION_IMPORTLIB}
+        CMAKE_IMPLIB_FILE_LOCATION_RELEASE = lib$${CMAKE_QT_STEM}.$${QMAKE_EXTENSION_IMPORTLIB}
     } else {
         CMAKE_WINMAIN_FILE_LOCATION_DEBUG = qtmain$${QT_LIBINFIX}$${debug_suffix}.lib
         CMAKE_WINMAIN_FILE_LOCATION_RELEASE = qtmain$${QT_LIBINFIX}.lib
diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake
index 8a0d07feac7..17d7b8fc123 100644
--- a/src/corelib/Qt6CoreMacros.cmake
+++ b/src/corelib/Qt6CoreMacros.cmake
@@ -550,7 +550,6 @@ function(_qt_internal_apply_win_prefix_and_suffix target)
 
         # 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")
-- 
2.44.0

