This file is part of MXE. See LICENSE.md for licensing information.

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Ray Donnelly <mingw.android@gmail.com>
Date: Wed, 26 Aug 2015 12:45:43 +0100
Subject: [PATCH 1/6] cmake: Rearrange STATIC vs INTERFACE targets

Otherwise we attempt to add_library(Qt5::UiPlugin STATIC IMPORTED)
for header-only modules when building Qt5 statically.

Source: https://git.io/vzWJz
See also: https://github.com/mxe/mxe/issues/1185

diff --git a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
index 1111111..2222222 100644
--- a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
+++ b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
@@ -370,6 +370,9 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
     list(APPEND _Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES \"$${CMAKE_INTERFACE_QT5_MODULE_DEPS}\")
 !!ENDIF
 
+!!IF equals(TEMPLATE, aux)
+    add_library(Qt5::$${CMAKE_MODULE_NAME} INTERFACE IMPORTED)
+!!ELSE
 !!IF !isEmpty(CMAKE_STATIC_TYPE)
     if(NOT Qt5_EXCLUDE_STATIC_DEPENDENCIES)
 !!IF !isEmpty(CMAKE_DEBUG_TYPE)
@@ -411,9 +414,6 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
     add_library(Qt5::$${CMAKE_MODULE_NAME} STATIC IMPORTED)
     set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY IMPORTED_LINK_INTERFACE_LANGUAGES "CXX")
 !!ENDIF
-!!ELSE
-!!IF equals(TEMPLATE, aux)
-    add_library(Qt5::$${CMAKE_MODULE_NAME} INTERFACE IMPORTED)
 !!ELSE
     add_library(Qt5::$${CMAKE_MODULE_NAME} SHARED IMPORTED)
 !!ENDIF

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Mark Brand <mabrand@mabrand.nl>
Date: Sun, 11 Jun 2017 00:27:41 +0200
Subject: [PATCH 2/6] use pkg-config for harfbuzz

Change-Id: Ia65cbb90fd180f1bc10ce077a9a8323a48e51421

diff --git a/src/gui/configure.json b/src/gui/configure.json
index 1111111..2222222 100644
--- a/src/gui/configure.json
+++ b/src/gui/configure.json
@@ -303,7 +303,8 @@
             },
             "headers": "harfbuzz/hb.h",
             "sources": [
-                "-lharfbuzz"
+               { "type": "pkgConfig", "args": "harfbuzz" },
+               "-lharfbuzz"
             ]
         },
         "imf": {

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Mark Brand <mabrand@mabrand.nl>
Date: Wed, 16 Nov 2022 15:22:10 +0100
Subject: [PATCH 3/6] fix linking for schannel ssl support

Lower case library file names.

diff --git a/src/network/ssl/ssl.pri b/src/network/ssl/ssl.pri
index 1111111..2222222 100644
--- a/src/network/ssl/ssl.pri
+++ b/src/network/ssl/ssl.pri
@@ -62,7 +62,7 @@ qtConfig(ssl) {
                    ssl/qsslellipticcurve_dummy.cpp \
                    ssl/qsslsocket_qt.cpp
 
-        LIBS_PRIVATE += "-lSecur32" "-lCrypt32" "-lbcrypt" "-lncrypt"
+        LIBS_PRIVATE += "-lsecur32" "-lcrypt32" "-lbcrypt" "-lncrypt"
     }
 
     qtConfig(securetransport) {

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Mark Brand <mabrand@mabrand.nl>
Date: Fri, 22 Dec 2023 01:32:13 +0100
Subject: [PATCH 4/6] buildfix: avoid deprecated operator

Change-Id: I1d4ae659ee7ebcbe9557b265c7035d7b48e4a667

diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp
index 1111111..2222222 100644
--- a/src/plugins/platforms/windows/qwindowscontext.cpp
+++ b/src/plugins/platforms/windows/qwindowscontext.cpp
@@ -1005,7 +1005,7 @@ QByteArray QWindowsContext::comErrorString(HRESULT hr)
     }
     _com_error error(hr);
     result += QByteArrayLiteral(" (");
-    result += errorMessageFromComError(error);
+    result += errorMessageFromComError(error).toUtf8();
     result += ')';
     return result;
 }

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Mark Brand <mabrand@mabrand.nl>
Date: Fri, 11 Apr 2025 12:04:56 +0200
Subject: [PATCH 5/6] mingw: use pkg-config to detect libmariadb


diff --git a/src/plugins/sqldrivers/configure.json b/src/plugins/sqldrivers/configure.json
index 1111111..2222222 100644
--- a/src/plugins/sqldrivers/configure.json
+++ b/src/plugins/sqldrivers/configure.json
@@ -67,15 +67,7 @@
             },
             "headers": "mysql.h",
             "sources": [
-                { "type": "mysqlConfig", "query": "--libs_r", "cleanlibs": true },
-                { "type": "mysqlConfig", "query": "--libs", "cleanlibs": true },
-                { "type": "mysqlConfig", "query": "--libs_r", "cleanlibs": false },
-                { "type": "mysqlConfig", "query": "--libs", "cleanlibs": false },
-                { "libs": "-lmysqlclient_r", "condition": "!config.win32" },
-                { "libs": "-llibmariadb", "condition": "config.win32" },
-                { "libs": "-llibmysql", "condition": "config.win32" },
-                { "libs": "-lmariadb", "condition": "!config.win32" },
-                { "libs": "-lmysqlclient", "condition": "!config.win32" }
+                { "type": "pkgConfig", "args": "libmariadb" }
             ]
         },
         "psql": {

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Mark Brand <mabrand@mabrand.nl>
Date: Thu, 31 Oct 2024 14:08:37 +0100
Subject: [PATCH 6/6] workaround for failure to find libatomic

https://github.com/mxe/mxe/issues/3099

diff --git a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
index 1111111..2222222 100644
--- a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
+++ b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
@@ -116,6 +116,9 @@ function(_qt5_$${CMAKE_MODULE_NAME}_process_prl_file prl_file_location Configura
                         list(APPEND _lib_deps
                             ${_Qt5$${CMAKE_MODULE_NAME}_${Configuration}_${_lib}_PATH}
                         )
+                    elseif(_flag MATCHES \"^-latomic$\")
+                        # libatomic.a might be somewhere else like usr/lib/gcc/x86_64-w64-mingw32.static/14.2.0/libatomic.a
+                        list(APPEND _lib_deps ${_flag})
                     else()
                         message(FATAL_ERROR \"Library not found: ${_lib}\")
                     endif()
