Clean up cross-compilation

This commit is contained in:
Přemysl Eric Janouch 2022-08-10 16:04:10 +02:00
parent 57739ff81e
commit 2e684d2f4e
Signed by: p
GPG Key ID: A0420B94F92B9493
2 changed files with 23 additions and 19 deletions

View File

@ -17,18 +17,23 @@ if (WIN32)
message (FATAL_ERROR "Win32 must be cross-compiled to build sensibly") message (FATAL_ERROR "Win32 must be cross-compiled to build sensibly")
endif () endif ()
set (WIN32_DEPENDS_PATH ${PROJECT_SOURCE_DIR}/win32-depends) set (win32_deps_root "${PROJECT_SOURCE_DIR}")
list (APPEND CMAKE_PREFIX_PATH ${WIN32_DEPENDS_PATH}) set (win32_deps_prefix "${win32_deps_root}/mingw64")
list (APPEND CMAKE_INCLUDE_PATH ${WIN32_DEPENDS_PATH}/lib) list (APPEND CMAKE_PREFIX_PATH "${win32_deps_prefix}")
list (APPEND CMAKE_INCLUDE_PATH "${win32_deps_prefix}/lib")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mms-bitfields") set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mms-bitfields")
if (CMAKE_CROSSCOMPILING) if (CMAKE_CROSSCOMPILING)
list (APPEND CMAKE_FIND_ROOT_PATH ${WIN32_DEPENDS_PATH}) list (APPEND CMAKE_FIND_ROOT_PATH ${win32_deps_prefix})
endif (CMAKE_CROSSCOMPILING) endif ()
set (ENV{PKG_CONFIG_LIBDIR} # Relativize prefixes, and bar pkg-config from looking up host libraries
"${WIN32_DEPENDS_PATH}/share/pkgconfig:${WIN32_DEPENDS_PATH}/lib/pkgconfig") set (ENV{PKG_CONFIG_SYSROOT_DIR} "${win32_deps_root}")
endif (WIN32) set (win32_deps_pcpath
"${win32_deps_prefix}/share/pkgconfig:${win32_deps_prefix}/lib/pkgconfig")
set (ENV{PKG_CONFIG_PATH} "${win32_deps_pcpath}")
set (ENV{PKG_CONFIG_LIBDIR} "${win32_deps_pcpath}")
endif ()
# Dependencies # Dependencies
find_package (ZLIB REQUIRED) find_package (ZLIB REQUIRED)
@ -306,25 +311,25 @@ elseif (WITH_GUI)
# This rather crude filter has been mostly copied over from logdiag # This rather crude filter has been mostly copied over from logdiag
install (TARGETS sdgui DESTINATION .) install (TARGETS sdgui DESTINATION .)
install (DIRECTORY install (DIRECTORY
${WIN32_DEPENDS_PATH}/bin/ ${win32_deps_prefix}/bin/
DESTINATION . DESTINATION .
FILES_MATCHING PATTERN "*.dll") FILES_MATCHING PATTERN "*.dll")
install (DIRECTORY install (DIRECTORY
${WIN32_DEPENDS_PATH}/etc/ ${win32_deps_prefix}/etc/
DESTINATION etc) DESTINATION etc)
install (DIRECTORY install (DIRECTORY
${WIN32_DEPENDS_PATH}/lib/gdk-pixbuf-2.0 ${win32_deps_prefix}/lib/gdk-pixbuf-2.0
DESTINATION lib DESTINATION lib
FILES_MATCHING PATTERN "*" PATTERN "*.a" EXCLUDE) FILES_MATCHING PATTERN "*" PATTERN "*.a" EXCLUDE)
install (DIRECTORY install (DIRECTORY
${WIN32_DEPENDS_PATH}/share/glib-2.0/schemas ${win32_deps_prefix}/share/glib-2.0/schemas
DESTINATION share/glib-2.0) DESTINATION share/glib-2.0)
install (DIRECTORY install (DIRECTORY
${WIN32_DEPENDS_PATH}/share/icons/Adwaita ${win32_deps_prefix}/share/icons/Adwaita
DESTINATION share/icons OPTIONAL) DESTINATION share/icons OPTIONAL)
install (FILES install (FILES
${WIN32_DEPENDS_PATH}/share/icons/hicolor/index.theme ${win32_deps_prefix}/share/icons/hicolor/index.theme
DESTINATION share/icons/hicolor) DESTINATION share/icons/hicolor)
install (DIRECTORY ${icon_base} DESTINATION share) install (DIRECTORY ${icon_base} DESTINATION share)

View File

@ -54,13 +54,12 @@ configure() {
glib-compile-schemas share/glib-2.0/schemas glib-compile-schemas share/glib-2.0/schemas
wine64 bin/gdk-pixbuf-query-loaders.exe \ wine64 bin/gdk-pixbuf-query-loaders.exe \
> lib/gdk-pixbuf-2.0/2.10.0/loaders.cache > lib/gdk-pixbuf-2.0/2.10.0/loaders.cache
# pkgconf has a command line option for this, but CMake can't pass it
sed -i "s|^prefix=/mingw64|prefix=$(pwd)|" {share,lib}/pkgconfig/*.pc
} }
mkdir -p win32-depends # This directory name matches the prefix in .pc files, so we don't need to
cd win32-depends # modify them (pkgconf has --prefix-variable, but CMake can't pass that option)
mkdir -p mingw64
cd mingw64
dbsync dbsync
fetch mingw-w64-x86_64-gtk3 mingw-w64-x86_64-icu \ fetch mingw-w64-x86_64-gtk3 mingw-w64-x86_64-icu \
mingw-w64-x86_64-libwinpthread-git # because we don't do "provides"? mingw-w64-x86_64-libwinpthread-git # because we don't do "provides"?