1- cmake_minimum_required (VERSION 3.14 )
2- project (TradingEngine )
1+ cmake_minimum_required (VERSION 3.16 )
2+ project (LowLatencyMatchingEngine LANGUAGES CXX )
33
44set (CMAKE_CXX_STANDARD 17)
5+ set (CMAKE_CXX_STANDARD_REQUIRED ON )
6+ set (CMAKE_CXX_EXTENSIONS OFF )
57
6- include (FetchContent )
7- FetchContent_Declare (
8- prometheus-cpp
9- GIT_REPOSITORY https://github.com/jupp0r/prometheus-cpp.git
10- GIT_TAG v1.1.0
8+ option (LLX_ENABLE_LTO "Enable link-time optimization" ON )
9+ option (LLX_ENABLE_NATIVE "Enable -march=native for local benchmarking" OFF )
10+
11+ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang" )
12+ add_compile_options (
13+ -Wall
14+ -Wextra
15+ -Wpedantic
16+ -Wconversion
17+ -Wshadow
18+ -Wnon-virtual-dtor
19+ -O3
20+ )
21+
22+ if (LLX_ENABLE_NATIVE)
23+ add_compile_options (-march=native )
24+ endif ()
25+
26+ if (LLX_ENABLE_LTO)
27+ add_compile_options (-flto )
28+ add_link_options (-flto )
29+ endif ()
30+ endif ()
31+
32+ add_library (llx_core
33+ src/book/ladder_book.cpp
34+ src/core/matching_engine.cpp
1135)
12- set (ENABLE_TESTING OFF CACHE BOOL "" FORCE )
13- set (ENABLE_PUSH OFF CACHE BOOL "" FORCE )
14- FetchContent_MakeAvailable (prometheus-cpp)
1536
16- include_directories (include )
37+ target_include_directories (llx_core PUBLIC include )
38+ target_compile_features (llx_core PUBLIC cxx_std_17 )
39+ target_link_libraries (llx_core PUBLIC pthread )
40+
41+ add_executable (llx_bench apps/bench_main.cpp )
42+ target_link_libraries (llx_bench PRIVATE llx_core )
43+
44+ add_executable (llx_replay apps/replay_main.cpp )
45+ target_link_libraries (llx_replay PRIVATE llx_core )
1746
18- add_executable (engine src/main.cpp src/order_book .cpp )
19- target_link_libraries (engine PRIVATE prometheus-cpp::core prometheus-cpp::pull z )
47+ add_executable (llx_tests apps/tests_main .cpp )
48+ target_link_libraries (llx_tests PRIVATE llx_core )
0 commit comments