Skip to content
Draft
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
117 changes: 117 additions & 0 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform.
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml
name: Multiplatform Build

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:
runs-on: ${{ matrix.runner }}
strategy:
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
fail-fast: false

# Set up a matrix to run the following 3 configurations:
# 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator>
# 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator>
# 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator>
#
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
matrix:
runner: [ubuntu-26.04, windows-2025-vs2026]
build_type: [Release]
c_compiler: [gcc, clang-22, cl]
include:
- runner: windows-2025-vs2026
os: Windows
c_compiler: cl
cpp_compiler: cl
- runner: ubuntu-26.04
c_compiler: gcc
cpp_compiler: g++
- runner: ubuntu-26.04
c_compiler: clang-22
cpp_compiler: clang++-22
exclude:
- runner: windows-2025-vs2026
c_compiler: gcc
- runner: windows-2025-vs2026
c_compiler: clang-22
- runner: ubuntu-26.04
c_compiler: cl

steps:
- uses: actions/checkout@v4

- name: Install libc++ for Clang
if: matrix.c_compiler == 'clang-22'
run: |
sudo apt-get update
sudo apt-get install -y libc++-22-dev libc++abi-22-dev

- name: Set reusable strings
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"

- name: Create Conan Dependencies Profile
shell: bash
run: |
cat << EOF > profile.txt
[settings]
arch=x86_64
os=$RUNNER_OS
compiler=$(sed 's/-[0-9][0-9]*$//' <<< "${{ matrix.c_compiler }}")
compiler.version=$(${{ matrix.c_compiler }} -dumpversion | cut -d. -f1)
compiler.cppstd=23
$([[ "${{ matrix.c_compiler }}" == "gcc" ]] && echo "compiler.libcxx=libstdc++11" || echo "compiler.libcxx=libc++")

[buildenv]
CC=${{ matrix.c_compiler }}
CXX=${{ matrix.cpp_compiler }}

[conf]
tools.cmake.cmaketoolchain:generator=Ninja Multi-Config
tools.cmake.cmake_layout:build_folder_vars=['settings.compiler', 'settings.arch']
EOF

- name: Install Conan
run: |
pip install conan==2.29.0
conan profile detect

- name: Configure Conan Dependencies
run: >
conan install
-of "${{ steps.strings.outputs.build-output-dir }}"
-s build_type=${{ matrix.build_type }}
-b=missing
-pr=profile.txt
"${{ github.workspace }}/conanfile.txt"

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
--preset=conan-$(sed 's/-[0-9][0-9]*$//' <<< "${{ matrix.c_compiler }}")-x86_64
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-S ${{ github.workspace }}

- name: Build
# 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).
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}

- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest --preset=conan-$(sed 's/-[0-9][0-9]*$//' <<< "${{ matrix.c_compiler }}")-x86_64-release
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ if (CMAKE_VERSION VERSION_LESS "4.0.3")
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "a9e1cf81-9932-4810-974b-6eccaf14e457")
elseif (CMAKE_VERSION VERSION_LESS "4.3.0")
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "d0edc3af-4c50-42ea-a356-e2862fe7a444")
else()
elseif (CMAKE_VERSION VERSION_LESS "4.4.0")
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "451f2fe2-a8a2-47c3-bc32-94786d8fc91b")
else()
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "f35a9ac6-8463-4d38-8eec-5d6008153e7d")
endif()

# Project + Language
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ cmake -B build/clang --preset=conan-clang-x86_64
# build
cmake --build build/clang --config Release -j8
# test
ctest -C Release --test-dir build/clang --no-compress-output --verbose
ctest -preset=${CONAN_PROFILE} --no-compress-output --verbose
```

### GNU
Expand All @@ -115,7 +115,7 @@ cmake -B build/gcc --preset=conan-gcc-x86_64
# build
cmake --build build/gcc --config Release -j8
# test
ctest -C Release --test-dir build/gcc --no-compress-output --verbose
ctest -preset=${CONAN_PROFILE} --no-compress-output --verbose
```

## Dockerfile
Expand Down
1 change: 0 additions & 1 deletion targets/cpp-deps-modules/libcxx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ target_compile_definitions(${TARGET_NAME} PRIVATE _LIBCPP_HAS_WIDE_CHARACTERS=1)
target_compile_definitions(${TARGET_NAME} PRIVATE _LIBCPP_HAS_THREADS=1)
target_compile_definitions(${TARGET_NAME} PRIVATE _LIBCPP_HAS_RANDOM_DEVICE=1)

FILE(GLOB_RECURSE SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cppm)
target_sources(${TARGET_NAME} PUBLIC
FILE_SET CXX_MODULES
BASE_DIRS
Expand Down
Loading