Skip to content

Commit 4691ae1

Browse files
committed
Build and test on Windows MSYS2
New GitHub workflow to build and test on a Windows MSYS2 build in 32 and 64 bits. This patch sets the `LANGUAGES` to `CXX` in the cmake project to avoid setting up the `C` language which is not used by the project. Due to a bug in cmake ninja generator with MSYS we can't set a prefix on the target because it creates a duplicated ninja rule.
1 parent acc21a6 commit 4691ae1

File tree

2 files changed

+51
-3
lines changed

2 files changed

+51
-3
lines changed

.github/workflows/build_test.yml

+43
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,46 @@ jobs:
5555
path: ~/.cache/bazel
5656
key: bazel-${{ runner.os }}
5757
- run: bazel build //...
58+
59+
windows_msys2:
60+
name: Windows MSYS2 / ${{ matrix.arch }}
61+
runs-on: windows-latest
62+
strategy:
63+
fail-fast: false
64+
matrix:
65+
include:
66+
- arch: x86_64
67+
msystem: mingw64
68+
- arch: i686
69+
msystem: mingw32
70+
defaults:
71+
run:
72+
shell: msys2 {0}
73+
steps:
74+
- uses: actions/checkout@v2
75+
- uses: msys2/setup-msys2@v2
76+
with:
77+
msystem: ${{ matrix.msystem }}
78+
update: false
79+
install: >-
80+
base-devel
81+
git
82+
mingw-w64-${{ matrix.arch }}-cmake
83+
mingw-w64-${{ matrix.arch }}-gcc
84+
mingw-w64-${{ matrix.arch }}-gtest
85+
mingw-w64-${{ matrix.arch }}-ninja
86+
87+
- name: CMake configure
88+
# Enable only SCALAR and AVX2 to speed up the build/test.
89+
run: |
90+
cmake \
91+
-DCMAKE_BUILD_TYPE=Release \
92+
-DCMAKE_CXX_FLAGS="-DHWY_DISABLED_TARGETS=\"~(HWY_SCALAR|HWY_AVX2)\"" \
93+
-DHWY_WARNINGS_ARE_ERRORS=ON \
94+
-DHWY_SYSTEM_GTEST=ON \
95+
-B out \
96+
-G Ninja
97+
- name: CMake build
98+
run: cmake --build out
99+
- name: Test
100+
run: ctest --test-dir out --parallel 2 --output-on-failure

CMakeLists.txt

+8-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ if(POLICY CMP0083)
1919
cmake_policy(SET CMP0083 NEW)
2020
endif()
2121

22-
project(hwy VERSION 0.14.2) # Keep in sync with highway.h version
22+
project(hwy LANGUAGES CXX VERSION 0.14.2) # Keep in sync with highway.h version
2323

2424
set(CMAKE_CXX_STANDARD 11)
2525
set(CMAKE_CXX_EXTENSIONS OFF)
@@ -374,8 +374,13 @@ foreach (TESTFILE IN LISTS HWY_TEST_FILES)
374374
else()
375375
target_link_libraries(${TESTNAME} hwy hwy_contrib hwy_test gtest gtest_main)
376376
endif()
377-
# Output test targets in the test directory.
378-
set_target_properties(${TESTNAME} PROPERTIES PREFIX "tests/")
377+
378+
# MINGW with Ninja generates two build rules for the same file when setting a
379+
# prefix in the target. We skip the prefix in MINGW to workaround the issue.
380+
if(NOT MINGW OR NOT ${CMAKE_GENERATOR} STREQUAL "Ninja").
381+
# Output test targets in the test directory.
382+
set_target_properties(${TESTNAME} PROPERTIES PREFIX "tests/")
383+
endif()
379384

380385
if (HWY_EMSCRIPTEN)
381386
set_target_properties(${TESTNAME} PROPERTIES LINK_FLAGS "-s SINGLE_FILE=1")

0 commit comments

Comments
 (0)