forked from TzuHuanTai/RaspberryPi-WebRTC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
153 lines (142 loc) · 4.31 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
151
152
153
cmake_minimum_required(VERSION 3.18)
project(pi_webrtc)
set(CMAKE_CXX_STANDARD 20)
set(BUILD_TEST "" CACHE STRING "test")
string(TOLOWER "${CMAKE_BUILD_TYPE}" BUILD_TYPE_LOWER)
if(NOT BUILD_TYPE_LOWER OR BUILD_TYPE_LOWER STREQUAL "debug")
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build (Debug or Release)" FORCE)
add_definitions(-DDEBUG_MODE)
find_library(PROFILER_LIB profiler)
if(PROFILER_LIB)
message(STATUS "Profiler library found: ${PROFILER_LIB}")
add_link_options(-lprofiler)
else()
message(STATUS "Profiler library not found")
endif()
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
endif()
option(USE_MQTT_SIGNALING "Enable MQTT signaling" ON)
if(USE_MQTT_SIGNALING)
add_definitions(-DUSE_MQTT_SIGNALING)
message(STATUS "SIGNALING: MQTT")
endif()
set(WEBRTC_INCLUDE_DIR /usr/local/include/webrtc)
set(WEBRTC_LIBRARY /usr/local/lib/libwebrtc.a)
set(WEBRTC_LINK_LIBS dl)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
message(STATUS "BUILD_TEST: ${BUILD_TEST}")
message(STATUS "WEBRTC_INCLUDE_DIR: ${WEBRTC_INCLUDE_DIR}")
message(STATUS "WEBRTC_LIBRARY: ${WEBRTC_LIBRARY}")
add_compile_definitions(
NDEBUG
WEBRTC_POSIX
WEBRTC_LINUX
WEBRTC_USE_H264
USE_CPPRESTSDK
)
add_compile_options(
-pipe
-fdeclspec
)
include_directories(
./src
${WEBRTC_INCLUDE_DIR}
${WEBRTC_INCLUDE_DIR}/third_party/abseil-cpp
${WEBRTC_INCLUDE_DIR}/third_party/libyuv/include
${WEBRTC_INCLUDE_DIR}/tools/json_schema_compiler
)
if(BUILD_TEST STREQUAL "pulseaudio")
add_executable(test_pulseaudio test/test_pulseaudio.cpp)
target_link_libraries(test_pulseaudio
pulse-simple pulse
)
elseif(BUILD_TEST STREQUAL "recorder")
add_subdirectory(src/common)
add_subdirectory(src/capturer)
add_subdirectory(src/recorder)
add_subdirectory(src/v4l2_codecs)
add_executable(test_recorder test/test_recorder.cpp)
target_link_libraries(test_recorder
capturer
recorder
)
elseif(BUILD_TEST STREQUAL "mqtt")
add_subdirectory(src/signaling)
add_executable(test_mqtt test/test_mqtt.cpp)
target_link_libraries(test_mqtt
signaling
)
target_link_libraries(test_mqtt
Threads::Threads
${MOSQUITTO_LIBS}
)
elseif(BUILD_TEST STREQUAL "openh264")
add_executable(test_openh264 test/test_openh264.cpp)
target_link_libraries(test_openh264
${WEBRTC_LINK_LIBS}
${WEBRTC_LIBRARY}
)
elseif(BUILD_TEST STREQUAL "v4l2_capturer")
add_subdirectory(src/capturer)
add_subdirectory(src/common)
add_subdirectory(src/v4l2_codecs)
add_executable(test_v4l2_capturer test/test_v4l2_capturer.cpp)
target_link_libraries(test_v4l2_capturer
capturer
v4l2_codecs
)
elseif(BUILD_TEST STREQUAL "v4l2_encoder")
add_subdirectory(src/capturer)
add_subdirectory(src/common)
add_subdirectory(src/v4l2_codecs)
add_executable(test_v4l2_encoder test/test_v4l2_encoder.cpp)
target_link_libraries(test_v4l2_encoder
capturer
v4l2_codecs
)
elseif(BUILD_TEST STREQUAL "v4l2_decoder")
add_subdirectory(src/capturer)
add_subdirectory(src/common)
add_subdirectory(src/v4l2_codecs)
add_executable(test_v4l2_decoder test/test_v4l2_decoder.cpp)
target_link_libraries(test_v4l2_decoder
capturer
v4l2_codecs
)
elseif(BUILD_TEST STREQUAL "v4l2_scaler")
add_subdirectory(src/capturer)
add_subdirectory(src/common)
add_subdirectory(src/v4l2_codecs)
add_executable(test_v4l2_scaler test/test_v4l2_scaler.cpp)
target_link_libraries(test_v4l2_scaler
capturer
v4l2_codecs
)
elseif(BUILD_TEST STREQUAL "libcamera")
add_subdirectory(src/capturer)
add_subdirectory(src/common)
add_executable(test_libcamera test/test_libcamera.cpp)
target_link_libraries(test_libcamera
capturer
common
)
target_link_libraries(test_libcamera
${WEBRTC_LINK_LIBS}
Threads::Threads
${WEBRTC_LIBRARY}
)
else()
add_subdirectory(src)
add_executable(${PROJECT_NAME} src/main.cpp)
target_link_libraries(${PROJECT_NAME}
src
)
target_link_libraries(${PROJECT_NAME}
${WEBRTC_LINK_LIBS}
boost_program_options
Threads::Threads
${WEBRTC_LIBRARY}
)
endif()