Skip to content

Commit 5a39df0

Browse files
author
Gonzalo Diaz
committed
[CONFIG] [Github Actions] C/C++ for windows.
1 parent a99ebd3 commit 5a39df0

File tree

3 files changed

+81
-1
lines changed

3 files changed

+81
-1
lines changed

.github/workflows/c-windows.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
name: C/C++ CMake CI Test
3+
4+
on: # yamllint disable-line rule:truthy
5+
push:
6+
branches: ["main"]
7+
pull_request:
8+
# The branches below must be a subset of the branches above
9+
branches: ["main"]
10+
workflow_dispatch:
11+
12+
jobs:
13+
build:
14+
name: C/C++ CMake CI Test
15+
strategy:
16+
matrix:
17+
os: ["windows-2022"]
18+
arch:
19+
- amd64
20+
- amd64_x86
21+
- amd64_arm64
22+
23+
runs-on: ${{ matrix.os }}
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
28+
29+
- name: Install
30+
shell: bash
31+
run: |
32+
if [ "$RUNNER_OS" == "macOS" ]; then
33+
brew install vcpkg
34+
git clone https://github.com/microsoft/vcpkg "$HOME/vcpkg"
35+
export VCPKG_ROOT="$HOME/vcpkg"
36+
echo "VCPKG_ROOT=$HOME/vcpkg" >> $GITHUB_ENV
37+
elif [ "$RUNNER_OS" == "Linux" ]; then
38+
echo "VCPKG_ROOT=/usr/local/share/vcpkg" >> $GITHUB_ENV
39+
elif [ "$RUNNER_OS" == "Windows" ]; then
40+
echo "VCPKG_ROOT=C:/vcpkg" >> $GITHUB_ENV
41+
fi
42+
43+
- name: Check Tools
44+
run: |
45+
echo "-----------"
46+
make --version
47+
echo "-----------"
48+
cmake --version
49+
echo "-----------"
50+
vcpkg --version
51+
echo "-----------"
52+
53+
- uses: ilammy/msvc-dev-cmd@v1
54+
with:
55+
arch: ${{ matrix.arch }}
56+
57+
- name: Install dependencies
58+
run: |
59+
vcpkg --x-wait-for-lock integrate install
60+
vcpkg --x-wait-for-lock install
61+
62+
- name: Build
63+
run: |
64+
cmake --preset windows -B build
65+
cmake --build build --verbose
66+
67+
- name: Test
68+
run: |
69+
make test

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ set(CMAKE_C_STANDARD 11)
1414
set(CMAKE_C_STANDARD_REQUIRED ON)
1515
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
1616

17-
SET(GCC_COVERAGE_COMPILE_FLAGS "-fsanitize=address -fprofile-arcs -ftest-coverage -g -O0")
17+
SET(GCC_COVERAGE_COMPILE_FLAGS "-fprofile-arcs -ftest-coverage -g -O0")
1818
SET(GCC_COVERAGE_LINK_FLAGS "--coverage")
1919
SET(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}")
2020
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}")

CMakePresets.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@
1010
},
1111
"generator": "Unix Makefiles",
1212
"binaryDir": "${sourceDir}/build/default"
13+
},
14+
{
15+
"name": "windows",
16+
"cacheVariables": {
17+
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
18+
"CMAKE_BUILD_TYPE": "Debug",
19+
"CMAKE_C_COMPILER": "cl",
20+
"CMAKE_CXX_COMPILER": "cl"
21+
},
22+
"generator": "NMake Makefiles",
23+
"binaryDir": "${sourceDir}/build/default"
1324
}
1425
]
1526
}

0 commit comments

Comments
 (0)