-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathCMakeLists.txt
262 lines (208 loc) · 8.12 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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
#
# If not stated otherwise in this file or this component's LICENSE file the
# following copyright and licenses apply:
#
# Copyright 2022 Sky UK
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
cmake_minimum_required( VERSION 3.10 )
project( Rialto LANGUAGES C CXX VERSION 1.0.0 )
# Preprocesser Variable
add_compile_definitions(PROJECT_VER_MAJOR="${PROJECT_VERSION_MAJOR}")
add_compile_definitions(PROJECT_VER_MINOR="${PROJECT_VERSION_MINOR}")
add_compile_definitions(PROJECT_VER_PATCH="${PROJECT_VERSION_PATCH}")
set(CMAKE_CXX_STANDARD 17)
if ( COVERAGE_ENABLED )
add_compile_options(-coverage -fprofile-update=atomic)
endif()
add_compile_options(-Wall -Werror)
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 13.0)
add_compile_options(-Wno-error=overloaded-virtual)
endif()
# By default set link time optimisation, can affect compilation performance
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
option(RIALTO_LOG_FATAL_ENABLED "Enable fatal logging for RialtoServer" ON)
option(RIALTO_LOG_ERROR_ENABLED "Enable error logging for RialtoServer" ON)
option(RIALTO_LOG_WARN_ENABLED "Enable warning logging for RialtoServer" ON)
option(RIALTO_LOG_MIL_ENABLED "Enable milestone logging for RialtoServer" ON)
if( RIALTO_BUILD_TYPE STREQUAL "Debug" )
message("_______________DEBUG MODE_______________")
option(RIALTO_LOG_INFO_ENABLED "Enable info logging for RialtoServer" ON)
option(RIALTO_LOG_DEBUG_ENABLED "Enable debug logging for RialtoServer" ON)
else()
message("_______________RELEASE MODE (DEFAULT)_______________")
option(RIALTO_LOG_INFO_ENABLED "Enable info logging for RialtoServer" OFF)
option(RIALTO_LOG_DEBUG_ENABLED "Enable debug logging for RialtoServer" OFF)
endif()
if (NOT RIALTO_LOG_FATAL_ENABLED OR
NOT RIALTO_LOG_ERROR_ENABLED OR
NOT RIALTO_LOG_WARN_ENABLED OR
NOT RIALTO_LOG_MIL_ENABLED OR
NOT RIALTO_LOG_INFO_ENABLED OR
NOT RIALTO_LOG_DEBUG_ENABLED )
message("_______________COMPILATION ERRORS IGNORED_______________")
add_compile_options(-Wno-error=unused-function -Wno-error=unused-variable)
endif()
if ( RIALTO_LOG_FATAL_ENABLED )
message("RIALTO_LOG_FATAL IS ENABLED")
add_compile_definitions( RIALTO_LOG_FATAL_ENABLED )
endif()
if ( RIALTO_LOG_ERROR_ENABLED )
message("RIALTO_LOG_ERROR IS ENABLED")
add_compile_definitions( RIALTO_LOG_ERROR_ENABLED )
endif()
if ( RIALTO_LOG_WARN_ENABLED )
message("RIALTO_LOG_WARN IS ENABLED")
add_compile_definitions( RIALTO_LOG_WARN_ENABLED )
endif()
if ( RIALTO_LOG_MIL_ENABLED )
message("RIALTO_LOG_MIL IS ENABLED")
add_compile_definitions( RIALTO_LOG_MIL_ENABLED )
endif()
if ( RIALTO_LOG_INFO_ENABLED )
message("RIALTO_LOG_INFO IS ENABLED")
add_compile_definitions( RIALTO_LOG_INFO_ENABLED )
endif()
if ( RIALTO_LOG_DEBUG_ENABLED )
message("RIALTO_LOG_DEBUG IS ENABLED")
add_compile_definitions( RIALTO_LOG_DEBUG_ENABLED )
endif()
#check if TextTrack plugin exists in Thunder
find_path( TEXT_TRACK_INCLUDE_DIR NAMES WPEFramework/interfaces/ITextTrack.h )
if (TEXT_TRACK_INCLUDE_DIR)
message("ENABLE RIALTO_ENABLE_TEXT_TRACK")
add_compile_definitions(RIALTO_ENABLE_TEXT_TRACK)
endif()
# Retrieve the commit ID
execute_process(
COMMAND git rev-parse HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
RESULT_VARIABLE RESULT
OUTPUT_VARIABLE SRCREV
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(RESULT)
message("Failed to get git commit ID: ${RESULT}")
endif()
# Retrieve release tag
execute_process(
COMMAND bash -c "git tag --list --contains ${SRCREV} | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$'"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE TAGS
OUTPUT_STRIP_TRAILING_WHITESPACE
)
string(REPLACE "\n" ", " TAGS "${TAGS}")
if(NOT TAGS STREQUAL "")
set(TAGS ${TAGS})
endif()
# Preprocesser Variable
add_compile_definitions(SRCREV="${SRCREV}")
add_compile_definitions(TAGS="${TAGS}")
# Add our local cmake directory to search for components
set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake )
# Thread is just the generic lib link for the pthread libraries (on platforms
# that don't have a separate pthread library this is a NOP)
find_package( Threads REQUIRED )
# Allow setting the path to the protoc compiler binary to use on the cmake
# command line - likely to need this for SDK builds as SDK doesn't
# contain the tools by default
set( PROTOC_PATH "" CACHE STRING "Optional path to the host protobuf compiler (protoc) tool" )
if( PROTOC_PATH )
add_executable( protobuf::protoc IMPORTED )
set_target_properties( protobuf::protoc PROPERTIES IMPORTED_LOCATION "${PROTOC_PATH}" )
endif()
# Import protobuf package
find_package( Protobuf REQUIRED )
# Options to disable building some of the components
option(ENABLE_SERVER "Enable building RialtoServer" ON)
option(ENABLE_SERVER_MANAGER "Enable building RialtoServerManagerSim" ON)
if ( NOT ENVIRONMENT_VARIABLES)
set( ENVIRONMENT_VARIABLES "\"XDG_RUNTIME_DIR=/tmp\",\"GST_REGISTRY=/tmp/rialto-server-gstreamer-cache.bin\",\"WESTEROS_SINK_USE_ESSRMGR=1\"" )
endif()
if ( NOT EXTRA_ENV_VARIABLES)
set( EXTRA_ENV_VARIABLES "" )
endif()
if (NOT SESSION_SERVER_PATH)
set( SESSION_SERVER_PATH "\"/usr/bin/RialtoServer\"" )
endif()
if (NOT STARTUP_TIMEOUT_MS)
set( STARTUP_TIMEOUT_MS 0 )
endif()
if (NOT HEALTHCHECK_INTERVAL_S)
set( HEALTHCHECK_INTERVAL_S 5 )
endif()
if (NOT SOCKET_PERMISSIONS)
set( SOCKET_PERMISSIONS 666 )
endif()
string(REGEX MATCH "^([0-9]+)([0-9]+)([0-9]+)" PERMISSIONS_MATCH ${SOCKET_PERMISSIONS})
set(SOCKET_PERMISSIONS_OWNER ${CMAKE_MATCH_1})
set(SOCKET_PERMISSIONS_GROUP ${CMAKE_MATCH_2})
set(SOCKET_PERMISSIONS_OTHER ${CMAKE_MATCH_3})
# Empty strings for "owner" and "group" means that chown() won't be called. This will leave the created
# socket being owned by the user executing the code (and the group would be their primary group)
if (NOT SOCKET_OWNER)
set(SOCKET_OWNER "\"\"" )
endif()
if (NOT SOCKET_GROUP)
set(SOCKET_GROUP "\"\"" )
endif()
if (NOT NUM_OF_PRELOADED_SERVERS)
set( NUM_OF_PRELOADED_SERVERS 0 )
endif()
if (NOT LOG_LEVEL)
set( LOG_LEVEL 3 )
endif()
if (NOT NUM_OF_PINGS_BEFORE_RECOVERY)
set( NUM_OF_PINGS_BEFORE_RECOVERY 3 )
endif()
if( NATIVE_BUILD )
add_compile_options(-Wno-error=attributes)
add_subdirectory( stubs/rdk_gstreamer_utils )
add_subdirectory( stubs/opencdm )
add_subdirectory( stubs/wpeframework-core )
add_subdirectory( stubs/wpeframework-com )
include( GNUInstallDirs )
configure_file( pkg-config/RialtoClient.in.pc ${CMAKE_BINARY_DIR}/RialtoClient.pc @ONLY )
install (
FILES ${CMAKE_BINARY_DIR}/RialtoClient.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)
endif()
# Include the new IPC library components
add_subdirectory( ipc )
# Add the rialto targets
add_subdirectory( common )
add_subdirectory( media )
add_subdirectory( logging )
add_subdirectory( wrappers )
add_subdirectory( proto )
if( ENABLE_SERVER_MANAGER )
add_subdirectory( serverManager )
endif()
# Config and target for building the unit tests
if( CMAKE_BUILD_FLAG STREQUAL "UnitTests" )
# Turn off link time optimisation to speed up compilation
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION FALSE)
include( cmake/googletest.cmake )
add_subdirectory( tests/common EXCLUDE_FROM_ALL )
add_subdirectory( tests/unittests EXCLUDE_FROM_ALL )
endif()
# Config and target for building the unit tests
if( CMAKE_BUILD_FLAG STREQUAL "ComponentTests" )
# Turn off link time optimisation to speed up compilation
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION FALSE)
include( cmake/googletest.cmake )
add_subdirectory( tests/common EXCLUDE_FROM_ALL )
add_subdirectory( tests/componenttests EXCLUDE_FROM_ALL )
endif()