Skip to content

Commit 31a6e4d

Browse files
committed
[WIP] Switch MinGW building to CMake
Automatically grabs and compiles libpng, and avoids having hacky lines in our Makefile (the compiler specification *should* be orthogonal to the build target!)
1 parent 66e521e commit 31a6e4d

3 files changed

Lines changed: 23 additions & 5 deletions

File tree

.github/workflows/testing.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,12 @@ jobs:
240240
- name: Install MinGW
241241
run: | # dpkg-dev is apparently required for pkg-config for cross-building
242242
sudo apt-get install g++-mingw-w64-${{ matrix.arch }}-win32 mingw-w64-tools libz-mingw-w64-dev dpkg-dev
243-
- name: Install libpng dev headers for MinGW
244-
run: |
245-
./.github/scripts/mingw-w64-libpng-dev.sh ${{ matrix.triplet }}
243+
#- name: Install libpng dev headers for MinGW
244+
# run: |
245+
# ./.github/scripts/mingw-w64-libpng-dev.sh ${{ matrix.triplet }}
246246
- name: Cross-build Windows binaries
247247
run: |
248-
make mingw${{ matrix.bits }} -kj Q=
248+
cmake -B build -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-mingw64.cmake
249249
- name: Package binaries
250250
run: | # DLL dependencies can be figured out using e.g. Dependency Walker or objdump -p
251251
mkdir bins

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ CMakeCache.txt
1414
CMakeFiles/
1515
cmake_install.cmake
1616
CMakeUserPresets.json
17-
build/
17+
build*/
1818
*.dSYM/
1919
callgrind.out.*

cmake/toolchain-mingw64.cmake

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# From https://www.mingw-w64.org/build-systems/cmake/
2+
3+
set(CMAKE_SYSTEM_NAME Windows)
4+
set(CMAKE_SYSTEM_PROCESSOR x86_64)
5+
6+
# specify the cross compiler
7+
set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
8+
set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
9+
set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)
10+
11+
# where is the target environment
12+
set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32)
13+
14+
# search for programs in the build host directories
15+
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
16+
# for libraries and headers in the target directories
17+
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
18+
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

0 commit comments

Comments
 (0)