-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
91 lines (79 loc) · 3.35 KB
/
Copy pathCMakeLists.txt
File metadata and controls
91 lines (79 loc) · 3.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
cmake_minimum_required(VERSION 3.24)
if(POLICY CMP0135)
cmake_policy(SET CMP0135 NEW)
endif()
project(nanobook
VERSION 0.1.0
DESCRIPTION "Nasdaq TotalView-ITCH 5.0 feed handler and limit order book engine"
LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
option(NANOBOOK_BUILD_TESTS "Build unit tests" ON)
option(NANOBOOK_BUILD_BENCHMARKS "Build micro-benchmark targets" ON)
# Enabled by the release preset only; never set for debug or sanitizer builds.
option(NANOBOOK_NATIVE_ARCH "Tune optimized builds for the host CPU" OFF)
# Warnings apply to nanobook targets only, never to fetched dependencies.
add_library(nanobook_warnings INTERFACE)
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
target_compile_options(nanobook_warnings INTERFACE
-Wall
-Wextra
-Wpedantic
-Wshadow
-Wnon-virtual-dtor
-Wcast-align
-Wformat=2)
endif()
# Host-CPU tuning for optimized builds. The canonical flag on Linux x86-64 is
# -march=native for both GCC and Clang. Some AArch64 toolchains accept only
# -mcpu=native, so probe and fall back rather than fail; the primary benchmark
# platform remains Linux x86-64 (docs/product_spec.md, section 1).
if(NANOBOOK_NATIVE_ARCH)
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-march=native" NANOBOOK_HAS_MARCH_NATIVE)
if(NANOBOOK_HAS_MARCH_NATIVE)
add_compile_options(-march=native)
else()
check_cxx_compiler_flag("-mcpu=native" NANOBOOK_HAS_MCPU_NATIVE)
if(NANOBOOK_HAS_MCPU_NATIVE)
add_compile_options(-mcpu=native)
else()
message(WARNING "Neither -march=native nor -mcpu=native is supported; build is not host-tuned")
endif()
endif()
endif()
# Header-only for now; sources may be added as the engine grows.
add_library(nanobook INTERFACE)
add_library(nanobook::nanobook ALIAS nanobook)
target_include_directories(nanobook INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_compile_features(nanobook INTERFACE cxx_std_20)
add_executable(nanobook_cli src/main.cpp)
set_target_properties(nanobook_cli PROPERTIES OUTPUT_NAME nanobook)
target_link_libraries(nanobook_cli PRIVATE nanobook::nanobook nanobook_warnings)
add_executable(itch_synth tools/itch_synth.cpp)
target_link_libraries(itch_synth PRIVATE nanobook::nanobook nanobook_warnings)
# Dependencies: GoogleTest and Google Benchmark only, via FetchContent.
# Adding anything else requires an explicit decision (docs/product_spec.md, section 11).
include(FetchContent)
if(NANOBOOK_BUILD_TESTS)
set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)
FetchContent_Declare(googletest
URL https://github.com/google/googletest/archive/refs/tags/v1.15.2.tar.gz
URL_HASH SHA256=7b42b4d6ed48810c5362c265a17faebe90dc2373c885e5216439d37927f02926)
FetchContent_MakeAvailable(googletest)
enable_testing()
add_subdirectory(tests)
endif()
if(NANOBOOK_BUILD_BENCHMARKS)
set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "" FORCE)
set(BENCHMARK_ENABLE_GTEST_TESTS OFF CACHE BOOL "" FORCE)
set(BENCHMARK_ENABLE_INSTALL OFF CACHE BOOL "" FORCE)
set(BENCHMARK_ENABLE_WERROR OFF CACHE BOOL "" FORCE)
FetchContent_Declare(benchmark
URL https://github.com/google/benchmark/archive/refs/tags/v1.9.5.tar.gz
URL_HASH SHA256=9631341c82bac4a288bef951f8b26b41f69021794184ece969f8473977eaa340)
FetchContent_MakeAvailable(benchmark)
add_subdirectory(bench)
endif()