forked from ultravideo/uvgRTP
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
139 lines (120 loc) · 3.84 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
cmake_minimum_required(VERSION 3.5)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS OFF)
project(uvgrtp)
option(DISABLE_CRYPTO "Do not build uvgRTP with crypto enabled")
option(PTHREADS_PATH "Path to POSIX threads static library")
option(CRYPTOPP_PATH "Path to Crypto++ static library")
add_library(uvgrtp STATIC
src/clock.cc
src/crypto.cc
src/dispatch.cc
src/frame.cc
src/hostname.cc
src/lib.cc
src/media_stream.cc
src/mingw_inet.cc
src/multicast.cc
src/pkt_dispatch.cc
src/poll.cc
src/queue.cc
src/random.cc
src/rtcp.cc
src/rtp.cc
src/runner.cc
src/session.cc
src/socket.cc
src/zrtp.cc
src/holepuncher.cc
src/formats/media.cc
src/formats/h26x.cc
src/formats/h264.cc
src/formats/h265.cc
src/formats/h266.cc
src/zrtp/zrtp_receiver.cc
src/zrtp/hello.cc
src/zrtp/hello_ack.cc
src/zrtp/commit.cc
src/zrtp/dh_kxchng.cc
src/zrtp/confirm.cc
src/zrtp/confack.cc
src/zrtp/error.cc
src/zrtp/zrtp_message.cc
src/srtp/base.cc
src/srtp/srtp.cc
src/srtp/srtcp.cc
)
target_include_directories(uvgrtp
PUBLIC
${PROJECT_SOURCE_DIR}/include
)
set(LIBRARY_PATHS "")
if (PTHREADS_PATH)
separate_arguments(LIBRARY_PATHS NATIVE_COMMAND ${PTHREADS_PATH})
endif (PTHREADS_PATH)
if (CRYPTOPP_PATH AND NOT DISABLE_CRYPTO)
separate_arguments(LIBRARY_PATHS NATIVE_COMMAND "${LIBRARY_PATHS} ${CRYPTOPP_PATH}")
endif (CRYPTOPP_PATH AND NOT DISABLE_CRYPTO)
if (UNIX)
set(COMPILER_FLAGS "-Wall -Wextra -Wuninitialized -Wshadow -O2 -g -march=native")
if (DISABLE_CRYPTO)
string(APPEND COMPILER_FLAGS " -D__RTP_NO_CRYPTO__")
endif(DISABLE_CRYPTO)
# Check the getrandom() function exists
include(CheckCXXSymbolExists)
check_cxx_symbol_exists(getrandom sys/random.h HAVE_GETRANDOM)
if(HAVE_GETRANDOM)
add_compile_definitions(HAVE_GETRANDOM=1)
endif()
# if (NOT "${LIBRARY_PATHS}" STREQUAL "")
# add_custom_command(TARGET uvgrtp POST_BUILD
# COMMAND ar crsT ARGS libuvgrtp_thin.a libuvgrtp.a ${LIBRARY_PATHS}
# BYPRODUCTS libuvgrtp_thin.a
# COMMENT "Creating combined archive"
# )
# install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libuvgrtp_thin.a
# RENAME libuvgrtp.a
# DESTINATION /usr/local/lib
# )
# else (NOT "${LIBRARY_PATHS}" STREQUAL "")
install(TARGETS uvgrtp
ARCHIVE
DESTINATION /usr/local/lib
)
# endif (NOT "${LIBRARY_PATHS}" STREQUAL "")
install(DIRECTORY include/ DESTINATION /usr/local/include/uvgrtp
FILES_MATCHING PATTERN "*.hh"
)
endif (UNIX)
if (WIN32)
if(MSVC)
# /Zc:__cplusplus makes it so the correct c++ version is defined
set(COMPILER_FLAGS "/O2 /Zc:__cplusplus")
else(MSVC)
set(COMPILER_FLAGS "-O2")
endif(MSVC)
SET(OUT_DIR ${CMAKE_BINARY_DIR}/Debug)
if (DISABLE_CRYPTO)
if(MSVC)
string(APPEND COMPILER_FLAGS " /D__RTP_NO_CRYPTO__")
else(MSVC)
string(APPEND COMPILER_FLAGS " -D__RTP_NO_CRYPTO__")
endif(MSVC)
endif(DISABLE_CRYPTO)
# if (NOT "${LIBRARY_PATHS}" STREQUAL "")
# add_custom_command(TARGET uvgrtp POST_BUILD
# COMMAND lib /out:${OUT_DIR}/uvgrtp.lib ${OUT_DIR}/uvgrtp.lib ${LIBRARY_PATHS}
# BYPRODUCTS uvgrtp.lib
# COMMENT "Creating combined archive"
# )
# else (NOT "${LIBRARY_PATHS}" STREQUAL "")
install(TARGETS uvgrtp
ARCHIVE
DESTINATION ${PROJECT_BINARY_DIR}/lib
)
# endif (NOT "${LIBRARY_PATHS}" STREQUAL "")
install(DIRECTORY include/ DESTINATION ${PROJECT_BINARY_DIR}/include
FILES_MATCHING PATTERN "*.hh"
)
endif (WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMPILER_FLAGS}")