-
Notifications
You must be signed in to change notification settings - Fork 10
/
CMakeLists.txt
91 lines (76 loc) · 2.88 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
cmake_minimum_required(VERSION 3.13)
project(DolphinDBAPI)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_EXTENSIONS OFF)
option(USE_OPENSSL "Use OpenSSL for encrypted communication" ON)
option(USE_AERON "Use Aeron for UDP connection" ON)
option(USE_CXX11_ABI "Gcc Use C++11 ABI" ON)
add_library(${CMAKE_PROJECT_NAME} SHARED)
add_subdirectory(src)
if (USE_OPENSSL)
find_package(OpenSSL REQUIRED)
target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE USE_OPENSSL)
endif()
if (USE_AERON)
if (NOT DEFINED AERON_INSTALL_DIR)
set(AERON_INSTALL_DIR "/usr/local")
endif()
set(AERON_INCLUDE_DIR
"${AERON_INSTALL_DIR}/include/wrapper"
"${AERON_INSTALL_DIR}/include/aeron"
"${AERON_INSTALL_DIR}/include"
)
target_link_directories(${CMAKE_PROJECT_NAME} PRIVATE ${AERON_INSTALL_DIR}/lib)
set(AERON_LIBRARY
aeron
aeron_client_shared
aeron_driver
)
target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE USE_AERON)
endif()
if (NOT USE_CXX11_ABI)
target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE _GLIBCXX_USE_CXX11_ABI=0)
endif()
target_include_directories(${CMAKE_PROJECT_NAME}
PRIVATE ${OPENSSL_INCLUDE_DIR}
PRIVATE BEFORE ${AERON_INCLUDE_DIR} # make sure we include C warpper before deprecated C++ API
)
target_link_libraries(${CMAKE_PROJECT_NAME}
PRIVATE ${OPENSSL_SSL_LIBRARY}
PRIVATE ${OPENSSL_CRYPTO_LIBRARY}
PRIVATE ${AERON_LIBRARY}
)
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
target_compile_definitions(${CMAKE_PROJECT_NAME}
PRIVATE WINDOWS NOMINMAX _DDBAPIDLL
)
# C4251: Class member of an exported class is not marked dllexport.
# This is triggered by std::string but we cannot modify STL.
# C4100: Parameter is unused. We should fix this later.
target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE /W3 /WX /MP /wd4251 /wd4100)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE ws2_32)
else ()
target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE -Wall -Werror)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE pthread rt uuid)
endif()
if (USE_CXX11_ABI AND EXISTS "${PROJECT_SOURCE_DIR}/thirdparty/googletest/CMakeLists.txt")
add_executable(${CMAKE_PROJECT_NAME}_test)
add_subdirectory(test)
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
target_compile_options(${CMAKE_PROJECT_NAME}_test PRIVATE /W0 /utf-8 /MP)
target_compile_definitions(${CMAKE_PROJECT_NAME}_test PRIVATE WINDOWS NOMINMAX)
else()
target_compile_options(${CMAKE_PROJECT_NAME}_test PRIVATE -w)
endif()
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
add_subdirectory("${PROJECT_SOURCE_DIR}/thirdparty/googletest")
enable_testing()
target_link_libraries(${CMAKE_PROJECT_NAME}_test
${CMAKE_PROJECT_NAME}
gtest_main
gmock_main
)
else()
message("skipping tests.")
endif()