aboutsummarylogtreecommitdiffstats
path: root/0019-Use-.dll.a-as-import-lib-extension.patch
blob: 9dfab61ca7449d532a6f4d94d0a6c5bc0b08cbf2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
From c60beaf9aafc2ea2d9ed4e61b612cd0d1ca15a1d Mon Sep 17 00:00:00 2001
From: Martchus <martchus@gmx.net>
Date: Sun, 18 Sep 2016 18:26:18 +0200
Subject: [PATCH 19/32] Use *.dll.a as import lib extension

The variables used here are provided by
g++-win32.conf

Change-Id: Ic8915ea40b4db3d9f60533d21daf8ff1ec1bd803
---
 mkspecs/features/create_cmake.prf      |  5 ++--
 mkspecs/features/qt.prf                | 38 ++++++++++----------------
 qmake/generators/win32/winmakefile.cpp | 15 +++++++---
 3 files changed, 28 insertions(+), 30 deletions(-)

diff --git a/mkspecs/features/create_cmake.prf b/mkspecs/features/create_cmake.prf
index 6cd94f8058a..ac089a2f9f0 100644
--- a/mkspecs/features/create_cmake.prf
+++ b/mkspecs/features/create_cmake.prf
@@ -339,8 +339,9 @@ mac {
         CMAKE_WINMAIN_FILE_LOCATION_DEBUG = libqt5main$${QT_LIBINFIX}$${debug_suffix}.a
         CMAKE_WINMAIN_FILE_LOCATION_RELEASE = libqt5main$${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 = qt5main$${QT_LIBINFIX}$${debug_suffix}.lib
         CMAKE_WINMAIN_FILE_LOCATION_RELEASE = qt5main$${QT_LIBINFIX}.lib
diff --git a/mkspecs/features/qt.prf b/mkspecs/features/qt.prf
index 8096d01c341..b79b324b887 100644
--- a/mkspecs/features/qt.prf
+++ b/mkspecs/features/qt.prf
@@ -215,32 +215,22 @@ for(ever) {
                 # Linking frameworks by absolute path does not work.
                 LIBS$$var_sfx += -framework $$framework
             } else {
-                candidates = $$MODULE_MODULE$$qtPlatformTargetSuffix()
-                darwin: candidates *= $$MODULE_MODULE
-                win32|contains(MODULE_CONFIG, staticlib) {
-                    lib_prefix = $$MODULE_LIBS/$$QMAKE_PREFIX_STATICLIB
-                    lib_suffix = $$QMAKE_EXTENSION_STATICLIB
-                    add_lib_to_pretargetdeps = true
+                lib = $$MODULE_MODULE$$qtPlatformTargetSuffix()
+                contains(MODULE_CONFIG, staticlib) {
+                    lib = $$MODULE_LIBS/$$QMAKE_PREFIX_STATICLIB$${lib}.$$QMAKE_EXTENSION_STATICLIB
+                    PRE_TARGETDEPS += $$lib
                 } else {
-                    lib_prefix = $$MODULE_LIBS/$$QMAKE_PREFIX_SHLIB
-                    lib_suffix = $$QMAKE_EXTENSION_SHLIB
-                    add_lib_to_pretargetdeps = false
-                }
-                lib_missing = true
-                lib_fallback =
-                for(lib_base, candidates) {
-                    lib = $${lib_prefix}$${lib_base}.$${lib_suffix}
-                    isEmpty(lib_fallback): \
-                        lib_fallback = $$lib
-                    exists($$lib) {
-                        lib_missing = false
-                        break()
+                    win32 {
+                        shared|actually_a_shared_build {
+                            lib = $$MODULE_LIBS/$$QMAKE_PREFIX_STATICLIB$${lib}.$$QMAKE_EXTENSION_IMPORTLIB
+                        } else {
+                            lib = $$MODULE_LIBS/$$QMAKE_PREFIX_STATICLIB$${lib}.$$QMAKE_EXTENSION_STATICLIB
+                        }
+                        PRE_TARGETDEPS += $$lib
+                    } else {
+                        lib = $$MODULE_LIBS/$$QMAKE_PREFIX_SHLIB$${lib}.$$QMAKE_EXTENSION_SHLIB
                     }
-                }
-                $$lib_missing: \
-                    lib = $$lib_fallback
-                $$add_lib_to_pretargetdeps: \
-                    PRE_TARGETDEPS += $$lib
+		}
                 LIBS$$var_sfx += $$lib
             }
         }
diff --git a/qmake/generators/win32/winmakefile.cpp b/qmake/generators/win32/winmakefile.cpp
index 183cef29089..03732df4a84 100644
--- a/qmake/generators/win32/winmakefile.cpp
+++ b/qmake/generators/win32/winmakefile.cpp
@@ -99,9 +99,13 @@ private:
 bool
 Win32MakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags)
 {
-    ProStringList impexts = project->values("QMAKE_LIB_EXTENSIONS");
-    if (impexts.isEmpty())
-        impexts = project->values("QMAKE_EXTENSION_STATICLIB");
+    ProStringList impexts;
+    if (project->isActiveConfig("staticlib")) {
+      impexts.append(project->values("QMAKE_EXTENSION_STATICLIB"));
+    } else {
+      impexts.append(project->values("QMAKE_EXTENSION_IMPORTLIB"));
+      impexts.append(project->values("QMAKE_EXTENSION_STATICLIB"));
+    }
     QVector<LibrarySearchPath> dirs;
     int libidx = 0;
     for (const ProString &dlib : project->values("QMAKE_DEFAULT_LIBDIRS"))
@@ -283,9 +287,12 @@ void Win32MakefileGenerator::fixTargetExt()
     if (!project->values("QMAKE_APP_FLAG").isEmpty()) {
         project->values("TARGET_EXT").append(".exe");
     } else if (project->isActiveConfig("shared")) {
+        ProString impext = project->first("QMAKE_EXTENSION_IMPORTLIB");
+        if (impext.isEmpty())
+          impext = project->first("QMAKE_PREFIX_STATICLIB");
         project->values("LIB_TARGET").prepend(project->first("QMAKE_PREFIX_STATICLIB")
                                               + project->first("TARGET") + project->first("TARGET_VERSION_EXT")
-                                              + '.' + project->first("QMAKE_EXTENSION_STATICLIB"));
+                                              + '.' + impext);
         project->values("TARGET_EXT").append(project->first("TARGET_VERSION_EXT") + "."
                 + project->first("QMAKE_EXTENSION_SHLIB"));
         project->values("TARGET").first() = project->first("QMAKE_PREFIX_SHLIB") + project->first("TARGET");
-- 
2.46.0