Skip to content

Commit

Permalink
Add a simple MSVC cross-compile script for testing
Browse files Browse the repository at this point in the history
This is not generally useful, but with a suitable setup allows for smoke
testing of an MSVC build without needing Windows.
  • Loading branch information
cspiegel committed Feb 24, 2024
1 parent ed50f18 commit eb317b1
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Toolchain-msvc.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR X86_64)

set(CMAKE_BUILD_TYPE "Release")
set(CMAKE_C_COMPILER "x86_64-pc-windows-msvc-gcc")
set(CMAKE_CXX_COMPILER "x86_64-pc-windows-msvc-g++")
set(CMAKE_EXE_LINKER_FLAGS "/winsdkdir:/usr/x86_64-pc-windows-msvc/winsdk/sdk /vctoolsdir:/usr/x86_64-pc-windows-msvc/winsdk/crt /libpath:/usr/x86_64-pc-windows-msvc/winsdk/sdk/lib/um/x64")
set(CMAKE_SHARED_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS})
set(CMAKE_MT "llvm-mt")

set(CMAKE_FIND_ROOT_PATH /usr/x86_64-pc-windows-msvc)

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

set(ENV{PKG_CONFIG_DIR} "")
set(ENV{PKG_CONFIG_LIBDIR} "/usr/x86_64-pc-windows-msvc/lib/pkgconfig")
39 changes: 39 additions & 0 deletions msvc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

set -ex

qt="$HOME/Qt/6.6.0/msvc2019_64"

nproc=$(getconf _NPROCESSORS_ONLN)

[[ -e build/dist ]] && exit 1

(
mkdir build-msvc
cd build-msvc
cmake .. -DWITH_QT6=ON -DCMAKE_PREFIX_PATH="${qt}" -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=Toolchain-msvc.cmake -DSOUND=QT -DWITH_BUNDLED_FMT=ON -DDIST_INSTALL=ON
make -j${nproc}
make install
)

for dll in libpng16.dll sndfile.dll turbojpeg.dll zlib1.dll
do
cp "/usr/x86_64-pc-windows-msvc/bin/${dll}" build/dist
done

for dll in Qt6Core.dll Qt6Gui.dll Qt6Multimedia.dll Qt6Network.dll Qt6Widgets.dll
do
cp "${qt}/bin/${dll}" build/dist
done

mkdir -p "build/dist/plugins/platforms"
cp "${qt}/plugins/platforms/qwindows.dll" "build/dist/plugins/platforms"
mkdir -p "build/dist/plugins/multimedia"
cp "${qt}/plugins/multimedia/windowsmediaplugin.dll" "build/dist/plugins/multimedia"

cp licenses/*.txt build/dist
cp fonts/Gargoyle*.ttf build/dist
cp fonts/unifont*.otf build/dist
mkdir build/dist/themes
cp themes/*.json build/dist/themes
unix2dos -n garglk/garglk.ini build/dist/garglk.ini

0 comments on commit eb317b1

Please sign in to comment.