-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
125 lines (98 loc) · 3.33 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
cmake_minimum_required(VERSION 3.20.2)
set(CMAKE_BUILD_TYPE Debug)
add_compile_options(
-Wno-unused-parameter
-Wno-unused-variable
-Wall
-Wextra
-Werror
-Wconversion
-Wnull-dereference
-Wsuggest-override
-Wpointer-arith
-Wshift-overflow=1
-Wduplicated-cond
-Wduplicated-branches
-Wsuggest-final-types
-Wcast-align
-Wnon-virtual-dtor
-Wmisleading-indentation)
project(
rush
VERSION 0.0.1
DESCRIPTION "rush protocol transport library")
option(WITH_GNUTLS "use gnutls for tls" OFF)
IF (WITH_GNUTLS)
add_compile_definitions(TLS_USE_GNUTLS)
ELSE()
add_compile_definitions(TLS_USE_OPENSSL)
ENDIF()
include(GNUInstallDirs)
find_library(LIBEV_LIBRARIES NAMES ev REQUIRED)
find_path(LIBEV_INCLUDE_DIR ev.h)
find_package(PkgConfig REQUIRED)
IF (WITH_GNUTLS)
set(GNUTLS "gnutls = 3.7.8")
pkg_check_modules(GNUTLS REQUIRED ${GNUTLS})
include_directories(${GNUTLS_INCLUDE_DIRS})
pkg_check_modules(NGTCP2_GNUTLS_REQUIRED libngtcp2_crypto_gnutls)
include_directories(${NGTCP2_GNUTLS_DIRS})
ELSE()
set(OPEN_SSL_QUIC "openssl = 1.1.1s+quic")
pkg_check_modules(OPENSSL REQUIRED ${OPEN_SSL_QUIC})
include_directories(${OPENSSL_INCLUDE_DIRS})
pkg_check_modules(NGTCP2_OPENSSL REQUIRED libngtcp2_crypto_openssl)
include_directories(${NGTCP2_OPENSSL_DIRS})
ENDIF()
set(LIB_NGTCP2 "libngtcp2 >= 0.11.0")
pkg_check_modules(NGTCP2 REQUIRED ${LIB_NGTCP2})
include_directories(${NGTCP2_INCLUDE_DIRS})
set(
SOURCE_FILES
${PROJECT_SOURCE_DIR}/src/Rush.cpp
${PROJECT_SOURCE_DIR}/src/Evloop.cpp
${PROJECT_SOURCE_DIR}/src/Utils.cpp
${PROJECT_SOURCE_DIR}/src/TLSClientContext.cpp
${PROJECT_SOURCE_DIR}/src/RushClient.cpp
${PROJECT_SOURCE_DIR}/src/Buffer.cpp
${PROJECT_SOURCE_DIR}/src/RushMuxer.cpp
${PROJECT_SOURCE_DIR}/src/Pool.cpp
${PROJECT_SOURCE_DIR}/src/Frames.cpp
${PROJECT_SOURCE_DIR}/src/CodecUtils.cpp
${PROJECT_SOURCE_DIR}/src/Serializer.cpp
${PROJECT_SOURCE_DIR}/src/QuicConnection.cpp)
IF (WITH_GNUTLS)
set(SOURCE_FILES ${SOURCE_FILES}
${PROJECT_SOURCE_DIR}/src/GnutlsClientContext.cpp)
ELSE()
set(SOURCE_FILES ${SOURCE_FILES}
${PROJECT_SOURCE_DIR}/src/OpensslClientContext.cpp)
ENDIF()
add_library(rush ${SOURCE_FILES})
set(PUBLIC_HEADERS ${PROJECT_SOURCE_DIR}/include/Rush.h
${PROJECT_SOURCE_DIR}/include/CodecUtils.h)
set_target_properties(rush PROPERTIES VERSION ${PROJECT_VERSION})
set_target_properties(rush PROPERTIES PUBLIC_HEADER "${PUBLIC_HEADERS}")
target_include_directories(rush PUBLIC ${PROJECT_SOURCE_DIR}/include)
target_link_libraries(rush ${NGTCP2_LIBRARIES})
IF (WITH_GNUTLS)
target_link_libraries(rush ${GNUTLS_LIBRARIES})
target_link_libraries(rush ${NGTCP2_GNUTLS_LIBRARIES})
ELSE()
target_link_libraries(rush ${OPENSSL_LIBRARIES})
target_link_libraries(rush ${NGTCP2_OPENSSL_LIBRARIES})
ENDIF()
target_link_libraries(rush ${LIBEV_LIBRARIES})
set(LIBS_PRIVATE "-lpthread -lstdc++ -lev")
IF (WITH_GNUTLS)
set(REQUIRES_PRIVATE "${LIB_NGTCP2} libngtcp2_crypto_gnutls ${GNUTLS}")
ELSE()
set(REQUIRES_PRIVATE "${LIB_NGTCP2} libngtcp2_crypto_openssl ${OPEN_SSL_QUIC}")
ENDIF()
configure_file(librush.pc.in librush.pc @ONLY)
install(
TARGETS rush
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(FILES ${CMAKE_BINARY_DIR}/librush.pc
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig)