Skip to content

Setup CMake and CI #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 18, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
31 changes: 31 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
Language: Cpp
BasedOnStyle: LLVM
AlwaysBreakTemplateDeclarations: Yes
BreakBeforeBraces: Attach
ColumnLimit: 160
SpaceAfterTemplateKeyword: true
Standard: c++20
TabWidth: 4
IndentWidth: 4
UseTab: Always
AllowShortEnumsOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
AllowShortLambdasOnASingleLine: All
AllowShortBlocksOnASingleLine: Always
AllowShortIfStatementsOnASingleLine: Always
AllowShortLoopsOnASingleLine: true
IndentRequires: true
IncludeCategories:
# Headers in <> with .h extension.
- Regex: '<([A-Za-z0-9\/-_])+\.h>'
Priority: 10
# Headers in <> with .hpp extension.
- Regex: '<([A-Za-z0-9\/-_])+\.hpp>'
Priority: 20
# Headers in <> without extension.
- Regex: '<([A-Za-z0-9\/-_])+>'
Priority: 30
PointerAlignment: Left
QualifierAlignment: Right
22 changes: 22 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
Checks: 'clang-analyzer-*,
concurrency-*,
cppcoreguidelines-*,
-cppcoreguidelines-non-private-member-variables-in-classes,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-avoid-const-or-ref-data-members,
-cppcoreguidelines-avoid-do-while,
misc-*,
-misc-non-private-member-variables-in-classes,
-misc-no-recursion,
modernize-*,
-modernize-use-trailing-return-type,
performance-*,
portability-*,
readability-*,
-readability-identifier-length,
-readability-implicit-bool-conversion,
-readability-magic-numbers,
-readability-redundant-member-init,
-readability-uppercase-literal-suffix'
...
19 changes: 19 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[*]
insert_final_newline = true
charset = utf-8
indent_size = 4
indent_style = tab
# Optional: git will commit as lf, this will only affect local files
end_of_line = lf

[*.{py,md,yml,sh,cmake,json}]
indent_style = space
indent_size = 2

[*.{py,md,yml,sh,cmake,json}.in]
indent_style = space
indent_size = 2

[CMakeLists.txt]
indent_style = space
indent_size = 2
105 changes: 105 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: ci-pr
on: [pull_request, workflow_dispatch]
jobs:
x64-linux-gcc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: init
run: uname -m; sudo apt install -yqq ninja-build
- name: configure
run: cmake -S . --preset=ninja-gcc -B build -DCMAKE_C_COMPILER=gcc-14 -DCMAKE_CXX_COMPILER=g++-14
- name: build debug
run: cmake --build build --config=Debug -- -v
- name: build release
run: cmake --build build --config=Release -- -v
- name: test debug
run: cd build && ctest -V -C Debug
- name: test release
run: cd build && ctest -V -C Release
x64-linux-clang:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: init
run: |
uname -m
sudo apt update -yqq && sudo apt install -yqq clang-19 ninja-build
sudo update-alternatives --remove-all clang++
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-19 10
- name: configure
run: cmake -S . --preset=ninja-clang -B build
- name: build debug
run: cmake --build build --config=Debug -- -v
- name: build release
run: cmake --build build --config=Release -- -v
- name: test debug
run: cd build && ctest -V -C Debug
- name: test release
run: cd build && ctest -V -C Release
arm64-linux-gcc:
runs-on: ubuntu-24.04-arm
steps:
- uses: actions/checkout@v4
- name: init
run: uname -m
- name: configure
run: cmake -S . --preset=ninja-gcc -B build -DCMAKE_C_COMPILER=gcc-14 -DCMAKE_CXX_COMPILER=g++-14
- name: build debug
run: cmake --build build --config=Debug -- -v
- name: build release
run: cmake --build build --config=Release -- -v
- name: test debug
run: cd build && ctest -V -C Debug
- name: test release
run: cd build && ctest -V -C Release
arm64-linux-clang:
runs-on: ubuntu-24.04-arm
steps:
- uses: actions/checkout@v4
- name: init
run: |
uname -m
sudo apt update -yqq && sudo apt install -yqq clang-19 ninja-build
sudo update-alternatives --remove-all clang++
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-19 10
- name: configure
run: cmake -S . --preset=ninja-clang -B build
- name: build debug
run: cmake --build build --config=Debug -- -v
- name: build release
run: cmake --build build --config=Release -- -v
- name: test debug
run: cd build && ctest -V -C Debug
- name: test release
run: cd build && ctest -V -C Release
x64-windows-vs22:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: configure
run: cmake -S . --preset=vs22 -B build
- name: build debug
run: cmake --build build --config=Debug --parallel
- name: build release
run: cmake --build build --config=Release --parallel
- name: test debug
run: cd build && ctest -V -C Debug
- name: test release
run: cd build && ctest -V -C Release
x64-windows-clang:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: init
run: choco install ninja
- name: configure
run: cmake -S . --preset=ninja-clang -B clang
- name: build debug
run: cmake --build clang --config=Debug -- -v
- name: build release
run: cmake --build clang --config=Release -- -v
- name: test debug
run: cd clang && ctest -V -C Debug
- name: test release
run: cd clang && ctest -V -C Release
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,13 @@
/Test/out/build/x64-debug
/cppjson/out/build/x64-debug
/out/build/x64-Debug

# clangd
/.cache
compile_commands.json

# CMake presets
CMakeUserPresets.json

# CMake build output
/out
21 changes: 18 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
cmake_minimum_required (VERSION 3.8)
cmake_minimum_required(VERSION 3.24)

add_subdirectory("cppjson")
add_subdirectory("Test")
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_DEBUG_POSTFIX "-d")

include(version.cmake)

project(cppjson VERSION ${cppjson_version})

option(CPPJSON_BUILD_TESTS "Build cppjson tests" ${PROJECT_IS_TOP_LEVEL})

add_subdirectory(cppjson)

if(CPPJSON_BUILD_TESTS)
enable_testing()
add_subdirectory(Test)
endif()
Loading