forked from pyth-network/pyth-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
150 lines (127 loc) · 3.66 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
cmake_minimum_required( VERSION 3.13 )
# project pyth-client
project( pyth-client )
# default build convention
if( NOT CMAKE_BUILD_TYPE )
set( CMAKE_BUILD_TYPE Release )
endif()
# use root directory as include
set( CMAKE_INCLUDE_CURRENT_DIR ON )
# find oracle header files
include_directories( program/src/ )
# gcc compiler/linker flags
add_compile_options( -ggdb -Wall -Wextra -Wsign-conversion -Werror -m64 )
set( CMAKE_CXX_FLAGS -std=c++11 )
set( CMAKE_C_FLAGS -std=c99 )
set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pthread")
#
# pyth client API library
#
set( PC_SRC
pc/attr_id.cpp;
pc/capture.cpp;
pc/key_pair.cpp;
pc/key_store.cpp;
pc/jtree.cpp;
pc/log.cpp;
pc/manager.cpp;
pc/mem_map.cpp;
pc/misc.cpp;
pc/net_socket.cpp;
pc/pub_stats.cpp;
pc/replay.cpp;
pc/request.cpp;
pc/rpc_client.cpp;
pc/user.cpp;
program/src/oracle/sort.c
)
set( PC_HDR
pc/attr_id.hpp;
pc/capture.hpp;
pc/dbl_list.hpp;
pc/error.hpp;
pc/jtree.hpp;
pc/key_pair.hpp;
pc/key_store.hpp;
pc/hash_map.hpp;
pc/log.hpp;
pc/manager.hpp;
pc/mem_map.hpp;
pc/misc.hpp;
pc/net_socket.hpp;
pc/replay.hpp;
pc/request.hpp;
pc/rpc_client.hpp
pc/user.hpp )
add_library( pc STATIC ${PC_SRC} )
# dependencies
set( PC_DEP pc ssl crypto z zstd )
#
# applications
#
add_executable( pythd pcapps/pythd.cpp )
target_link_libraries( pythd ${PC_DEP} )
add_executable( pyth pcapps/pyth.cpp )
target_link_libraries( pyth ${PC_DEP} )
add_executable( pyth_admin pcapps/admin_rpc_client.cpp pcapps/admin_request.cpp pcapps/pyth_admin.cpp )
target_link_libraries( pyth_admin ${PC_DEP} )
add_executable( pyth_csv pcapps/pyth_csv.cpp )
target_link_libraries( pyth_csv ${PC_DEP} )
add_executable( pyth_tx pcapps/tx_rpc_client.cpp pcapps/tx_svr.cpp pcapps/pyth_tx.cpp )
target_link_libraries( pyth_tx ${PC_DEP} )
#
# install
#
install( TARGETS pc DESTINATION lib )
install( TARGETS pyth pyth_admin pythd pyth_csv pyth_tx DESTINATION bin )
install( FILES ${PC_HDR} DESTINATION include/pc )
install( FILES program/src/oracle/oracle.h DESTINATION include/oracle )
#
# test programs
#
enable_testing()
add_executable( test_unit pctest/test_unit.cpp )
target_link_libraries( test_unit ${PC_DEP} )
add_executable( test_net pctest/test_net.cpp )
target_link_libraries( test_net ${PC_DEP} )
add_executable( test_publish pctest/test_publish.cpp )
target_link_libraries( test_publish ${PC_DEP} )
add_executable( test_qset pctest/test_qset.cpp )
target_link_libraries( test_qset ${PC_DEP} )
add_executable( test_twap pctest/test_twap.cpp )
target_link_libraries( test_twap ${PC_DEP} )
add_executable( leader_stats pctest/leader_stats.cpp )
target_link_libraries( leader_stats ${PC_DEP} )
add_test( test_unit test_unit )
add_test( test_net test_net )
#
# fuzz testing application
#
add_executable( fuzz pctest/fuzz.cpp )
target_link_libraries( fuzz ${PC_DEP} )
#
# bpf static analysis (CLion)
#
function( add_bpf_lib targ )
if( SOLANA AND NOT BPF )
set( BPF ${SOLANA}/sdk/bpf )
endif()
if( BPF )
add_library( ${targ} STATIC ${ARGN} )
if( ${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.21" )
# bpf.mk uses --std=c17
set_property( TARGET ${targ} PROPERTY C_STANDARD 17 )
else()
set_property( TARGET ${targ} PROPERTY C_STANDARD 11 )
endif()
set_property( TARGET ${targ} PROPERTY C_STANDARD_REQUIRED ON )
set_property( TARGET ${targ} PROPERTY C_EXTENSIONS OFF )
target_compile_definitions( ${targ} PRIVATE __bpf__=1 )
target_include_directories( ${targ} SYSTEM PRIVATE
${BPF}/c/inc
${BPF}/dependencies/criterion/include
)
endif()
endfunction()
# test_oracle.c includes oracle.c
add_bpf_lib( test-oracle-bpf program/src/oracle/test_oracle.c )