summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartchus2020-11-08 17:31:44 +0100
committerMartchus2020-11-08 17:31:44 +0100
commit1ecf97f6f97df55ac8d2371e9dcf1c615783565c (patch)
tree1ca5b946341240de4972fadf515aeaee7133e137
downloadaur-1ecf97f6f97df55ac8d2371e9dcf1c615783565c.tar.gz
Initial import
-rw-r--r--.SRCINFO15
-rw-r--r--PKGBUILD31
-rw-r--r--mingw-cmake-static.sh15
-rw-r--r--toolchain-mingw-static.cmake41
4 files changed, 102 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..1786425447cf
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,15 @@
+pkgbase = mingw-w64-cmake-static
+ pkgdesc = CMake wrapper for MinGW (mingw-w64, static)
+ pkgver = 1
+ pkgrel = 1
+ url = https://github.com/martchus/pkgbuilds
+ arch = any
+ license = GPL
+ depends = mingw-w64-cmake
+ source = mingw-cmake-static.sh
+ source = toolchain-mingw-static.cmake
+ sha256sums = SKIP
+ sha256sums = SKIP
+
+pkgname = mingw-w64-cmake-static
+
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..cb0ed8ef333f
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,31 @@
+pkgname=mingw-w64-cmake-static
+pkgver=1
+pkgrel=1
+arch=('any')
+pkgdesc='CMake wrapper for MinGW (mingw-w64, static)'
+depends=('mingw-w64-cmake')
+license=("GPL")
+url='https://github.com/martchus/pkgbuilds'
+source=(mingw-cmake-static.sh
+ toolchain-mingw-static.cmake)
+sha256sums=('SKIP' 'SKIP')
+_architectures="i686-w64-mingw32 x86_64-w64-mingw32"
+
+build() {
+ for _arch in ${_architectures}; do
+ for _variant in '' '-static'; do
+ sed "s|@TRIPLE@|${_arch}|g;s|@PROCESSOR@|${_arch::-12}|g" toolchain-mingw-static.cmake > toolchain-${_arch}-static.cmake
+ sed "s|@TRIPLE@|${_arch}|g" mingw-cmake-static.sh > ${_arch}-cmake-static
+ done
+ done
+}
+
+package() {
+ install -d "${pkgdir}"/usr/bin
+ install -d "${pkgdir}"/usr/share/mingw
+ for _arch in ${_architectures}; do
+ install -m 644 toolchain-${_arch}-static.cmake "${pkgdir}"/usr/share/mingw/
+ install -m 755 ${_arch}-cmake-static "${pkgdir}"/usr/bin/
+ done
+}
+
diff --git a/mingw-cmake-static.sh b/mingw-cmake-static.sh
new file mode 100644
index 000000000000..11c8c49e66f4
--- /dev/null
+++ b/mingw-cmake-static.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+source mingw-env @TRIPLE@
+
+mingw_prefix=/usr/@TRIPLE@
+
+PATH=${mingw_prefix}/bin:$PATH cmake \
+ -DCMAKE_INSTALL_PREFIX:PATH=${mingw_prefix} \
+ -DCMAKE_INSTALL_LIBDIR:PATH=lib \
+ -DCMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES:PATH=${mingw_prefix}/include \
+ -DCMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES:PATH=${mingw_prefix}/include \
+ -DBUILD_SHARED_LIBS:BOOL=OFF \
+ -DCMAKE_TOOLCHAIN_FILE=/usr/share/mingw/toolchain-@TRIPLE@-static.cmake \
+ -DCMAKE_CROSSCOMPILING_EMULATOR=/usr/bin/@TRIPLE@-wine \
+ "$@"
diff --git a/toolchain-mingw-static.cmake b/toolchain-mingw-static.cmake
new file mode 100644
index 000000000000..ee5cffad8f0b
--- /dev/null
+++ b/toolchain-mingw-static.cmake
@@ -0,0 +1,41 @@
+# This toolchain file helps building a fully statically linked executable (besides DLLs from Windows itself) by
+# defining certain variables. It is mainly focusing on dependencies used by Qt.
+
+# build this on top of the regular toolchain file
+include("/usr/share/mingw/toolchain-@TRIPLE@.cmake")
+
+# prefer libraries from "static" sub-prefix
+set(CMAKE_FIND_ROOT_PATH "/usr/@TRIPLE@/static;${CMAKE_FIND_ROOT_PATH}")
+
+# prefer static libraries
+# note: It is of no use to set the real variable CMAKE_FIND_LIBRARY_SUFFIXES here because it gets overridden by CMake
+# after loading the toolchain file. The project needs to make the actual override if enforcing static libraries
+# is required.
+set(CMAKE_FIND_LIBRARY_SUFFIXES_OVERRIDE ".a;.lib")
+set(CMAKE_EXE_LINKER_FLAGS "$ENV{LDFLAGS} -static -static-libgcc -static-libstdc++" CACHE STRING "linker flags for static builds" FORCE)
+set(OPENSSL_USE_STATIC_LIBS ON)
+set(BOOST_USE_STATIC_LIBS ON)
+
+# force-use the shared Vulkan library because there's no static one
+# note: The library is not used anyways but required for Vulkan to be considered installed and enabled.
+set(Vulkan_LIBRARY "/usr/@TRIPLE@/lib/libvulkan.dll.a" CACHE FILEPATH "shared Vulkan IDC library")
+
+# workaround limitations in upstream pkg-config files and CMake find modules
+set(pkgcfg_lib_libbrotlicommon_brotlicommon "/usr/@TRIPLE@/lib/libbrotlicommon-static.a" CACHE INTERNAL "static libbrotlicommon")
+set(pkgcfg_lib_libbrotlienc_brotlienc "/usr/@TRIPLE@/lib/libbrotlienc-static.a;/usr/@TRIPLE@/lib/libbrotlicommon-static.a" CACHE INTERNAL "static libbrotliend")
+set(pkgcfg_lib_libbrotlidec_brotlidec "/usr/@TRIPLE@/lib/libbrotlidec-static.a;/usr/@TRIPLE@/lib/libbrotlicommon-static.a" CACHE INTERNAL "static libbrotlidec")
+set(libbrotlicommon_STATIC_LDFLAGS "${pkgcfg_lib_libbrotlicommon_brotlicommon}" CACHE INTERNAL "static libbrotlicommon")
+set(libbrotlienc_STATIC_LDFLAGS "${pkgcfg_lib_libbrotlienc_brotlienc}" CACHE INTERNAL "static libbrotliend")
+set(libbrotlidec_STATIC_LDFLAGS "${pkgcfg_lib_libbrotlidec_brotlidec}" CACHE INTERNAL "static libbrotlidec")
+
+# define dependencies of various static libraries as CMake doesn't pull them reliably automatically
+# note: It would be possible to deduce the dependencies via pkg-config. However, for simplicity I'm hard-coding the dependencies for now.
+# In some cases the pkg-config file wouldn't work anyways because it is only covering the shared version (despite use of `-static`).
+set(OPENSSL_DEPENDENCIES "-lws2_32;-lgdi32;-lcrypt32" CACHE INTERNAL "dependencies of static OpenSSL libraries")
+set(POSTGRESQL_DEPENDENCIES "-lpgcommon;-lpgport;-lintl;-lssl;-lcrypto;-lshell32;-lws2_32;-lsecur32;-liconv" CACHE INTERNAL "dependencies of static PostgreSQL libraries")
+set(MYSQL_DEPENDENCIES "-lssl;-lcrypto;-lshlwapi;-lgdi32;-lws2_32;-lpthread;-lz;-lm" CACHE INTERNAL "dependencies of static MySQL/MariaDB libraries")
+set(LIBPNG_DEPENDENCIES "-lz" CACHE INTERNAL "dependencies of static libpng")
+set(GLIB2_DEPENDENCIES "-lintl;-lws2_32;-lole32;-lwinmm;-lshlwapi;-lm" CACHE INTERNAL "dependencies of static Glib2")
+set(FREETYPE_DEPENDENCIES "-lbz2;-lharfbuzz;-lfreetype" CACHE INTERNAL "dependencies of static FreeType2 library")
+set(HARFBUZZ_DEPENDENCIES "-lglib-2.0;${GLIB2_DEPENDENCIES};-lintl;-lm;-lfreetype;-lgraphite2" CACHE INTERNAL "dependencies of static HarfBuzz library")
+set(DBUS1_DEPENDENCIES "-lws2_32;-liphlpapi;-ldbghelp" CACHE INTERNAL "dependencies of static D-Bus1 library")