Skip to content

Commit c8205cf

Browse files
committed
fix cmake
1 parent 81f8a7c commit c8205cf

File tree

6 files changed

+62
-51
lines changed

6 files changed

+62
-51
lines changed

.gitignore

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,23 @@
3939
cmake-build-debug
4040
build
4141
*-build
42-
demo/openapi_cpp_test/Debug/
43-
demo/openapi_cpp_test/Release/
44-
demo/openapi_cpp_test/myeasylog.log
45-
output/Debug/openapi-cpp-sdk.exp
46-
output/Debug/openapi-cpp-sdk.ilk
47-
output/Debug/openapi-cpp-sdk.pdb
48-
output/Debug/openapi_cpp_test.ilk
49-
output/Debug/openapi_cpp_test.pdb
50-
output/Release/openapi-cpp-sdk.exp
51-
output/Release/openapi-cpp-sdk.pdb
52-
output/Release/openapi_cpp_test.iobj
53-
output/Release/openapi_cpp_test.ipdb
54-
output/Release/openapi_cpp_test.pdb
42+
demo/openapi_cpp_test/Debug/
43+
demo/openapi_cpp_test/Release/
44+
demo/openapi_cpp_test/myeasylog.log
45+
demo/openapi_cpp_test/CMakeCache.txt
46+
demo/openapi_cpp_test/CMakeFiles
47+
demo/openapi_cpp_test/Makefile
48+
demo/openapi_cpp_test/cmake_install.cmake
49+
output/Debug/openapi-cpp-sdk.exp
50+
output/Debug/openapi-cpp-sdk.ilk
51+
output/Debug/openapi-cpp-sdk.pdb
52+
output/Debug/openapi_cpp_test.ilk
53+
output/Debug/openapi_cpp_test.pdb
54+
output/Release/openapi-cpp-sdk.exp
55+
output/Release/openapi-cpp-sdk.pdb
56+
output/Release/openapi_cpp_test.iobj
57+
output/Release/openapi_cpp_test.ipdb
58+
output/Release/openapi_cpp_test.pdb
5559
/output/Release/openapi-cpp-sdk.ipdb
5660
/output/Release/openapi-cpp-sdk.iobj
5761

CMakeLists.txt

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,20 @@ if(UNIX) # Darwing or Linux
2626
message(CPPREST_INCLUDE_DIR " ${CPPREST_INCLUDE_DIR}")
2727
message(CPPREST_LIBRARY " ${CPPREST_LIBRARY}")
2828

29+
30+
2931
if(APPLE)
3032
# Prefer a homebrew version of OpenSSL over the one in /usr/lib
3133
# file(GLOB OPENSSL_ROOT_DIR /usr/local/Cellar/openssl*/*)
32-
file(GLOB OPENSSL_ROOT_DIR /usr/local/opt/openssl/*)
34+
file(GLOB OPENSSL_ROOT_DIR /usr/local/opt/openssl/* /opt/homebrew/Cellar/openssl@3/*)
3335
# Prefer the latest (make the latest one first)
3436
list(REVERSE OPENSSL_ROOT_DIR)
3537

36-
find_package(OpenSSL 1.1 REQUIRED)
37-
set(OPENSSL_VERSION "1.1.1q")
38+
find_package(OpenSSL REQUIRED)
39+
# set(OPENSSL_VERSION "1.1.1q")
3840

41+
set(ZLIB_LIBRARY /opt/homebrew/Cellar/zlib/1.2.13/lib/libz.dylib )
42+
message(ZLIB_LIBRARY " ${ZLIB_LIBRARY}")
3943

4044
else()
4145
find_package(OpenSSL 1.0.1 REQUIRED)
@@ -52,7 +56,8 @@ endif()
5256
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
5357

5458
message("-- configuring clang options")
55-
set(CMAKE_CXX_FLAGS "-arch x86_64 -std=c++11 -stdlib=libc++ -DBOOST_LOG_DYN_LINK -Wno-deprecated-declarations")
59+
# set(CMAKE_CXX_FLAGS "-arch x86_64 -std=c++11 -stdlib=libc++ -DBOOST_LOG_DYN_LINK -Wno-deprecated-declarations")
60+
set(CMAKE_CXX_FLAGS "-arch arm64 -std=c++11 -stdlib=libc++ -DBOOST_LOG_DYN_LINK -Wno-deprecated-declarations")
5661

5762
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
5863

@@ -64,13 +69,14 @@ endif()
6469

6570
# Project construction ...
6671
# src files ...
72+
file(GLOB MY_SOURCE_FILES "include/cpprest/*.h" "include/cpprest/details/*.h")
6773
add_library(${PROJECT_NAME}
6874
src/tiger_client.cpp include/tigerapi/tiger_client.h include/tigerapi/constants.h
6975
include/tigerapi/utils.h src/utils.cpp include/tigerapi/service_types.h include/tigerapi/quote_client.h
7076
src/quote_client.cpp src/trade_client.cpp include/tigerapi/model.h src/order_util.cpp
7177
include/tigerapi/order_util.h src/contract_util.cpp include/tigerapi/contract_util.h
7278
include/tigerapi/client_config.h include/tigerapi/sign_util.h
73-
include/tigerapi/easylogging++.h src/easylogging++.cc)
79+
include/tigerapi/easylogging++.h cpprest/ src/easylogging++.cc ${MY_SOURCE_FILES})
7480

7581
# headers search paths ...
7682
#set(HEADER_SEARCH_PATHS ${CPPREST_INCLUDE_DIR} ${Boost_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR})
@@ -79,7 +85,7 @@ set(HEADER_SEARCH_PATHS ${Boost_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR})
7985
# library search paths ...
8086
if(APPLE)
8187
set(OPENSSL_LIBS "${OPENSSL_LIBRARIES}")
82-
set(ZIP_LIBRARY "/usr/local/Cellar/zlib/1.2.12/lib/libz.dylib")
88+
# set(ZIP_LIBRARY ZLIB::ZLIB)
8389

8490
set(LIBRARIES_SEARCH_PATHS ${OPENSSL_LIBS} ${Boost_LIBRARIES} ${CPPREST_LIBRARY} ${ZIP_LIBRARY})
8591
else()

demo/CMakeLists.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ if(UNIX) # Darwing or Linux
2323
if(APPLE)
2424
# Prefer a homebrew version of OpenSSL over the one in /usr/lib
2525
# file(GLOB OPENSSL_ROOT_DIR /usr/local/Cellar/openssl*/*)
26-
file(GLOB OPENSSL_ROOT_DIR /usr/local/opt/openssl/*)
26+
file(GLOB OPENSSL_ROOT_DIR /usr/local/opt/openssl/* /opt/homebrew/Cellar/openssl@3/*)
2727
# Prefer the latest (make the latest one first)
2828
list(REVERSE OPENSSL_ROOT_DIR)
2929

30-
find_package(OpenSSL 1.1 REQUIRED)
31-
set(OPENSSL_VERSION "1.1.1q")
30+
find_package(OpenSSL REQUIRED)
31+
# set(OPENSSL_VERSION "1.1.1q")
3232

3333

3434
else()
@@ -46,7 +46,8 @@ endif()
4646
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
4747

4848
message("-- configuring clang options")
49-
set(CMAKE_CXX_FLAGS "-arch x86_64 -std=c++11 -stdlib=libc++ -DBOOST_LOG_DYN_LINK -Wno-deprecated-declarations")
49+
# set(CMAKE_CXX_FLAGS "-arch x86_64 -std=c++11 -stdlib=libc++ -DBOOST_LOG_DYN_LINK -Wno-deprecated-declarations")
50+
set(CMAKE_CXX_FLAGS "-arch arm64 -std=c++11 -stdlib=libc++ -DBOOST_LOG_DYN_LINK -Wno-deprecated-declarations")
5051

5152
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
5253

@@ -65,7 +66,7 @@ set(HEADER_SEARCH_PATHS ${CPPREST_INCLUDE_DIR} ${Boost_INCLUDE_DIR} ${OPENSSL_IN
6566
# library search paths ...
6667
if(APPLE)
6768
set(OPENSSL_LIBS "${OPENSSL_LIBRARIES}")
68-
set(ZIP_LIBRARY "/usr/local/Cellar/zlib/1.2.12/lib/libz.dylib")
69+
# set(ZIP_LIBRARY "/usr/local/Cellar/zlib/1.2.12/lib/libz.dylib")
6970
set(LIBRARIES_SEARCH_PATHS ${OPENSSL_LIBS} ${Boost_LIBRARIES} ${ZIP_LIBRARY} ${CPPREST_LIBRARY} ${TIGERAPI_LIBRARY})
7071
else()
7172
set(OPENSSL_LIBS "${OPENSSL_LIBRARIES}")

src/quote_client.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ namespace TIGER_API {
6767
value obj = value::object(true);
6868
obj[P_SYMBOLS] = symbols;
6969
obj[U("include_hour_trading")] = include_hour_trading;
70-
obj[P_BEGIN_TIME] = begin_time;
70+
obj[P_BEGIN_TIME] = (long long) begin_time;
7171
return post(TIMELINE, obj);
7272
}
7373

@@ -76,8 +76,8 @@ namespace TIGER_API {
7676
value obj = value::object(true);
7777
obj[P_SYMBOLS] = symbols;
7878
obj[P_PERIOD] = value::string(period);
79-
obj[P_BEGIN_TIME] = begin_time;
80-
obj[P_END_TIME] = end_time;
79+
obj[P_BEGIN_TIME] = (long long) begin_time;
80+
obj[P_END_TIME] = (long long) end_time;
8181
obj[P_RIGHT] = value::string(right);
8282
obj[P_LIMIT] = limit;
8383
obj[P_PAGE_TOKEN] = value::string(page_token);
@@ -135,8 +135,8 @@ namespace TIGER_API {
135135
value obj = value::object(true);
136136
obj[P_SYMBOLS] = symbols;
137137
obj[P_TRADE_SESSION] = value::string(trade_session);
138-
obj[P_BEGIN_INDEX] = begin_index;
139-
obj[P_END_INDEX] = end_index;
138+
obj[P_BEGIN_INDEX] = (long long) begin_index;
139+
obj[P_END_INDEX] = (long long) end_index;
140140
obj[P_LIMIT] = limit;
141141
return post(TRADE_TICK, obj);
142142
}
@@ -233,7 +233,7 @@ namespace TIGER_API {
233233
value obj = value::object(true);
234234
value basic = value::object(true);
235235
basic[P_SYMBOL] = value::string(symbol);
236-
basic[P_EXPIRY] = expiry;
236+
basic[P_EXPIRY] = (long long) expiry;
237237
value option_basic = value::array();
238238
option_basic[0] = basic;
239239
obj[U("option_basic")] = option_basic;
@@ -266,9 +266,9 @@ namespace TIGER_API {
266266
continue;
267267
}
268268
value obj = value::object(true);
269-
obj[P_BEGIN_TIME] = begin_time;
270-
obj[P_END_TIME] = end_time;
271-
obj[P_EXPIRY] = Utils::date_string_to_timestamp(expiry);
269+
obj[P_BEGIN_TIME] = (long long) begin_time;
270+
obj[P_END_TIME] = (long long) end_time;
271+
obj[P_EXPIRY] = (long long) Utils::date_string_to_timestamp(expiry);
272272
obj[P_PERIOD] = value::string(U("day"));
273273
obj[P_RIGHT] = value::string(right);
274274
obj[P_STRIKE] = value::string(strike);
@@ -349,8 +349,8 @@ namespace TIGER_API {
349349
value obj = value::object(true);
350350
obj[P_CONTRACT_CODES] = contract_codes;
351351
obj[P_PERIOD] = value::string(period);
352-
obj[P_BEGIN_TIME] = begin_time;
353-
obj[P_END_TIME] = end_time;
352+
obj[P_BEGIN_TIME] = (long long) begin_time;
353+
obj[P_END_TIME] = (long long) end_time;
354354
obj[P_LIMIT] = limit;
355355
obj[P_PAGE_TOKEN] = value::string(page_token);
356356
return post(FUTURE_KLINE, obj);

src/tiger_client.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ namespace TIGER_API {
145145
continue;
146146
}
147147
value obj = value::object(true);
148-
obj[P_EXPIRY] = Utils::date_string_to_timestamp(expiry);
148+
obj[P_EXPIRY] = (long long) Utils::date_string_to_timestamp(expiry);
149149
obj[P_RIGHT] = value::string(right);
150150
obj[P_STRIKE] = value::string(strike);
151151
obj[P_SYMBOL] = value::string(symbol);

src/trade_client.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ namespace TIGER_API {
8282
obj[U("sub_accounts")] = sub_accounts;
8383
}
8484
if (expiry != -1 && expiry != 0) {
85-
obj[P_EXPIRY] = expiry;
85+
obj[P_EXPIRY] = (long long) expiry;
8686
}
8787
if (!strike.empty()) {
8888
obj[P_STRIKE] = value::string(strike);
@@ -128,10 +128,10 @@ namespace TIGER_API {
128128
obj[P_SYMBOL] = value::string(symbol);
129129
}
130130
if (start_date != -1 && start_date != 0) {
131-
obj[P_START_DATE] = start_date;
131+
obj[P_START_DATE] = (long long) start_date;
132132
}
133133
if (end_date != -1 && end_date != 0) {
134-
obj[P_END_DATE] = end_date;
134+
obj[P_END_DATE] = (long long) end_date;
135135
}
136136
if (limit != 0) {
137137
obj[P_LIMIT] = limit;
@@ -172,10 +172,10 @@ namespace TIGER_API {
172172
obj[P_SYMBOL] = value::string(symbol);
173173
}
174174
if (start_date != -1 && start_date != 0) {
175-
obj[P_START_DATE] = start_date;
175+
obj[P_START_DATE] = (long long) start_date;
176176
}
177177
if (end_date != -1 && end_date != 0) {
178-
obj[P_END_DATE] = end_date;
178+
obj[P_END_DATE] = (long long) end_date;
179179
}
180180
if (parent_id != 0) {
181181
obj[U("parent_id")] = parent_id;
@@ -213,10 +213,10 @@ namespace TIGER_API {
213213
obj[P_SYMBOL] = value::string(symbol);
214214
}
215215
if (start_date != -1 && start_date != 0) {
216-
obj[P_START_DATE] = start_date;
216+
obj[P_START_DATE] = (long long) start_date;
217217
}
218218
if (end_date != -1 && end_date != 0) {
219-
obj[P_END_DATE] = end_date;
219+
obj[P_END_DATE] = (long long) end_date;
220220
}
221221
if (parent_id != 0) {
222222
obj[U("parent_id")] = parent_id;
@@ -254,10 +254,10 @@ namespace TIGER_API {
254254
obj[P_SYMBOL] = value::string(symbol);
255255
}
256256
if (start_date != -1 && start_date != 0) {
257-
obj[P_START_DATE] = start_date;
257+
obj[P_START_DATE] = (long long) start_date;
258258
}
259259
if (end_date != -1 && end_date != 0) {
260-
obj[P_END_DATE] = end_date;
260+
obj[P_END_DATE] = (long long) end_date;
261261
}
262262
if (parent_id != 0) {
263263
obj[U("parent_id")] = parent_id;
@@ -296,7 +296,7 @@ namespace TIGER_API {
296296
obj[P_EXCHANGE] = value::string(exchange);
297297
}
298298
if (expiry != -1 && expiry != 0) {
299-
obj[P_EXPIRY] = expiry;
299+
obj[P_EXPIRY] = (long long) expiry;
300300
}
301301
if (!strike.empty()) {
302302
obj[P_STRIKE] = value::string(strike);
@@ -359,7 +359,7 @@ namespace TIGER_API {
359359
}
360360

361361
if (order.order_id != 0) {
362-
obj[U("order_id")] = order.order_id;
362+
obj[U("order_id")] = (long long) order.order_id;
363363
}
364364
if (order.id != 0) {
365365
obj[U("id")] = order.id;
@@ -401,7 +401,7 @@ namespace TIGER_API {
401401
obj[U("user_mark")] = value::string(order.user_mark);
402402
}
403403
if (order.expire_time) {
404-
obj[U("expire_time")] = order.expire_time;
404+
obj[U("expire_time")] = (long long) order.expire_time;
405405
}
406406
value res = post(PLACE_ORDER, obj);
407407
try {
@@ -481,7 +481,7 @@ namespace TIGER_API {
481481
obj[U("user_mark")] = value::string(order.user_mark);
482482
}
483483
if (order.expire_time) {
484-
obj[U("expire_time")] = order.expire_time;
484+
obj[U("expire_time")] = (long long) order.expire_time;
485485
}
486486
value res = post(MODIFY_ORDER, obj);
487487
return res;
@@ -503,7 +503,7 @@ namespace TIGER_API {
503503
obj[U("action")] = value::string(order.action);
504504
}
505505
if (total_quantity != 0) {
506-
obj[U("total_quantity")] = total_quantity;
506+
obj[U("total_quantity")] = (long long) total_quantity;
507507
} else {
508508
obj[U("total_quantity")] = order.total_quantity;
509509
}
@@ -529,7 +529,7 @@ namespace TIGER_API {
529529
obj[U("outside_rth")] = outside_rth;
530530
}
531531
if (expire_time) {
532-
obj[U("expire_time")] = expire_time;
532+
obj[U("expire_time")] = (long long) expire_time;
533533
}
534534
value res = post(MODIFY_ORDER, obj);
535535
return res;

0 commit comments

Comments
 (0)