Skip to content

Commit 9102673

Browse files
Add modules CI for building the modules
1 parent 690b59c commit 9102673

2 files changed

Lines changed: 169 additions & 0 deletions

File tree

.github/workflows/modules-ci.yml

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
name: C++20 Modules CI
2+
on: [push, workflow_dispatch, pull_request]
3+
4+
env:
5+
# Enable verbose output for CMake and tests
6+
VERBOSE: 1
7+
CTEST_OUTPUT_ON_FAILURE: 1
8+
9+
jobs:
10+
ubuntu-clang-modules:
11+
strategy:
12+
matrix:
13+
buildType: [Debug, Release]
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Update package list
17+
run: sudo apt update
18+
- name: Install Dependencies
19+
run: |
20+
sudo apt install -y git libssl-dev build-essential libcurl4-openssl-dev libpsl-dev meson libunistring-dev ninja-build wget
21+
# Install Clang 21+
22+
wget https://apt.llvm.org/llvm.sh
23+
chmod +x llvm.sh
24+
sudo ./llvm.sh 21
25+
sudo apt install -y libc++-21-dev libc++abi-21-dev
26+
env:
27+
DEBIAN_FRONTEND: noninteractive
28+
- name: Install CMake 3.28+
29+
run: |
30+
wget -O cmake.sh https://github.com/Kitware/CMake/releases/download/v3.28.3/cmake-3.28.3-linux-x86_64.sh
31+
sudo sh cmake.sh --prefix=/usr/local --skip-license
32+
cmake --version
33+
- name: Checkout
34+
uses: actions/checkout@v5
35+
- name: Configure
36+
run: |
37+
cmake -S . -B build \
38+
-DCMAKE_BUILD_TYPE=${{ matrix.buildType }} \
39+
-DCMAKE_CXX_COMPILER=clang++-21 \
40+
-DCMAKE_C_COMPILER=clang-21 \
41+
-DCPR_BUILD_MODULES=ON \
42+
-DCPR_BUILD_TESTS=ON \
43+
-DCPR_BUILD_TESTS_SSL=ON \
44+
-DCPR_FORCE_OPENSSL_BACKEND=ON \
45+
-DCPR_USE_SYSTEM_CURL=OFF \
46+
-G Ninja
47+
- name: Build
48+
run: cmake --build build --verbose
49+
- name: Test
50+
run: ctest --test-dir build --output-on-failure --repeat until-pass:5
51+
- name: Verify Module Build
52+
run: |
53+
echo "Contents of build/modules:"
54+
ls -la build/modules/
55+
if [ -f build/modules/libcpr_module.a ] || [ -f build/modules/libcpr_module.so ] || [ -f build/modules/cpr_module.a ] || find build/modules -name "*cpr_module*" -type f | grep -q .; then
56+
echo "Module library built successfully"
57+
else
58+
echo "Error: Module library not found"
59+
exit 1
60+
fi
61+
62+
fedora-gcc-modules:
63+
runs-on: ubuntu-latest
64+
container: "fedora:latest"
65+
steps:
66+
- name: Update package list
67+
run: dnf update -y
68+
- name: Install Dependencies
69+
run: dnf install -y gcc g++ git make openssl-devel libcurl-devel cmake libpsl-devel libunistring-devel meson ninja-build
70+
- name: Checkout
71+
uses: actions/checkout@v5
72+
- name: Configure
73+
run: |
74+
cmake -S . -B build \
75+
-DCMAKE_BUILD_TYPE=Release \
76+
-DCPR_BUILD_MODULES=ON \
77+
-DCPR_BUILD_TESTS=ON \
78+
-DCPR_BUILD_TESTS_SSL=ON \
79+
-DCPR_FORCE_OPENSSL_BACKEND=ON \
80+
-DCPR_USE_SYSTEM_CURL=OFF \
81+
-G Ninja
82+
- name: Build
83+
run: cmake --build build --verbose
84+
- name: Test
85+
run: ctest --test-dir build --output-on-failure --repeat until-pass:5
86+
- name: Verify Module Build
87+
run: |
88+
echo "Contents of build/modules:"
89+
ls -la build/modules/
90+
if [ -f build/modules/libcpr_module.a ] || [ -f build/modules/libcpr_module.so ] || [ -f build/modules/cpr_module.a ] || find build/modules -name "*cpr_module*" -type f | grep -q .; then
91+
echo "Module library built successfully"
92+
else
93+
echo "Error: Module library not found"
94+
exit 1
95+
fi
96+
97+
windows-msvc-modules:
98+
runs-on: windows-latest
99+
steps:
100+
- uses: actions/setup-python@v6
101+
- name: Install meson
102+
run: pip install meson
103+
- name: Setup MSVC environment
104+
uses: ilammy/msvc-dev-cmd@v1
105+
- name: Checkout
106+
uses: actions/checkout@v5
107+
- name: Install dependencies via vcpkg
108+
run: |
109+
vcpkg install curl zlib openssl --triplet x64-windows
110+
shell: pwsh
111+
- name: Configure
112+
run: |
113+
cmake -S . -B build `
114+
-DCMAKE_BUILD_TYPE=Release `
115+
-DCMAKE_TOOLCHAIN_FILE="C:/vcpkg/scripts/buildsystems/vcpkg.cmake" `
116+
-DVCPKG_TARGET_TRIPLET=x64-windows `
117+
-DCPR_BUILD_MODULES=ON `
118+
-DCPR_BUILD_TESTS=ON `
119+
-DCPR_BUILD_TESTS_SSL=OFF `
120+
-DCPR_USE_SYSTEM_CURL=ON `
121+
-G "Visual Studio 17 2022"
122+
shell: pwsh
123+
- name: Build
124+
run: cmake --build build --config Release --verbose
125+
- name: Test
126+
run: ctest --test-dir build -C Release --output-on-failure --repeat until-pass:5
127+
- name: Verify Module Build
128+
run: |
129+
Write-Host "Contents of build/modules/Release:"
130+
Get-ChildItem -Path build/modules/Release -Force
131+
if (!(Test-Path "build/modules/Release/cpr_module.lib") -and !(Get-ChildItem -Path build/modules -Recurse -Filter "*cpr_module*")) {
132+
throw "Module library not found"
133+
}
134+
Write-Host "Module library built successfully"
135+
shell: pwsh
136+
137+
macos-clang-modules:
138+
runs-on: macos-latest
139+
steps:
140+
- name: Install Dependencies
141+
run: |
142+
brew install libpsl ninja
143+
- name: Checkout
144+
uses: actions/checkout@v5
145+
- name: Configure
146+
run: |
147+
cmake -S . -B build \
148+
-DCMAKE_BUILD_TYPE=Release \
149+
-DCPR_BUILD_MODULES=ON \
150+
-DCPR_BUILD_TESTS=ON \
151+
-DCPR_BUILD_TESTS_SSL=OFF \
152+
-DCPR_USE_SYSTEM_LIB_PSL=ON \
153+
-G Ninja
154+
- name: Build
155+
run: cmake --build build --verbose
156+
- name: Test
157+
run: ctest --test-dir build --output-on-failure --repeat until-pass:5
158+
- name: Verify Module Build
159+
run: |
160+
echo "Contents of build/modules:"
161+
ls -la build/modules/
162+
if [ -f build/modules/libcpr_module.a ] || [ -f build/modules/libcpr_module.dylib ] || [ -f build/modules/cpr_module.a ] || find build/modules -name "*cpr_module*" -type f | grep -q .; then
163+
echo "Module library built successfully"
164+
else
165+
echo "Error: Module library not found"
166+
exit 1
167+
fi

modules/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
cmake_minimum_required(VERSION 3.28)
22

3+
set(CMAKE_CXX_SCAN_FOR_MODULES ON)
4+
35
add_library(cpr_module)
46

57
target_sources(cpr_module

0 commit comments

Comments
 (0)