Skip to content

Commit 03161d4

Browse files
author
Philemon Benner
committed
move oryx:: namespace
enhanced tests added proper install updated readme added automatic test pipeline
1 parent 0bc6d39 commit 03161d4

16 files changed

Lines changed: 7548 additions & 7406 deletions

.clangd

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
CompileFlags:
2+
CompilationDatabase: build
3+
Add:
4+
- -Wno-unknown-warning-option
5+
- -std=gnu++23
6+
- -Iinclude
7+
Remove: [-m*, -f*]
8+
Compiler: /usr/bin/gcc-14
9+
10+
Index:
11+
Background: Build
12+
StandardLibrary: true
13+
14+
Hover:
15+
ShowAKA: false
16+
17+
Completion:
18+
AllScopes: Yes
19+
20+
InlayHints:
21+
BlockEnd: false
22+
Designators: false
23+
Enabled: true
24+
ParameterNames: false
25+
DeducedTypes: false
26+
TypeNameLimit: 24
27+
28+
Diagnostics:
29+
UnusedIncludes: Strict
30+
ClangTidy:
31+
FastCheckFilter: Strict
32+
Add:
33+
- modernize-*
34+
- performance-*
35+
- bugprone-use-after-move
36+
Remove:
37+
- modernize-avoid-c-arrays

.github/workflows/linux.yaml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: linux
2+
3+
on: [ push, pull_request ]
4+
5+
jobs:
6+
linux:
7+
strategy:
8+
fail-fast: false
9+
matrix:
10+
include:
11+
- compiler: llvm
12+
compiler-version: 18
13+
cxx: 23
14+
- compiler: llvm
15+
compiler-version: 19
16+
cxx: 23
17+
- compiler: gcc
18+
compiler-version: 11
19+
cxx: 20
20+
- compiler: gcc
21+
compiler-version: 12
22+
cxx: 20
23+
- compiler: gcc
24+
compiler-version: 13
25+
cxx: 20
26+
- compiler: gcc
27+
compiler-version: 14
28+
cxx: 23
29+
name: "${{ github.job }} (C++${{ matrix.cxx }}-${{ matrix.compiler }}-${{ matrix.compiler-version }})"
30+
runs-on: ubuntu-24.04
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v4
34+
with:
35+
submodules: recursive
36+
fetch-depth: 0
37+
- name: Export GitHub Actions cache environment variables
38+
uses: actions/github-script@v7
39+
with:
40+
script: |
41+
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
42+
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
43+
- name: Setup ccache
44+
uses: hendrikmuhs/ccache-action@v1
45+
with:
46+
key: "${{ github.job }}-${{ matrix.compiler }}-${{ matrix.compiler-version }}"
47+
max-size: "2G"
48+
- name: Compile
49+
run: |
50+
if [[ "${{ matrix.compiler }}" == "llvm" ]]; then
51+
export CC=clang-${{ matrix.compiler-version }}
52+
export CXX=clang++-${{ matrix.compiler-version }}
53+
elif [[ "${{ matrix.compiler }}" == "gcc" ]]; then
54+
export CC=gcc-${{ matrix.compiler-version }}
55+
export CXX=g++-${{ matrix.compiler-version }}
56+
fi
57+
sudo ln -s $(which ccache) /usr/local/bin/$CC
58+
sudo ln -s $(which ccache) /usr/local/bin/$CXX
59+
$CXX --version
60+
cmake -B build -G Ninja -DCMAKE_CXX_STANDARD=${{ matrix.cxx }} -DORYX_CRT_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Release
61+
cmake --build build
62+
- name: Run tests
63+
run: |
64+
./build/kvdb-cpp_tests --success

.vscode/c_cpp_properties.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"configurations": [
33
{
4-
"name": "KeyValueDatabase",
4+
"name": "Linux",
55
"cppStandard": "c++20",
66
"compilerPath": "/usr/bin/g++",
77
"intelliSenseMode": "${default}",

.vscode/settings.json

Lines changed: 6 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,8 @@
11
{
2-
"files.associations": {
3-
"typeinfo": "cpp",
4-
"text_encoding": "cpp",
5-
"optional": "cpp",
6-
"array": "cpp",
7-
"atomic": "cpp",
8-
"bit": "cpp",
9-
"*.tcc": "cpp",
10-
"bitset": "cpp",
11-
"cctype": "cpp",
12-
"charconv": "cpp",
13-
"chrono": "cpp",
14-
"cinttypes": "cpp",
15-
"clocale": "cpp",
16-
"cmath": "cpp",
17-
"compare": "cpp",
18-
"concepts": "cpp",
19-
"condition_variable": "cpp",
20-
"csignal": "cpp",
21-
"cstdarg": "cpp",
22-
"cstddef": "cpp",
23-
"cstdint": "cpp",
24-
"cstdio": "cpp",
25-
"cstdlib": "cpp",
26-
"cstring": "cpp",
27-
"ctime": "cpp",
28-
"cwchar": "cpp",
29-
"cwctype": "cpp",
30-
"deque": "cpp",
31-
"map": "cpp",
32-
"set": "cpp",
33-
"string": "cpp",
34-
"unordered_map": "cpp",
35-
"unordered_set": "cpp",
36-
"vector": "cpp",
37-
"exception": "cpp",
38-
"algorithm": "cpp",
39-
"functional": "cpp",
40-
"iterator": "cpp",
41-
"memory": "cpp",
42-
"memory_resource": "cpp",
43-
"numeric": "cpp",
44-
"random": "cpp",
45-
"ratio": "cpp",
46-
"regex": "cpp",
47-
"string_view": "cpp",
48-
"system_error": "cpp",
49-
"tuple": "cpp",
50-
"type_traits": "cpp",
51-
"utility": "cpp",
52-
"fstream": "cpp",
53-
"initializer_list": "cpp",
54-
"iomanip": "cpp",
55-
"iosfwd": "cpp",
56-
"iostream": "cpp",
57-
"istream": "cpp",
58-
"limits": "cpp",
59-
"mutex": "cpp",
60-
"new": "cpp",
61-
"numbers": "cpp",
62-
"ostream": "cpp",
63-
"semaphore": "cpp",
64-
"span": "cpp",
65-
"sstream": "cpp",
66-
"stdexcept": "cpp",
67-
"stop_token": "cpp",
68-
"streambuf": "cpp",
69-
"thread": "cpp",
70-
"variant": "cpp",
71-
"format": "cpp"
72-
}
2+
"editor.formatOnSave": true,
3+
"cmake.configureOnOpen": false,
4+
"cmake.configureOnEdit": false,
5+
"clangd.path": "/usr/bin/clangd",
6+
"C_Cpp.clang_format_path": "/usr/bin/clang-format-18",
7+
"files.associations": {},
738
}

CMakeLists.txt

Lines changed: 81 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,115 @@
1-
cmake_minimum_required(VERSION 3.11...3.31)
1+
cmake_minimum_required(VERSION 3.24)
22

3-
project(kvdbcpp VERSION 0.0.0 LANGUAGES CXX)
3+
project(kvdb-cpp VERSION 0.1.0 LANGUAGES CXX)
44

5-
option(KVDB_ENABLE_TESTS "Build Tests" ON)
6-
option(KVDB_BUILD_DEPS "Build Dependencies from source" ON)
5+
option(ORYX_KVDB_ENABLE_TESTS "Build Tests" ON)
6+
option(ORYX_KVDB_BUILD_DEPS "Build Dependencies from source" ON)
77

8-
include(FetchContent)
9-
include(GNUInstallDirs)
8+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
9+
if(NOT DEFINED CMAKE_CXX_STANDARD)
10+
set(CMAKE_CXX_STANDARD 20)
11+
endif()
1012

13+
include(FetchContent)
1114

12-
if(KVDB_BUILD_DEPS)
15+
if(ORYX_KVDB_BUILD_DEPS)
1316
message(STATUS "Building deps from source")
1417

1518
FetchContent_Declare(
1619
reflectcpp
1720
GIT_REPOSITORY https://github.com/getml/reflect-cpp.git
18-
GIT_TAG v0.15.0
21+
GIT_TAG v0.19.0
1922
OVERRIDE_FIND_PACKAGE
20-
EXCLUDE_FROM_ALL
2123
)
2224

2325
FetchContent_Declare(
2426
leveldb
2527
GIT_REPOSITORY https://github.com/google/leveldb.git
26-
GIT_TAG 1.23
28+
GIT_TAG ac691084fdc5546421a55b25e7653d450e5a25fb
2729
OVERRIDE_FIND_PACKAGE
28-
EXCLUDE_FROM_ALL
2930
)
3031

32+
set(LEVELDB_BUILD_BENCHMARKS OFF)
33+
set(LEVELDB_BUILD_TESTS OFF)
3134
FetchContent_MakeAvailable(reflectcpp leveldb)
35+
36+
add_library(reflectcpp::reflectcpp ALIAS reflectcpp)
37+
add_library(leveldb::leveldb ALIAS leveldb)
38+
39+
install(TARGETS reflectcpp EXPORT ${PROJECT_NAME}-exports)
40+
install(TARGETS leveldb EXPORT ${PROJECT_NAME}-exports)
41+
else()
42+
find_package(reflectcpp CONFIG REQUIRED)
43+
find_package(leveldb CONFIG REQUIRED)
3244
endif()
3345

34-
find_package(reflectcpp)
35-
find_package(leveldb)
36-
3746
add_library(${PROJECT_NAME} INTERFACE)
3847
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
3948

4049
target_link_libraries(${PROJECT_NAME}
4150
INTERFACE
42-
reflectcpp
43-
leveldb
51+
reflectcpp::reflectcpp
52+
leveldb::leveldb
4453
)
4554

46-
if(KVDB_ENABLE_TESTS)
47-
set(test_exe ${PROJECT_NAME}_test)
48-
add_executable(${test_exe} test/main.cpp test/read_write.cpp)
55+
if(ORYX_KVDB_ENABLE_TESTS)
56+
set(test_exe ${PROJECT_NAME}_tests)
57+
add_executable(${test_exe}
58+
tests/main.cpp
59+
tests/read_write.cpp
60+
)
4961
target_link_libraries(${test_exe} PRIVATE ${PROJECT_NAME})
5062
endif()
5163

52-
53-
target_include_directories(${PROJECT_NAME}
54-
INTERFACE
55-
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
56-
"$<INSTALL_INTERFACE:include>"
64+
target_include_directories(${PROJECT_NAME} INTERFACE
65+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
66+
$<INSTALL_INTERFACE:include>
5767
)
5868

69+
target_compile_options(${PROJECT_NAME} INTERFACE $<$<CONFIG:Debug>:-Wall -Wextra>)
70+
71+
if(PROJECT_IS_TOP_LEVEL)
72+
include(GNUInstallDirs)
73+
include(CMakePackageConfigHelpers)
74+
75+
configure_package_config_file(
76+
cmake/${PROJECT_NAME}-config.cmake.in
77+
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
78+
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
79+
)
80+
81+
write_basic_package_version_file(
82+
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
83+
VERSION ${PROJECT_VERSION}
84+
COMPATIBILITY SameMajorVersion
85+
)
86+
87+
install(
88+
FILES
89+
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
90+
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
91+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
92+
)
93+
94+
file(GLOB_RECURSE KVDB_CPP_HEADERS RELATIVE ${CMAKE_CURRENT_LIST_DIR} "${CMAKE_CURRENT_LIST_DIR}/include/*")
95+
96+
target_sources(${PROJECT_NAME}
97+
PUBLIC
98+
FILE_SET kvdb_cpp_headers
99+
TYPE HEADERS
100+
BASE_DIRS $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
101+
FILES ${KVDB_CPP_HEADERS}
102+
)
103+
104+
install(
105+
TARGETS ${PROJECT_NAME}
106+
EXPORT ${PROJECT_NAME}-exports
107+
FILE_SET kvdb_cpp_headers DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
108+
)
109+
110+
install(
111+
EXPORT ${PROJECT_NAME}-exports
112+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
113+
NAMESPACE oryx::
114+
)
115+
endif()

README.md

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,22 @@ kvdb-cpp supports the following types:
1818

1919
- `std::string`
2020
- `bool`
21-
- `int`
22-
- `double`
23-
- `structs / classes`
21+
- `integral types`
22+
- `floating types`
23+
- `any that reflect cpp can serialize beyond that`
2424

25-
## Roadmap
25+
## Build locally
2626

27-
- Examples
28-
- Add cmake support
29-
- Docs
27+
```bash
28+
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DCMAKE_BUILD_TYPE=Debug -Bbuild -H.
29+
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
30+
Only needed for clangd
31+
```
32+
33+
```bash
34+
cmake --build build -j32
35+
```
36+
37+
## Todo
38+
39+
- Fix install for reflect-cpp

cmake/kvdb-cpp-config.cmake.in

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@PACKAGE_INIT@
2+
3+
include(${CMAKE_CURRENT_LIST_DIR}/kvdb-cpp-exports.cmake)
4+
5+
find_dependency(reflectcpp)
6+
find_dependency(leveldb)
7+
8+
check_required_components(kvdb-cpp)

0 commit comments

Comments
 (0)