Skip to content

Commit 85e189a

Browse files
authored
Merge pull request #91 from tomoss/dev-ci-cmake-gcc-clang
Modified cmake CI to also build for Windows and fixed MSVC error C3493
2 parents 26b2ad9 + b8e3c60 commit 85e189a

File tree

3 files changed

+48
-7
lines changed

3 files changed

+48
-7
lines changed

.github/workflows/cmake-gcc-clang.yml

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,30 @@ jobs:
3535
#
3636
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
3737
matrix:
38-
os: [ubuntu-latest, ubuntu-24.04-arm] # windows-latest
39-
build_type: [Release]
40-
compiler:
41-
- { c: gcc, cpp: g++ }
42-
- { c: clang, cpp: clang++ }
38+
include:
39+
# --- Linux x64 ---
40+
# We define 'compiler' as a dictionary (object) here
41+
- os: ubuntu-latest
42+
build_type: Release
43+
compiler: { c: gcc, cpp: g++ }
44+
45+
- os: ubuntu-latest
46+
build_type: Release
47+
compiler: { c: clang, cpp: clang++ }
48+
49+
# --- Linux ARM ---
50+
- os: ubuntu-24.04-arm
51+
build_type: Release
52+
compiler: { c: gcc, cpp: g++ }
53+
54+
- os: ubuntu-24.04-arm
55+
build_type: Release
56+
compiler: { c: clang, cpp: clang++ }
57+
58+
# --- Windows ---
59+
- os: windows-latest
60+
build_type: Release
61+
compiler: { c: cl, cpp: cl }
4362

4463
steps:
4564
- uses: actions/checkout@v6
@@ -56,6 +75,19 @@ jobs:
5675
run: |
5776
sudo apt-get install --yes -qq libboost-all-dev
5877
78+
- name: Install Boost via vcpkg (Windows)
79+
if: startsWith(matrix.os, 'windows')
80+
run: |
81+
# 1. Install Boost using the Microsoft Package Manager
82+
# windows-latest has vcpkg pre-installed at C:\vcpkg
83+
vcpkg install boost-test:x64-windows
84+
85+
# 2. Inform CMake where to find it
86+
echo "BOOST_ROOT=$env:VCPKG_INSTALLATION_ROOT\installed\x64-windows" >> $env:GITHUB_ENV
87+
88+
# 3. Add vcpkg DLL path to CI before running tests
89+
echo "$env:VCPKG_INSTALLATION_ROOT\installed\x64-windows\bin" >> $env:GITHUB_PATH
90+
5991
- name: Configure CMake Ubuntu
6092
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
6193
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
@@ -69,6 +101,15 @@ jobs:
69101
-DATOMIC_QUEUE_BUILD_EXAMPLES=ON
70102
-S ${{ github.workspace }}
71103
104+
- name: Configure CMake Windows - MSVC
105+
if: startsWith(matrix.os, 'windows') && matrix.compiler.cpp == 'cl'
106+
run: >
107+
cmake -B ${{ steps.strings.outputs.build-output-dir }}
108+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
109+
-DATOMIC_QUEUE_BUILD_TESTS=ON
110+
-DATOMIC_QUEUE_BUILD_EXAMPLES=ON
111+
-S ${{ github.workspace }}
112+
72113
- name: Build
73114
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
74115
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}

src/example.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ int main() {
3737
// Start the producers.
3838
std::thread producers[PRODUCERS];
3939
for(int i = 0; i < PRODUCERS; ++i)
40-
producers[i] = std::thread([&q]() {
40+
producers[i] = std::thread([&q, N = N]() {
4141
// Each producer pushes range [1, N] elements into the queue.
4242
// Ascending order [1, N] requires comparing with N at each loop iteration. Ascending order isn't necessary here.
4343
// Push elements in descending order, range [N, 1] with step -1, so that CPU decrement instruction sets zero/equal flag

src/tests.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void stress() {
4343
uint64_t results[CONSUMERS];
4444
std::thread consumers[CONSUMERS];
4545
for(unsigned i = 0; i < CONSUMERS; ++i)
46-
consumers[i] = std::thread([&q, &barrier, &r = results[i]]() {
46+
consumers[i] = std::thread([&q, &barrier, &r = results[i], STOP = STOP]() {
4747
barrier.wait();
4848
uint64_t result = 0;
4949
for(T n; (n = q.pop()) != STOP;)

0 commit comments

Comments
 (0)