-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathCMakeLists.txt
151 lines (117 loc) · 6.72 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
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
cmake_minimum_required(VERSION 3.7)
project(orderbook VERSION 0.01 DESCRIPTION "Limit Order Book")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "-O3 -Wall")
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall")
set(SOURCE_FILES cpp/OrderBook.hpp cpp/veb.cpp cpp/veb.h cpp/vebBucketSet.hpp cpp/defaultBucketSet.hpp
cpp/PriceBucket.cpp cpp/PriceBucket.h cpp/Order.h cpp/PriceBucketManager.hpp )
set(LOBSTER_SOURCE_FILES cpp/lobster/AddOrderMsg.hpp cpp/lobster/MessageBase.cpp cpp/lobster/MessageBase.h
cpp/lobster/MsgParser.cpp cpp/lobster/MsgParser.h cpp/lobster/MsgFactory.cpp
cpp/lobster/MsgFactory.h cpp/lobster/CancelOrderMsg.hpp cpp/lobster/DeleteOrderMsg.hpp
cpp/lobster/OrderExecutedMsg.hpp cpp/lobster/AuctionTradeMsg.hpp cpp/lobster/TradeHaltMsg.hpp)
set(BATS_SOURCE_FILES cpp/bats/BATSUtil.h cpp/bats/BATSTradeBreakMsg.hpp cpp/bats/BATSTradeMsg.hpp
cpp/bats/BATSTradingStatusMsg.hpp cpp/bats/BATSOrderCancelMsg.hpp cpp/bats/BATSOrderExecutedMsg.hpp
cpp/bats/BATSRetailPriceImproveMsg.hpp cpp/bats/BATSMessageBase.cpp cpp/bats/BATSMessageBase.h
cpp/bats/BATSMsgFactory.cpp cpp/bats/BATSMsgFactory.h cpp/bats/BATSAddOrderMsg.hpp
cpp/bats/BATSAuctionSummaryMsg.hpp cpp/bats/BATSAuctionUpdateMsg.hpp cpp/bats/BATSPitchMsgParser.cpp
cpp/bats/BATSPitchMsgParser.h)
set(ALGOSEEK_SOURCE_FILES cpp/algoseek/MessageBase.h cpp/algoseek/MessageBase.cpp cpp/algoseek/AddOrderMsg.hpp
cpp/algoseek/MsgFactory.h cpp/algoseek/MsgFactory.cpp cpp/algoseek/MsgParser.h
cpp/algoseek/MsgParser.cpp cpp/algoseek/OrderExecutedMsg.hpp cpp/algoseek/CancelOrderMsg.hpp
cpp/algoseek/CrossMsg.hpp cpp/algoseek/AlgoseekUtils.h)
SET(ORDERBOOK_NET_API_SOURCE_FILES
cpp/net/client.h cpp/net/client.cpp cpp/Order.h cpp/net/server.cpp cpp/net/server.h)
SET(SIMPLE_CLIENT_SOURCE_FILES cpp/net/client.h cpp/net/client.cpp cpp/net/simple_client.cpp)
SET(SIMPLE_SERVER_SOURCE_FILES cpp/net/server.h cpp/net/server.cpp cpp/net/simple_server.cpp)
set(PYAPI_BATS_SOURCES cpp/bats/BATSPythonAPI.cpp)
set(PYAPI_LOB_SOURCES cpp/OrderBookPythonAPI.cpp)
message( STATUS "CMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}")
# figure out python paths
execute_process(COMMAND python-config "--prefix"
OUTPUT_VARIABLE PYTHON_PREFIX
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(PYTHON_INCLUDE_DIR "${PYTHON_PREFIX}/include/python2.7")
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(PYTHON_LIBRARY "${PYTHON_PREFIX}/lib/libpython2.7.dylib")
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(PYTHON_LIBRARY "${PYTHON_PREFIX}/lib/libpython2.7.so")
endif ()
message( STATUS "Generating global includes")
find_package(PythonLibs REQUIRED)
find_package(PythonInterp REQUIRED)
find_package(Boost COMPONENTS python27 iostreams unit_test_framework system
serialization thread REQUIRED)
include_directories (${PYTHON_INCLUDE_DIR} ${Boost_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/cpp ${CMAKE_SOURCE_DIR}/cpp/bats
${CMAKE_SOURCE_DIR}/cpp/lobster )
message( STATUS "Boost Boost_LIBRARIES=${Boost_LIBRARIES}")
message( STATUS "Boost Boost_PYTHON27_LIBRARIES=${Boost_PYTHON27_LIBRARIES}")
message( STATUS "Generating bats_pitch_parser library")
add_library(bats_pitch_parser SHARED ${BATS_SOURCE_FILES})
target_link_libraries(bats_pitch_parser ${Boost_LIBRARIES})
message( STATUS "Generating Python bats api library")
add_library(bats_api SHARED ${PYAPI_BATS_SOURCES})
# fix for osx. python only loads .so
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set_target_properties(bats_api PROPERTIES PREFIX "")
set_target_properties(bats_api PROPERTIES OUTPUT_NAME "bats_api")
set_target_properties(bats_api PROPERTIES SUFFIX ".so")
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set_target_properties(bats_api PROPERTIES PREFIX "")
endif()
target_link_libraries(bats_api bats_pitch_parser ${Boost_PYTHON27_LIBRARIES} ${PYTHON_LIBRARY})
message( STATUS "Generating Python orderbook api library")
add_library(orderbook_api SHARED ${PYAPI_LOB_SOURCES})
# fix for osx. python only loads .so
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set_target_properties(orderbook_api PROPERTIES PREFIX "")
set_target_properties(orderbook_api PROPERTIES OUTPUT_NAME "orderbook_api")
set_target_properties(orderbook_api PROPERTIES SUFFIX ".so")
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set_target_properties(orderbook_api PROPERTIES PREFIX "")
endif()
target_link_libraries(orderbook_api orderbook boost_system ${Boost_LIBRARIES} ${Boost_PYTHON27_LIBRARIES} ${PYTHON_LIBRARY} )
add_library(lobster SHARED ${LOBSTER_SOURCE_FILES})
add_library(algoseek SHARED ${ALGOSEEK_SOURCE_FILES})
add_library(orderbook SHARED ${SOURCE_FILES})
add_library(orderbook_net_api SHARED ${ORDERBOOK_NET_API_SOURCE_FILES})
target_link_libraries(orderbook_net_api orderbook boost_system
${Boost_LIBRARIES} ${Boost_PYTHON27_LIBRARIES} ${PYTHON_LIBRARY} )
add_executable(simple_client ${SIMPLE_CLIENT_SOURCE_FILES})
target_link_libraries(simple_client ${Boost_LIBRARIES} orderbook )
add_executable(simple_server ${SIMPLE_SERVER_SOURCE_FILES})
target_link_libraries(simple_server ${Boost_LIBRARIES} orderbook )
enable_testing()
file(GLOB TEST_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} tests/*.cpp)
foreach(testSrc ${TEST_SRCS})
get_filename_component(testName ${testSrc} NAME_WE)
add_executable(${testName} ${testSrc})
target_link_libraries(${testName} ${Boost_LIBRARIES} ${PYTHON_LIBRARY} algoseek orderbook lobster bats_pitch_parser)
set_target_properties(${testName} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tests)
add_test(NAME ${testName}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tests
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/tests/${testName} )
endforeach(testSrc)
file(GLOB PY_TEST_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} tests/*.py)
foreach(pytestSrc ${PY_TEST_SRCS})
get_filename_component(pytestName ${pytestSrc} NAME_WE)
add_test(NAME ${pytestName}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tests
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/${pytestSrc} )
endforeach(pytestSrc)
set(PY_SO_FILES bats_api orderbook_api)
foreach(so_file ${PY_SO_FILES})
ADD_CUSTOM_COMMAND(
TARGET ${so_file}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_BINARY_DIR}/${so_file}.so
${CMAKE_CURRENT_BINARY_DIR}/tests/${so_file}.so )
endforeach(so_file)
set(TEST_FILES tests/AAPL_2012-06-21_message_50.csv tests/AAPL_2012-06-21_orderbook_50.csv
tests/pitch_data_100k tests/pitch_example_data tests/IBM.FullDepth.20140128.200k.csv
${PY_TEST_SRCS} )
foreach(testFile ${TEST_FILES})
configure_file(${testFile} ${testFile} COPYONLY)
endforeach(testFile)