Skip to content

Commit a6ffa6d

Browse files
authored
Let's try 2022 in C++ (#2)
* update template * starting * ci * caching * debugginh * debugginh * debugginh * copying * workingish * adding template * Update README.md
1 parent d1e983b commit a6ffa6d

33 files changed

+637
-1685
lines changed

.clang-format

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
BasedOnStyle: Google

.github/workflows/bench.yml.off

Lines changed: 0 additions & 24 deletions
This file was deleted.

.github/workflows/tests.yml

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,30 @@
11
name: Tests
2+
23
on:
34
push:
4-
branches: [main]
5-
pull_request:
65
branches:
6+
- main
7+
tags:
8+
- "*"
9+
pull_request:
710

811
jobs:
912
test:
10-
name: Cargo ${{ matrix.command }}
13+
name: Tests
1114
runs-on: ubuntu-latest
12-
strategy:
13-
matrix:
14-
command:
15-
- test --all
16-
- fmt --all -- --check
17-
- clippy -- -D warnings
1815
steps:
1916
- name: Checkout
2017
uses: actions/checkout@v3
21-
- name: Cache cargo directories
18+
- name: Cache build artifacts
2219
uses: actions/cache@v3
2320
with:
24-
path: |
25-
~/.cargo/bin/
26-
~/.cargo/registry/index/
27-
~/.cargo/registry/cache/
28-
~/.cargo/git/db/
29-
target/
30-
key: tests-${{ matrix.command }}-${{ hashFiles('**/Cargo.lock') }}
21+
path: build
22+
key: cmake-${{ hashFiles('**/CMakeLists.txt') }}
3123
restore-keys: |
32-
tests-${{ matrix.command }}-
33-
tests-
34-
- name: Run command
35-
run: cargo ${{ matrix.command }}
24+
cmake-
25+
- name: Compile
26+
run: |
27+
cmake -B build .
28+
cmake --build build --parallel 2
29+
- name: Test
30+
run: ctest --output-on-failure --test-dir build

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
/.aoc
22
/data
3-
/target
3+
build
4+
vscode-build
5+
src/2019

CMakeLists.txt

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
cmake_minimum_required(VERSION 3.18)
2+
project(AdventOfCode VERSION 0.2022.0 LANGUAGES CXX)
3+
include(CTest)
4+
5+
option(AOC_BUILD_TESTS "Enable building tests" ON)
6+
option(AOC_BUILD_REMOTE "Enable remote support" ON)
7+
8+
#
9+
# C++ standard
10+
#
11+
set(CMAKE_CXX_STANDARD 20)
12+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
13+
set(CMAKE_CXX_EXTENSIONS ON)
14+
15+
include_directories(include)
16+
17+
#
18+
# External dependencies
19+
#
20+
include(FetchContent)
21+
FetchContent_Declare(
22+
doctest
23+
GIT_REPOSITORY https://github.com/doctest/doctest.git
24+
GIT_TAG b7c21ec5ceeadb4951b00396fc1e4642dd347e5f
25+
)
26+
FetchContent_MakeAvailable(doctest)
27+
28+
FetchContent_Declare(
29+
cpr
30+
GIT_REPOSITORY https://github.com/libcpr/cpr.git
31+
GIT_TAG a2d35a1cb9f3f7e2f1469d6a189751331dc99f96
32+
)
33+
FetchContent_MakeAvailable(cpr)
34+
35+
#
36+
# Main interface
37+
#
38+
add_subdirectory(src)
39+
40+
#
41+
# Unit tests
42+
#
43+
if(AOC_BUILD_TESTS)
44+
message(STATUS "Building tests")
45+
add_subdirectory(tests)
46+
endif()

0 commit comments

Comments
 (0)