-
Notifications
You must be signed in to change notification settings - Fork 28
/
CMakeLists.txt
121 lines (93 loc) · 3.69 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
### CMake Version ##############################################################
cmake_minimum_required(VERSION 3.10)
### Project Configuration ######################################################
get_filename_component(PROJECT_DIR_NAME ${CMAKE_CURRENT_LIST_DIR} NAME)
string(REPLACE " " "_" PROJECT_DIR_NAME ${PROJECT_DIR_NAME})
project(${PROJECT_DIR_NAME}
VERSION 2.0.0 # <major>.<minor>.<patch>
LANGUAGES CXX)
set(LIB_NAME shift)
### List of Files ##############################################################
set(DEMO
${PROJECT_SOURCE_DIR}/demo/credentials.py
${PROJECT_SOURCE_DIR}/demo/demo.py
${PROJECT_SOURCE_DIR}/demo/FIX50SP2.xml
${PROJECT_SOURCE_DIR}/demo/FIXT11.xml
${PROJECT_SOURCE_DIR}/demo/goodcbfs.py
${PROJECT_SOURCE_DIR}/demo/initiator.cfg
${PROJECT_SOURCE_DIR}/demo/zitrader.py
)
set(INCLUDE
${PROJECT_SOURCE_DIR}/include/BestPrice.h
${PROJECT_SOURCE_DIR}/include/Common.h
${PROJECT_SOURCE_DIR}/include/Order.h
${PROJECT_SOURCE_DIR}/include/OrderBook.h
${PROJECT_SOURCE_DIR}/include/OrderBookEntry.h
${PROJECT_SOURCE_DIR}/include/PortfolioItem.h
${PROJECT_SOURCE_DIR}/include/PortfolioSummary.h
${PROJECT_SOURCE_DIR}/include/Trader.h
)
set(SRC
${PROJECT_SOURCE_DIR}/src/SHIFT.cpp
${PROJECT_SOURCE_DIR}/src/Trader.cpp
)
set(OTHER
${PROJECT_SOURCE_DIR}/setup.py
)
### Compiler Flags #############################################################
# Important for libraries
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# C++17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
add_definitions("-DHAVE_STD_UNIQUE_PTR=1") # QuickFIX C++17 compatibility req.
# Common Flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -fexceptions")
# Debug Flags
set(CMAKE_CXX_FLAGS_DEBUG "-g -DDEBUG")
# Release Flags
# -O2 instead of -O3
# -flto stands for Link Time Optimization (LTO)
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG -finline-functions -flto")
# GCC (Ubuntu 20.04 LTS Focal Fossa)
if(UNIX AND NOT APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
endif(UNIX AND NOT APPLE)
# GCC (Raspberry Pi OS)
# Ubuntu rules apply here as well
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "armv7l")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
endif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "armv7l")
# Clang (macOS 11 Big Sur)
if(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-overloaded-virtual")
include_directories(/usr/local/include)
endif(APPLE)
### Build Types ################################################################
# if no build type is set, the default is Release
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif(NOT CMAKE_BUILD_TYPE)
### Build Configuration ########################################################
find_package(pybind11 REQUIRED)
# Always enforce search for SHIFT LibCoreClient
# (necessary when using the same name for Debug and Release)
set (LIBCORECLIENT "LIBCORECLIENT-NOTFOUND")
if(CMAKE_BUILD_TYPE MATCHES Debug)
find_library(LIBCORECLIENT shift_coreclient-d)
endif(CMAKE_BUILD_TYPE MATCHES Debug)
if(CMAKE_BUILD_TYPE MATCHES Release)
find_library(LIBCORECLIENT shift_coreclient)
endif(CMAKE_BUILD_TYPE MATCHES Release)
if(NOT LIBCORECLIENT)
message(FATAL_ERROR "SHIFT LibCoreClient was not found.")
endif(NOT LIBCORECLIENT)
pybind11_add_module(${LIB_NAME}
${DEMO} ${INCLUDE} ${SRC} ${OTHER})
target_include_directories(${LIB_NAME}
PRIVATE ${CMAKE_PREFIX_PATH}/include
PRIVATE ${PROJECT_SOURCE_DIR}/include)
target_link_libraries(${LIB_NAME}
PRIVATE ${LIBCORECLIENT})
################################################################################