Skip to content

Commit

Permalink
[qt5] MinGW build fixes (#29505)
Browse files Browse the repository at this point in the history
* [qt5] MinGW build fixes

* [qt5] Remove e-mail headers from mingw9.patch

* [qt5] Run vcpkg x-add-version

* Cleanup qt5-base icu libs setup

Windows-shared needs different options. Patch obsolete.

* Check early for mingw32-make

* Revise make install path fixup

---------

Co-authored-by: Kai Pastor <dg0yt@darc.de>
  • Loading branch information
koprok and dg0yt authored Feb 22, 2023
1 parent 90e3d2b commit 82e0390
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 54 deletions.
4 changes: 3 additions & 1 deletion ports/qt5-base/cmake/find_qt_mkspec.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ function(find_qt_mkspec TARGET_PLATFORM_MKSPEC_OUT HOST_PLATFORM_MKSPEC_OUT EXT_
if(NOT DEFINED VCPKG_QT_TARGET_MKSPEC)
message(STATUS "Figuring out qt target mkspec. Target arch ${VCPKG_TARGET_ARCHITECTURE}")
if(VCPKG_TARGET_IS_WINDOWS)
if(VCPKG_TARGET_IS_UWP)
if(VCPKG_TARGET_IS_MINGW)
set(_tmp_targ_out "win32-g++")
elseif(VCPKG_TARGET_IS_UWP)
if(VCPKG_PLATFORM_TOOLSET STREQUAL "v140")
set(msvc_year "2015")
elseif(VCPKG_PLATFORM_TOOLSET STREQUAL "v141")
Expand Down
6 changes: 5 additions & 1 deletion ports/qt5-base/cmake/install_qt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ include(qt_fix_makefile_install)

function(install_qt)
if(CMAKE_HOST_WIN32)
if (VCPKG_QMAKE_USE_NMAKE)
if(VCPKG_TARGET_IS_MINGW)
find_program(MINGW32_MAKE mingw32-make REQUIRED)
set(INVOKE "${MINGW32_MAKE}" -j${VCPKG_CONCURRENCY})
set(INVOKE_SINGLE "${MINGW32_MAKE}" -j1)
elseif (VCPKG_QMAKE_USE_NMAKE)
find_program(NMAKE nmake REQUIRED)
set(INVOKE "${NMAKE}")
set(INVOKE_SINGLE "${NMAKE}")
Expand Down
41 changes: 22 additions & 19 deletions ports/qt5-base/cmake/qt_fix_makefile_install.cmake
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
#Could probably be a vcpkg_fix_makefile_install for other ports?
function(qt_fix_makefile_install BUILD_DIR)
#Fix the installation location
file(TO_NATIVE_PATH "${CURRENT_INSTALLED_DIR}" NATIVE_INSTALLED_DIR)
file(TO_NATIVE_PATH "${CURRENT_PACKAGES_DIR}" NATIVE_PACKAGES_DIR)

if(WIN32)
string(SUBSTRING "${NATIVE_INSTALLED_DIR}" 2 -1 INSTALLED_DIR_WITHOUT_DRIVE)
string(SUBSTRING "${NATIVE_PACKAGES_DIR}" 2 -1 PACKAGES_DIR_WITHOUT_DRIVE)
set(MSYS_HACK "")
if(VCPKG_HOST_IS_WINDOWS)
file(TO_NATIVE_PATH "${CURRENT_INSTALLED_DIR}" NATIVE_INSTALLED_DIR)
file(TO_NATIVE_PATH "${CURRENT_PACKAGES_DIR}" NATIVE_PACKAGES_DIR)
if(VCPKG_TARGET_IS_MINGW)
set(MSYS_HACK ":@msyshack@%=%")
file(STRINGS "${BUILD_DIR}/Makefile" using_sh REGEX "= rm -f")
if(using_sh)
set(NATIVE_INSTALLED_DIR "${CURRENT_INSTALLED_DIR}")
set(NATIVE_PACKAGES_DIR "${CURRENT_PACKAGES_DIR}")
endif()
endif()
string(SUBSTRING "${NATIVE_INSTALLED_DIR}" 0 2 INSTALLED_DRIVE)
string(SUBSTRING "${NATIVE_PACKAGES_DIR}" 0 2 PACKAGES_DRIVE)
string(SUBSTRING "${NATIVE_INSTALLED_DIR}" 2 -1 INSTALLED_DIR_WITHOUT_DRIVE)
string(SUBSTRING "${NATIVE_PACKAGES_DIR}" 2 -1 PACKAGES_DIR_WITHOUT_DRIVE)
else()
set(INSTALLED_DRIVE)
set(PACKAGES_DRIVE)
set(INSTALLED_DIR_WITHOUT_DRIVE ${NATIVE_INSTALLED_DIR})
set(PACKAGES_DIR_WITHOUT_DRIVE ${NATIVE_PACKAGES_DIR})
set(INSTALLED_DRIVE "")
set(PACKAGES_DRIVE "")
set(INSTALLED_DIR_WITHOUT_DRIVE "${CURRENT_INSTALLED_DIR}")
set(PACKAGES_DIR_WITHOUT_DRIVE "${CURRENT_PACKAGES_DIR}")
endif()
set(installed "${INSTALLED_DRIVE}$(INSTALL_ROOT${MSYS_HACK})${INSTALLED_DIR_WITHOUT_DRIVE}")
set(packages "${PACKAGES_DRIVE}$(INSTALL_ROOT${MSYS_HACK})${PACKAGES_DIR_WITHOUT_DRIVE}")

file(TO_NATIVE_PATH "${CURRENT_INSTALLED_DIR}" NATIVE_INSTALLED_DIR)
file(TO_NATIVE_PATH "${CURRENT_PACKAGES_DIR}" NATIVE_PACKAGES_DIR)

file(GLOB_RECURSE MAKEFILES "${BUILD_DIR}/*Makefile*")

foreach(MAKEFILE ${MAKEFILES})
file(READ "${MAKEFILE}" _contents)
#Set the correct install directory to packages
string(REPLACE "${INSTALLED_DRIVE}$(INSTALL_ROOT)${INSTALLED_DIR_WITHOUT_DRIVE}" "${PACKAGES_DRIVE}$(INSTALL_ROOT)${PACKAGES_DIR_WITHOUT_DRIVE}" _contents "${_contents}")
file(WRITE "${MAKEFILE}" "${_contents}")
vcpkg_replace_string("${MAKEFILE}" "${installed}" "${packages}")
endforeach()
endfunction()
endfunction()
24 changes: 0 additions & 24 deletions ports/qt5-base/patches/icu.patch

This file was deleted.

21 changes: 21 additions & 0 deletions ports/qt5-base/patches/mingw9.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp
index 075ce0ffac..0d3dd2e0b2 100644
--- a/src/corelib/io/qfilesystemengine_win.cpp
+++ b/src/corelib/io/qfilesystemengine_win.cpp
@@ -627,14 +627,14 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
return QFileSystemEntry(ret, QFileSystemEntry::FromInternalPath());
}

-#if defined(Q_CC_MINGW) && WINVER < 0x0602 // Windows 8 onwards
+#if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8 // Windows 8 onwards

typedef struct _FILE_ID_INFO {
ULONGLONG VolumeSerialNumber;
FILE_ID_128 FileId;
} FILE_ID_INFO, *PFILE_ID_INFO;

-#endif // if defined (Q_CC_MINGW) && WINVER < 0x0602
+#endif // if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8

// File ID for Windows up to version 7 and FAT32 drives
static inline QByteArray fileId(HANDLE handle)
23 changes: 17 additions & 6 deletions ports/qt5-base/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ qt5-base for qt5-x11extras requires several libraries from the system package ma
for a complete list of them.
]]
)
elseif(VCPKG_TARGET_IS_MINGW AND CMAKE_HOST_WIN32)
find_program(MINGW32_MAKE mingw32-make PATHS ENV PATH NO_DEFAULT_PATH REQUIRED)
endif()

list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})
Expand Down Expand Up @@ -50,7 +52,6 @@ qt_download_submodule( OUT_SOURCE_PATH SOURCE_PATH
patches/windows_prf.patch #fixes the qtmain dependency due to the above move
patches/qt_app.patch #Moves the target location of qt5 host apps to always install into the host dir.
patches/gui_configure.patch #Patches the gui configure.json to break freetype/fontconfig autodetection because it does not include its dependencies.
patches/icu.patch #Help configure find static icu builds in vcpkg on windows
patches/xlib.patch #Patches Xlib check to actually use Pkgconfig instead of makeSpec only
patches/egl.patch #Fix egl detection logic.
patches/mysql_plugin_include.patch #Fix include path of mysql plugin
Expand All @@ -65,6 +66,7 @@ qt_download_submodule( OUT_SOURCE_PATH SOURCE_PATH
patches/create_cmake.patch
patches/Qt5GuiConfigExtras.patch # Patches the library search behavior for EGL since angle is not build with Qt
patches/fix_angle.patch # Failed to create OpenGL context for format QSurfaceFormat ...
patches/mingw9.patch # Fix compile with MinGW-W64 9.0.0: Redefinition of 'struct _FILE_ID_INFO'
)

# Remove vendored dependencies to ensure they are not picked up by the build
Expand Down Expand Up @@ -173,8 +175,8 @@ find_library(ICUDATA_DEBUG NAMES icudatad libicudatad icudata libicudata icudtd
set(ICU_RELEASE "${ICUIN_RELEASE} ${ICULX_RELEASE} ${ICUUC_RELEASE} ${ICUIO_RELEASE} ${ICUDATA_RELEASE}")
set(ICU_DEBUG "${ICUIN_DEBUG} ${ICULX_DEBUG} ${ICUUC_DEBUG} ${ICUIO_DEBUG} ${ICUDATA_DEBUG}")
if(VCPKG_TARGET_IS_WINDOWS)
set(ICU_RELEASE "${ICU_RELEASE} Advapi32.lib")
set(ICU_DEBUG "${ICU_DEBUG} Advapi32.lib" )
set(ICU_RELEASE "${ICU_RELEASE} -ladvapi32")
set(ICU_DEBUG "${ICU_DEBUG} -ladvapi32" )
endif()

find_library(FONTCONFIG_RELEASE NAMES fontconfig PATHS "${CURRENT_INSTALLED_DIR}/lib" NO_DEFAULT_PATH)
Expand Down Expand Up @@ -204,7 +206,6 @@ set(RELEASE_OPTIONS
"LIBPNG_LIBS=${LIBPNG_RELEASE} ${ZLIB_RELEASE}"
"PCRE2_LIBS=${PCRE2_RELEASE}"
"FREETYPE_LIBS=${FREETYPE_RELEASE_ALL}"
"ICU_LIBS=${ICU_RELEASE}"
"QMAKE_LIBS_PRIVATE+=${BZ2_RELEASE}"
"QMAKE_LIBS_PRIVATE+=${LIBPNG_RELEASE}"
"QMAKE_LIBS_PRIVATE+=${ICU_RELEASE}"
Expand All @@ -216,13 +217,23 @@ set(DEBUG_OPTIONS
"LIBPNG_LIBS=${LIBPNG_DEBUG} ${ZLIB_DEBUG}"
"PCRE2_LIBS=${PCRE2_DEBUG}"
"FREETYPE_LIBS=${FREETYPE_DEBUG_ALL}"
"ICU_LIBS=${ICU_DEBUG}"
"QMAKE_LIBS_PRIVATE+=${BZ2_DEBUG}"
"QMAKE_LIBS_PRIVATE+=${LIBPNG_DEBUG}"
"QMAKE_LIBS_PRIVATE+=${ICU_DEBUG}"
"QMAKE_LIBS_PRIVATE+=${ZSTD_DEBUG}"
)

# This if/else corresponds to icu setup in src/corelib/configure.json.
if(VCPKG_TARGET_IS_WINDOWS AND VCPKG_LIBRARY_LINKAGE STREQUAL "static")
list(APPEND CORE_OPTIONS
"ICU_LIBS_RELEASE=${ICU_RELEASE}"
"ICU_LIBS_DEBUG=${ICU_DEBUG}"
)
else()
list(APPEND RELEASE_OPTIONS "ICU_LIBS=${ICU_RELEASE}")
list(APPEND DEBUG_OPTIONS "ICU_LIBS=${ICU_DEBUG}")
endif()

if(VCPKG_TARGET_IS_WINDOWS)
if(VCPKG_TARGET_IS_UWP)
list(APPEND CORE_OPTIONS -appstore-compliant)
Expand All @@ -232,7 +243,7 @@ if(VCPKG_TARGET_IS_WINDOWS)
else()
list(APPEND CORE_OPTIONS -opengl dynamic) # other possible option without moving angle dlls: "-opengl desktop". "-opengel es2" only works with commented patch
endif()
set(ADDITIONAL_WINDOWS_LIBS "ws2_32.lib secur32.lib advapi32.lib shell32.lib crypt32.lib user32.lib gdi32.lib")
set(ADDITIONAL_WINDOWS_LIBS "-lws2_32 -lsecur32 -ladvapi32 -lshell32 -lcrypt32 -luser32 -lgdi32")
list(APPEND RELEASE_OPTIONS
"SQLITE_LIBS=${SQLITE_RELEASE}"
"HARFBUZZ_LIBS=${harfbuzz_LIBRARIES_RELEASE}"
Expand Down
2 changes: 1 addition & 1 deletion ports/qt5-base/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "qt5-base",
"version": "5.15.8",
"port-version": 3,
"port-version": 4,
"description": "Qt5 Application Framework Base Module. Includes Core, GUI, Widgets, Networking, SQL, Concurrent and other essential qt components.",
"homepage": "https://www.qt.io/",
"license": null,
Expand Down
5 changes: 4 additions & 1 deletion scripts/cmake/vcpkg_build_qmake.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ function(vcpkg_build_qmake)
set(ENV{_CL_} "/utf-8")

if(CMAKE_HOST_WIN32)
if (VCPKG_QMAKE_USE_NMAKE)
if(VCPKG_TARGET_IS_MINGW)
find_program(MINGW32_MAKE mingw32-make REQUIRED)
set(invoke_command "${MINGW32_MAKE}")
elseif (VCPKG_QMAKE_USE_NMAKE)
find_program(NMAKE nmake)
set(invoke_command "${NMAKE}")
get_filename_component(nmake_exe_path "${NMAKE}" DIRECTORY)
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -6314,7 +6314,7 @@
},
"qt5-base": {
"baseline": "5.15.8",
"port-version": 3
"port-version": 4
},
"qt5-canvas3d": {
"baseline": "0",
Expand Down
5 changes: 5 additions & 0 deletions versions/q-/qt5-base.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "1528baab40fce203129dc361128135b453e1ecb1",
"version": "5.15.8",
"port-version": 4
},
{
"git-tree": "6784bfaa6ca1ddf15b673165041defe84f289a9c",
"version": "5.15.8",
Expand Down

0 comments on commit 82e0390

Please sign in to comment.