Skip to content

Commit 85bc12d

Browse files
Copilot0xrinegade
andcommitted
Fix Windows CI: use vcpkg for Google Test, PowerShell shell, and proper toolchain
Co-authored-by: 0xrinegade <[email protected]>
1 parent 3a0d563 commit 85bc12d

File tree

1 file changed

+28
-18
lines changed

1 file changed

+28
-18
lines changed

.github/workflows/cpp_sdk.yml

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,10 @@ jobs:
6666
6767
- name: Install dependencies (Windows)
6868
if: matrix.os == 'windows-latest'
69+
shell: pwsh
6970
run: |
7071
choco install cmake ninja pkgconfiglite
71-
vcpkg install libsodium:x64-windows pkgconf:x64-windows
72+
vcpkg install libsodium:x64-windows pkgconf:x64-windows gtest:x64-windows
7273
echo "CMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake" >> $env:GITHUB_ENV
7374
echo "PKG_CONFIG_PATH=C:/vcpkg/installed/x64-windows/lib/pkgconfig" >> $env:GITHUB_ENV
7475
if ("${{ matrix.compiler }}" -eq "msvc") {
@@ -96,38 +97,47 @@ jobs:
9697
cmake --build . --config ${{ matrix.build-type }}
9798
sudo cmake --install . --config ${{ matrix.build-type }}
9899
99-
- name: Install Google Test (Windows)
100+
- name: Configure CMake (Windows)
100101
if: matrix.os == 'windows-latest'
102+
shell: pwsh
101103
run: |
102-
git clone https://github.com/google/googletest.git
103-
cd googletest
104+
cd cpp_sdk
104105
mkdir build && cd build
105-
cmake .. -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} -DCMAKE_TOOLCHAIN_FILE=$env:CMAKE_TOOLCHAIN_FILE
106-
cmake --build . --config ${{ matrix.build-type }}
107-
cmake --install . --config ${{ matrix.build-type }}
106+
if ("${{ matrix.compiler }}" -eq "msvc") {
107+
cmake .. -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} -DENABLE_SANITIZERS=ON -DCMAKE_TOOLCHAIN_FILE="${{ env.CMAKE_TOOLCHAIN_FILE }}"
108+
} else {
109+
cmake .. -GNinja -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} -DENABLE_SANITIZERS=ON -DCMAKE_TOOLCHAIN_FILE="${{ env.CMAKE_TOOLCHAIN_FILE }}"
110+
}
111+
env:
112+
CI: true
108113

109-
- name: Configure CMake
114+
- name: Configure CMake (Unix)
115+
if: matrix.os != 'windows-latest'
116+
shell: bash
110117
run: |
111118
cd cpp_sdk
112119
mkdir build && cd build
113-
if [[ "${{ matrix.compiler }}" == "msvc" ]]; then
114-
cmake .. -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} -DENABLE_SANITIZERS=ON -DCMAKE_TOOLCHAIN_FILE=${{ env.CMAKE_TOOLCHAIN_FILE }}
115-
else
116-
cmake .. -GNinja -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} -DENABLE_SANITIZERS=ON
117-
fi
118-
shell: bash
120+
cmake .. -GNinja -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} -DENABLE_SANITIZERS=ON
119121
env:
120122
CI: true
121123

122-
- name: Build
124+
- name: Build (Windows)
125+
if: matrix.os == 'windows-latest'
126+
shell: pwsh
123127
run: |
124128
cd cpp_sdk/build
125-
if [[ "${{ matrix.compiler }}" == "msvc" ]]; then
129+
if ("${{ matrix.compiler }}" -eq "msvc") {
126130
cmake --build . --config ${{ matrix.build-type }}
127-
else
131+
} else {
128132
ninja
129-
fi
133+
}
134+
135+
- name: Build (Unix)
136+
if: matrix.os != 'windows-latest'
130137
shell: bash
138+
run: |
139+
cd cpp_sdk/build
140+
ninja
131141
132142
- name: Run tests
133143
run: |

0 commit comments

Comments
 (0)