-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
64 lines (48 loc) · 2.29 KB
/
CMakeLists.txt
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
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
find_program(CCACHE_PROGRAM ccache)
if (CCACHE_PROGRAM)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
endif()
set(CPP_ORDERBOOK orderbook)
project(${CPP_ORDERBOOK} LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_THREAD_LIBS_INIT "-lpthread")
set(CMAKE_HAVE_THREADS_LIBRARY ON)
set(CMAKE_USE_PTHREADS_INIT ON)
set(THREADS_PREFER_PTHREAD_FLAG ON)
set(PROJECT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
option(ENABLE_TESTING "Enable test target generation" OFF)
add_executable (main main.cpp)
set(CPM_USE_LOCAL_PACKAGES ON)
include(cmake/CPM.cmake)
CPMUsePackageLock(package-lock.cmake)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
CPMAddPackage( NAME Boost VERSION 1.80.0 GITHUB_REPOSITORY "boostorg/boost" GIT_TAG "boost-1.80.0")
CPMAddPackage( NAME decimal VERSION 2.1.0 GITHUB_REPOSITORY "geseq/cpp-decimal" GIT_TAG "v2.1.0")
CPMAddPackage( NAME pool VERSION 0.6.1 GITHUB_REPOSITORY "geseq/cpp-pool" GIT_TAG "v0.5.0")
include_directories(decimal_SOURCE_DIR)
include_directories(pool_SOURCE_DIR)
file(GLOB SOURCES "src/*.cpp")
include_directories(include)
add_library(${CPP_ORDERBOOK} STATIC ${SOURCES})
target_sources(${CPP_ORDERBOOK} INTERFACE include/orderbook.hpp)
target_include_directories(${CPP_ORDERBOOK} INTERFACE include/)
target_link_libraries(${CPP_ORDERBOOK} PRIVATE Boost::intrusive decimal pool)
if (ENABLE_TESTING)
CPMAddPackage( NAME googletest GITHUB_REPOSITORY google/googletest VERSION 1.14.0 )
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
include_directories(googletest_SOURCE_DIR)
enable_testing()
FILE(GLOB tests CONFIGURE_DEPENDS ${PROJECT_SOURCE_DIR}/test/*)
FOREACH (test ${tests})
get_filename_component(test_name ${test} NAME)
message("Adding test: " ${test_name})
add_executable(${test_name} ${SOURCES} ${PROJECT_SOURCE_DIR}/test/${test_name})
target_link_libraries(${test_name} PRIVATE ${CMAKE_THREAD_LIBS_INIT} ${CPP_ORDERBOOK} gtest gtest_main Boost::algorithm Boost::intrusive decimal pool)
add_test(${test_name} ${test_name})
set_property(TEST ${test_name} PROPERTY LABELS "test")
ENDFOREACH ()
endif()
target_link_libraries(main PRIVATE ${CPP_ORDERBOOK} Boost::intrusive decimal pool)