Skip to content

Commit 1c50b16

Browse files
committed
Enable ASAN and clang-tidy options
1 parent 50c6d14 commit 1c50b16

File tree

13 files changed

+132
-1
lines changed

13 files changed

+132
-1
lines changed

.clang-tidy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Checks: '-*,bugprone-*,performance-*,modernize-*'
2+
WarningsAsErrors: ''
3+
HeaderFilterRegex: 'src/.*'

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,6 @@
3939

4040
# debug information files
4141
*.dwo
42+
43+
# Build directories
44+
/build/

CMakeLists.txt

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
cmake_minimum_required(VERSION 3.25)
2+
project(ExchangeSimulator VERSION 0.1 LANGUAGES CXX)
3+
4+
set(CMAKE_CXX_STANDARD 23)
5+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
6+
set(CMAKE_CXX_EXTENSIONS OFF)
7+
8+
option(ENABLE_ASAN "Enable AddressSanitizer" OFF)
9+
if(ENABLE_ASAN)
10+
if(MSVC)
11+
add_compile_options(/fsanitize=address)
12+
add_link_options(/fsanitize=address)
13+
else()
14+
add_compile_options(-fsanitize=address -fno-omit-frame-pointer)
15+
add_link_options(-fsanitize=address)
16+
endif()
17+
endif()
18+
19+
option(ENABLE_CLANG_TIDY "Enable clang-tidy analysis" OFF)
20+
if(ENABLE_CLANG_TIDY)
21+
find_program(CLANG_TIDY_EXE NAMES clang-tidy)
22+
if(CLANG_TIDY_EXE)
23+
set(CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY_EXE})
24+
else()
25+
message(WARNING "clang-tidy requested but executable not found")
26+
endif()
27+
endif()
28+
29+
include(FetchContent)
30+
FetchContent_Declare(
31+
spdlog
32+
GIT_REPOSITORY https://github.com/gabime/spdlog.git
33+
GIT_TAG v1.12.0
34+
)
35+
FetchContent_MakeAvailable(spdlog)
36+
37+
add_subdirectory(src)
38+
39+
# Tests
40+
option(BUILD_TESTING "Build tests" ON)
41+
if(BUILD_TESTING)
42+
enable_testing()
43+
add_subdirectory(tests)
44+
endif()

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,19 @@
1-
# ExchangeSimulator
1+
# ExchangeSimulator
2+
3+
A cross-platform exchange matching engine simulator written in modern C++23.
4+
5+
## Building
6+
7+
```bash
8+
cmake -S . -B build
9+
cmake --build build
10+
```
11+
12+
Pass optional flags to enable developer tooling:
13+
14+
```bash
15+
cmake -S . -B build -DENABLE_ASAN=ON # AddressSanitizer
16+
cmake -S . -B build -DENABLE_CLANG_TIDY=ON # clang-tidy analysis
17+
```
18+
19+
Requires the [spdlog](https://github.com/gabime/spdlog) library to be available to the build system.

docs/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# ExchangeSimulator Documentation
2+
3+
Documentation will be added here.

src/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
add_library(core INTERFACE)
2+
target_include_directories(core INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/core)
3+
target_link_libraries(core INTERFACE spdlog::spdlog)
4+
5+
add_library(engine INTERFACE)
6+
target_include_directories(engine INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/engine)
7+
8+
add_executable(exchange_simulator sim/main.cpp)
9+
target_link_libraries(exchange_simulator PRIVATE core engine)

src/core/logger.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#pragma once
2+
3+
#include <spdlog/spdlog.h>
4+
#include <string_view>
5+
6+
namespace es {
7+
8+
inline void info(std::string_view msg) {
9+
spdlog::info("{}", msg);
10+
}
11+
12+
} // namespace es

src/engine/matching_engine.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#pragma once
2+
3+
namespace es {
4+
class MatchingEngine {
5+
public:
6+
void run();
7+
};
8+
}

src/exchanges/cme/adapter.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#pragma once
2+
3+
namespace es::cme {
4+
class Adapter {
5+
public:
6+
void connect();
7+
};
8+
}

src/exchanges/eurex/adapter.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#pragma once
2+
3+
namespace es::eurex {
4+
class Adapter {
5+
public:
6+
void connect();
7+
};
8+
}

0 commit comments

Comments
 (0)