Skip to content

Commit 948b7ce

Browse files
authored
C++20 Support (#31)
1 parent 21d9f06 commit 948b7ce

File tree

9 files changed

+371
-246
lines changed

9 files changed

+371
-246
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: CMake on multiple platforms
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
build:
11+
runs-on: ${{ matrix.os }}
12+
13+
strategy:
14+
# 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.
15+
fail-fast: false
16+
17+
# Set up a matrix to run the following 3 configurations:
18+
# 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator>
19+
# 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator>
20+
# 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator>
21+
#
22+
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
23+
matrix:
24+
os: [ubuntu-latest, windows-latest]
25+
build_type: [Release]
26+
c_compiler: [gcc, clang, cl]
27+
include:
28+
- os: windows-latest
29+
c_compiler: cl
30+
cpp_compiler: cl
31+
- os: ubuntu-latest
32+
c_compiler: gcc
33+
cpp_compiler: g++
34+
- os: ubuntu-latest
35+
c_compiler: clang
36+
cpp_compiler: clang++
37+
exclude:
38+
- os: windows-latest
39+
c_compiler: gcc
40+
- os: windows-latest
41+
c_compiler: clang
42+
- os: ubuntu-latest
43+
c_compiler: cl
44+
45+
steps:
46+
- uses: actions/checkout@v4
47+
48+
- name: Set reusable strings
49+
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
50+
id: strings
51+
shell: bash
52+
run: |
53+
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
54+
55+
- name: Cache
56+
uses: actions/[email protected]
57+
with:
58+
# A list of files, directories, and wildcard patterns to cache and restore
59+
path: "/home/runner/work/clay/clay/build/_deps"
60+
# An explicit key for restoring and saving the cache
61+
key: "_deps"
62+
63+
- name: Install Dependencies
64+
if: runner.os == 'Linux'
65+
run: |
66+
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y git
67+
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y libwayland-dev
68+
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y pkg-config
69+
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y libxkbcommon-dev
70+
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y xorg-dev
71+
72+
73+
- name: Configure CMake
74+
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
75+
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
76+
run: >
77+
cmake -B ${{ steps.strings.outputs.build-output-dir }}
78+
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
79+
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
80+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
81+
-S ${{ github.workspace }}
82+
83+
- name: Build
84+
# 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).
85+
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
86+
87+
- name: Test
88+
working-directory: ${{ steps.strings.outputs.build-output-dir }}
89+
# 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).
90+
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
91+
run: ctest --build-config ${{ matrix.build_type }}

CMakeLists.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
cmake_minimum_required(VERSION 3.28)
2-
project(clay C)
2+
project(clay)
33

4-
set(CMAKE_C_STANDARD 99)
4+
add_subdirectory("examples/cpp-project-example")
55

6+
# Don't try to compile C99 projects using MSVC
7+
if(NOT MSVC)
68
add_subdirectory("examples/raylib-sidebar-scrolling-container")
7-
add_subdirectory("examples/clay-official-website")
9+
add_subdirectory("examples/clay-official-website")
10+
endif()

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,13 +394,15 @@ The supported directives are:
394394
- `CLAY_EXTEND_CONFIG_IMAGE` - Provide additional struct members to `CLAY_IMAGE_CONFIG` that will be passed through with output render commands.
395395
- `CLAY_EXTEND_CONFIG_CUSTOM` - Provide additional struct members to `CLAY_IMAGE_CONFIG` that will be passed through with output render commands.
396396

397-
### Bindings
397+
### Bindings for non C
398398

399-
Clay is usable out of the box as a `.h` include in both C99 and C++ with designated initializer support.
399+
Clay is usable out of the box as a `.h` include in both C99 and C++20 with designated initializer support.
400400
There are also supported bindings for other languages, including:
401401

402402
- [Odin Bindings](https://github.com/nicbarker/clay/tree/main/bindings/odin)
403403

404+
Unfortunately clay does **not** support Microsoft C11 or C17 via MSVC at this time.
405+
404406
### Debug Tools
405407

406408
Clay includes built-in UI debugging tools, similar to the "inspector" in browsers such as Chrome or Firefox. These tools are included in `clay.h`, and work by injecting additional render commands into the output [Clay_RenderCommandArray](#clay_rendercommandarray).

0 commit comments

Comments
 (0)