Skip to content

Commit

Permalink
Use conan
Browse files Browse the repository at this point in the history
  • Loading branch information
hit9 committed Apr 29, 2024
1 parent dd5e29e commit 4984cea
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 16 deletions.
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ jobs:
working-directory: ${{runner.workspace}}/build
run: >
cmake -B . -S ${{ github.workspace }}
-DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ build
*.s
ctp
Testing
CMakeUserPresets.json
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
default: build

install-deps:
conan install . --output-folder=build --build=missing -s compiler.cppstd=20 -s build_type=Release

build:
cmake -S . -B build
cmake -S . -B build \
-DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_TESTS=1
make -C build

tests: build
./build/tests/tests
ctest --test-dir ./build/tests --output-on-failure

lint:
cppcheck compile_time_regexp.h --enable=warning,style,performance,portability --inline-suppr --language=c++

clean:
rm -rf build

.PHONY: build lint clean install-deps
4 changes: 2 additions & 2 deletions compile_time_regexp.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct hash {
template <>
struct hash<char> {
constexpr uint32_t operator()(char v) const {
char s[1] = {v};
const char s[1] = {v};
return fnv32(s, 1);
}
};
Expand Down Expand Up @@ -565,7 +565,7 @@ class State {

template <>
struct hash<State *> {
constexpr uint32_t operator()(State *st) const {
constexpr uint32_t operator()(const State *st) const {
return hash<uint32_t>{}(st->Id());
}
};
Expand Down
6 changes: 6 additions & 0 deletions conanfile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[requires]
catch2/[>=3.2.0]

[generators]
CMakeDeps
CMakeToolchain
13 changes: 1 addition & 12 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,7 @@ enable_testing()

include_directories("..")

# Find or Download package Catch 2
include(FetchContent)
set(FETCHCONTENT_QUIET FALSE)
FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.4.0 # or a later release
GIT_PROGRESS TRUE
FIND_PACKAGE_ARGS NAMES Catch2)

FetchContent_MakeAvailable(Catch2)
list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras)
find_package(Catch2 CONFIG REQUIRED)

if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-fconstexpr-steps=1000000000)
Expand Down

0 comments on commit 4984cea

Please sign in to comment.