forked from hd-zero/hdzero-goggle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
185 lines (158 loc) · 4.48 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
cmake_minimum_required(VERSION 3.10)
project(HDZGOGGLE VERSION 1.1)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(COMMON_COMPILER_FLAGS "-Wno-unused-function -Wno-unused-variable -Wno-deprecated-declarations -ffunction-sections -fdata-sections -Wl,-gc-sections -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64")
option(EMULATOR_BUILD "emulate using SDL on host" OFF)
if(NOT EMULATOR_BUILD)
set(COMMON_COMPILER_FLAGS "${COMMON_COMPILER_FLAGS} -mfpu=neon -mfloat-abi=hard")
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_COMPILER_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_COMPILER_FLAGS}")
set(CMAKE_C_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_C_FLAGS_RELEASE "-Werror -O3 -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-Werror -O3 -DNDEBUG")
set(OS_APP_PATH ${PROJECT_SOURCE_DIR}/mkapp/app/app)
set(RECORD_APP_PATH ${PROJECT_SOURCE_DIR}/mkapp/app/app/record)
# common build settings
set(STANDARD_LIBRARIES
c
crypt
dl
m
pthread
rt
stdc++
)
add_definitions(
-DAWCHIP=AW_V5
-D_GNU_SOURCE
-DUSE_LOG_LIB_GLOG
)
if(EMULATOR_BUILD)
add_definitions(
-DEMULATOR_BUILD
)
endif()
# dependencies
add_subdirectory(lib/lvgl)
add_subdirectory(lib/minIni)
add_subdirectory(lib/log)
add_subdirectory(lib/esp-loader)
add_subdirectory(lib/softwinner)
if(EMULATOR_BUILD)
find_package(SDL2 REQUIRED)
else()
add_subdirectory(lib/ffmpeg)
add_subdirectory(lib/live)
endif()
# main application
file(GLOB SRC_FILES_CORE "src/core/*.c" "src/core/*.h")
file(GLOB SRC_FILES_DRIVER "src/driver/*.c" "src/driver/*.h")
file(GLOB SRC_FILES_FONTS "src/fonts/*.c" "src/fonts/*.h")
file(GLOB SRC_FILES_IMAGE "src/image/*.c" "src/image/*.h")
file(GLOB SRC_FILES_UI "src/ui/*.c" "src/ui/*.h")
file(GLOB SRC_FILES_BMI "src/bmi270/*.c" "src/bmi270/*.h")
file(GLOB SRC_FILES_UTIL "src/util/*.c" "src/util/*.h")
file(GLOB SRC_FILES_PLAYER "src/player/*.c" "src/player/*.h")
file(GLOB SRC_FILES_EMULATOR "src/emulator/*.c" "src/emulator/*.h")
file(GLOB SRC_FILES_LANG "src/lang/*.c" "src/lang/*.h")
set(SRC_FILES
${SRC_FILES_CORE}
${SRC_FILES_DRIVER}
${SRC_FILES_FONTS}
${SRC_FILES_IMAGE}
${SRC_FILES_UI}
${SRC_FILES_BMI}
${SRC_FILES_UTIL}
${SRC_FILES_LANG}
)
if(EMULATOR_BUILD)
list(APPEND SRC_FILES ${SRC_FILES_EMULATOR})
else()
list(APPEND SRC_FILES ${SRC_FILES_PLAYER})
endif()
add_executable(${PROJECT_NAME} ${SRC_FILES})
target_include_directories(${PROJECT_NAME} PRIVATE
src/
src/core
src/driver
src/player
src/player/media/app
src/window
lib/linux/include
lib/linux/include/video
)
target_link_libraries(${PROJECT_NAME} PRIVATE
${STANDARD_LIBRARIES}
log
lvgl
minIni
esp-loader
softwinner
)
if(EMULATOR_BUILD)
target_link_libraries(${PROJECT_NAME} PRIVATE ${SDL2_LIBRARIES})
endif()
if(NOT EMULATOR_BUILD)
# record application
file(GLOB SRC_FILES_RECORD "src/record/*.c" "src/record/*.h")
add_executable(record
${SRC_FILES_RECORD}
)
target_include_directories(record PRIVATE
src/record
lib/linux/include
lib/linux/include/video
lib/linux/include/media
)
target_link_libraries(record PRIVATE
${STANDARD_LIBRARIES}
log
ffmpeg
minIni
softwinner
)
# rtspLive application
file(GLOB SRC_FILES_RTSPLIVE "src/rtspLive/*.cpp" "src/rtspLive/*.hh")
file(GLOB SRC_FILES_RTSPLIVE_STREAM "src/rtspLive/stream/*.c" "src/rtspLive/stream/*.h")
file(GLOB SRC_FILES_RTSPLIVE_SERVER "src/rtspLive/server/*.cpp" "src/rtspLive/server/*.hh")
set(RTSPLIVE_BUILD_FLAGS "-DNO_OPENSSL=1 -fno-pie -no-pie")
add_executable(rtspLive
${SRC_FILES_RTSPLIVE}
${SRC_FILES_RTSPLIVE_STREAM}
${SRC_FILES_RTSPLIVE_SERVER}
)
target_include_directories(rtspLive PRIVATE
src/rtspLive
src/rtspLive/stream
src/rtspLive/server
)
set_target_properties(rtspLive PROPERTIES
COMPILE_FLAGS ${RTSPLIVE_BUILD_FLAGS}
LINK_FLAGS ${RTSPLIVE_BUILD_FLAGS}
)
target_link_libraries(rtspLive PRIVATE
${STANDARD_LIBRARIES}
log
live
minIni
)
# image build
add_custom_command(
OUTPUT ${PROJECT_SOURCE_DIR}/out/${PROJECT_NAME}
COMMAND size -A ${PROJECT_NAME}
COMMAND mkdir -p ${PROJECT_SOURCE_DIR}/out/
COMMAND cp ${PROJECT_NAME} ${PROJECT_SOURCE_DIR}/out/
COMMAND cp record ${PROJECT_SOURCE_DIR}/out/
COMMAND cp rtspLive ${PROJECT_SOURCE_DIR}/out/
COMMAND cp ${PROJECT_NAME} ${OS_APP_PATH}
COMMAND cp record ${RECORD_APP_PATH}
COMMAND cp rtspLive ${RECORD_APP_PATH}
COMMAND cd ${PROJECT_SOURCE_DIR} && ./mkapp/mkapp_ota.sh
DEPENDS ${PROJECT_NAME} record rtspLive
)
add_custom_target(${PROJECT_NAME}-OTA ALL
DEPENDS ${PROJECT_SOURCE_DIR}/out/${PROJECT_NAME}
)
endif()