Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ jobs:
build-type: Release
run-test: true
ctest-options: ${{ env.CTEST_OPTIONS }}

macos-clang-ssl:
strategy:
matrix:
Expand Down
156 changes: 156 additions & 0 deletions .github/workflows/modules-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
name: C++20 Modules CI
on: [push, workflow_dispatch, pull_request]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest adding a small example in examples/modules/... where the test actually compiles and uses modules via import cpr;.

env:
# Enable verbose output for CMake and tests
VERBOSE: 1
CTEST_OUTPUT_ON_FAILURE: 1

jobs:
fedora-clang-modules:
strategy:
matrix:
buildType: [Debug, Release]
runs-on: ubuntu-latest
# Fedora ships a recent Clang, libc++ and CMake out of the box, so we do not
# have to download and pin specific compiler/CMake versions by hand.
container: "fedora:latest"
steps:
- name: Update package list
run: dnf update -y
- name: Install Dependencies
run: dnf install -y clang clang-tools-extra libcxx-devel libcxxabi-devel cmake git make openssl-devel libcurl-devel libpsl-devel libunistring-devel meson ninja-build tar wget
- name: Checkout
uses: actions/checkout@v5
- name: Configure
run: |
cmake -S . -B build \
-DCMAKE_BUILD_TYPE=${{ matrix.buildType }} \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_FLAGS="-stdlib=libc++" \
-DCPR_BUILD_MODULES=ON \
-DCPR_BUILD_TESTS=ON \
-DCPR_BUILD_TESTS_SSL=ON \
-DCPR_FORCE_OPENSSL_BACKEND=ON \
-DCPR_USE_SYSTEM_CURL=OFF \
-G Ninja
- name: Build
run: cmake --build build --verbose
- name: Test
run: ctest --test-dir build --output-on-failure --repeat until-pass:5
- name: Verify Module Build
# Running the 'import cpr;' example is the real proof that the module was
# built and is importable; grepping for a library file on disk is not,
# since a module-only target may not emit a conventional archive.
run: ./build/bin/cpr_module_example

fedora-gcc-modules:
runs-on: ubuntu-latest
container: "fedora:latest"
steps:
- name: Update package list
run: dnf update -y
- name: Install Dependencies
# Fedora ships GCC and CMake recent enough for 'import std' out of the box.
run: dnf install -y gcc g++ git make cmake openssl-devel libcurl-devel libpsl-devel libunistring-devel meson ninja-build tar wget
- name: Checkout
uses: actions/checkout@v5
- name: Configure
run: |
cmake -S . -B build \
-DCMAKE_BUILD_TYPE=Release \
-DCPR_BUILD_MODULES=ON \
-DCPR_BUILD_TESTS=ON \
-DCPR_BUILD_TESTS_SSL=ON \
-DCPR_FORCE_OPENSSL_BACKEND=ON \
-DCPR_USE_SYSTEM_CURL=OFF \
-G Ninja
- name: Build
run: cmake --build build --verbose
- name: Test
run: ctest --test-dir build --output-on-failure --repeat until-pass:5
- name: Verify Module Build
# Running the 'import cpr;' example proves the module compiled and imports.
run: ./build/bin/cpr_module_example

windows-msvc-modules:
runs-on: windows-latest
steps:
- uses: actions/setup-python@v6
- name: Install meson
run: pip install meson
- name: Setup MSVC environment
uses: ilammy/msvc-dev-cmd@v1
- name: Checkout
uses: actions/checkout@v5
- name: Install dependencies via vcpkg
run: |
vcpkg install curl zlib openssl --triplet x64-windows
shell: pwsh
- name: Configure
run: |
cmake -S . -B build `
-DCMAKE_BUILD_TYPE=Release `
-DCMAKE_TOOLCHAIN_FILE="C:/vcpkg/scripts/buildsystems/vcpkg.cmake" `
-DVCPKG_TARGET_TRIPLET=x64-windows `
-DCPR_BUILD_MODULES=ON `
-DCPR_BUILD_TESTS=ON `
-DCPR_BUILD_TESTS_SSL=OFF `
-DCPR_USE_SYSTEM_CURL=ON `
-G Ninja
shell: pwsh
- name: Build
run: cmake --build build --config Release --verbose
- name: Test
run: ctest --test-dir build -C Release --output-on-failure --repeat until-pass:5
- name: Verify Module Build
# Running the 'import cpr;' example proves the module compiled and imports.
run: ./build/bin/cpr_module_example.exe
shell: pwsh

macos-clang-modules:
runs-on: macos-latest
# Uses Homebrew LLVM's own libc++ for 'import std' (see Configure).
# Keep the job non-blocking until it has been confirmed stable on CI.
continue-on-error: true
steps:
- name: Install Dependencies
run: |
brew install cmake llvm libpsl ninja
echo "$(brew --prefix cmake)/bin" >> "$GITHUB_PATH"
- name: Checkout
uses: actions/checkout@v5
- name: Configure
run: |
# Homebrew's clang links the macOS system libc++ by default, and CMake's
# '-print-file-name' lookup does not find the 'libc++.modules.json' that
# Homebrew's own libc++ ships. Point CMake at it and link that libc++.
LLVM_PREFIX="$(brew --prefix llvm)"
MODULES_JSON="$(find "$LLVM_PREFIX/lib" -name 'libc++.modules.json' -print -quit)"
if [ -z "$MODULES_JSON" ]; then
echo "Error: libc++.modules.json not found under $LLVM_PREFIX/lib"
exit 1
fi
echo "Using $MODULES_JSON"
LIBCXX_LDFLAGS="-L$LLVM_PREFIX/lib/c++ -Wl,-rpath,$LLVM_PREFIX/lib/c++ -L$LLVM_PREFIX/lib/unwind -Wl,-rpath,$LLVM_PREFIX/lib/unwind -lunwind"
cmake -S . -B build \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_STDLIB_MODULES_JSON="$MODULES_JSON" \
-DCMAKE_EXE_LINKER_FLAGS="$LIBCXX_LDFLAGS" \
-DCMAKE_SHARED_LINKER_FLAGS="$LIBCXX_LDFLAGS" \
-DCMAKE_MODULE_LINKER_FLAGS="$LIBCXX_LDFLAGS" \
-DCMAKE_CXX_COMPILER=$LLVM_PREFIX/bin/clang++ \
-DCMAKE_C_COMPILER=$(brew --prefix llvm)/bin/clang \
-DCPR_BUILD_MODULES=ON \
-DCPR_BUILD_TESTS=ON \
-DCPR_BUILD_TESTS_SSL=OFF \
-DCPR_USE_SYSTEM_LIB_PSL=ON \
-G Ninja
- name: Build
run: cmake --build build --verbose
- name: Test
run: ctest --test-dir build --output-on-failure --repeat until-pass:5
- name: Verify Module Build
# Running the 'import cpr;' example proves the module compiled and imports.
run: ./build/bin/cpr_module_example
Loading
Loading