-
Notifications
You must be signed in to change notification settings - Fork 36
/
CMakeLists.txt
269 lines (215 loc) · 8.55 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
263
264
265
266
267
268
269
#############################################################################
# If not stated otherwise in this file or this component's Licenses.txt file
# the following copyright and licenses apply:
#
# Copyright 2016 RDK Management
#
# 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 2.8.12)
if (POLICY CMP0048)
cmake_policy(SET CMP0048 NEW)
project(rbus VERSION 2.0.13)
else ()
project(rbus)
set(PROJECT_VERSION "2.0.13")
endif (POLICY CMP0048)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/")
enable_testing()
find_package(PkgConfig REQUIRED)
set(CMAKE_C_FLAGS_DEBUG "-fPIC -Wall -Werror -Wextra -Wno-type-limits -fno-inline ${CMAKE_C_FLAGS_DEBUG} -DRBUS_ALWAYS_ON ")
set(CMAKE_C_FLAGS_RELEASE "-fPIC -Wall -Werror -Wextra ${CMAKE_C_FLAGS_RELEASE} -DRBUS_ALWAYS_ON ")
set(CMAKE_CXX_FLAGS_DEBUG "-fPIC -Wall -Werror -Wextra -Wno-type-limits -fno-inline ${CMAKE_C_FLAGS_DEBUG} -DRBUS_ALWAYS_ON ")
set(CMAKE_CXX_FLAGS_RELEASE "-fPIC -Wall -Werror -Wextra ${CMAKE_C_FLAGS_RELEASE} -DRBUS_ALWAYS_ON ")
if(ENABLE_ADDRESS_SANITIZER)
set(CMAKE_C_FLAGS "-fsanitize=address ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "-fsanitize=address ${CMAKE_CXX_FLAGS}")
endif(ENABLE_ADDRESS_SANITIZER)
include(GNUInstallDirs)
IF (NOT DEFINED CMAKE_INSTALL_BINDIR)
message ("Setting Bindir")
SET(CMAKE_INSTALL_BINDIR bin)
ENDIF ()
IF (NOT DEFINED CMAKE_INSTALL_LIBDIR)
message ("Setting Libdir")
SET(CMAKE_INSTALL_LIBDIR lib)
ENDIF ()
message ("Using ${CMAKE_INSTALL_BINDIR} and ${CMAKE_INSTALL_LIBDIR}")
SET(FULL_CMAKE_INSTALL_BINDIR ${CMAKE_INSTALL_PREFIX}/bin)
SET(FULL_CMAKE_INSTALL_LIBDIR ${CMAKE_INSTALL_PREFIX}/lib)
include(CMakePackageConfigHelpers)
SET (CMAKE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/rbus")
configure_package_config_file(rbusConfig.cmake.in
rbusConfig.cmake
INSTALL_DESTINATION "${CMAKE_INSTALL_CMAKEDIR}")
write_basic_package_version_file(
rbusConfigVersion.cmake
VERSION 1.1.1
COMPATIBILITY AnyNewerVersion )
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/rbusConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/rbusConfigVersion.cmake"
DESTINATION "${CMAKE_INSTALL_CMAKEDIR}" )
option(BUILD_RBUS_DAEMON "BUILD_RBUS_DAEMON" ON)
option(BUILD_RBUS_SAMPLE_APPS "BUILD_RBUS_SAMPLE_APPS" ON)
option(BUILD_RBUS_TEST_APPS "BUILD_RBUS_TEST_APPS" ON)
option(BUILD_ONLY_RTMESSAGE "BUILD_ONLY_RTMESSAGE" OFF)
option(BUILD_RTMESSAGE_SAMPLE_APP "BUILD_RTMESSAGE_SAMPLE_APP" OFF)
option(BUILD_RTMESSAGE_DATAPROVIDER_LIB "BUILD_RTMESSAGE_DATAPROVIDER_LIB" OFF)
option(BUILD_RBUSCORE_BENCHMARK_TEST "BUILD_RBUSCORE_BENCHMARK_TEST" OFF)
option(BUILD_RBUSCORE_TEST_APPS "BUILD_RBUSCORE_TEST_APPS" OFF)
option(BUILD_SESSIONMGR_SAMPLE_APPS "BUILD_SESSIONMGR_SAMPLE_APPS" OFF)
option(ENABLE_RDKLOGGER "ENABLE_RDKLOGGER" OFF)
option(RDKC_BUILD "RDKC_BUILD" OFF)
option(WITH_SPAKE2 "WITH_SPAKE2" OFF)
option(MSG_ROUNDTRIP_TIME "MSG_ROUNDTRIP_TIME" OFF)
if (BUILD_FOR_DESKTOP)
set(MSG_ROUNDTRIP_TIME ON)
message("Building for desktop")
include_directories(${CMAKE_INSTALL_PREFIX}/include)
include(ExternalProject)
ExternalProject_Add(
cjson
GIT_REPOSITORY https://github.com/DaveGamble/cJSON.git
GIT_TAG v1.6.0
INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}
INSTALL_COMMAND ""
CONFIGURE_COMMAND ""
BUILD_IN_SOURCE 1
PREFIX deps
CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}"
BUILD_COMMAND make)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}/deps/src)
link_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}/deps/src/cjson
${CMAKE_BINARY_DIR}
${LIBRARY_DIR})
set(CJSON_LIBRARIES "-lcjson")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/deps/src/cjson/libcjson.so ${CMAKE_CURRENT_BINARY_DIR}/deps/src/cjson/libcjson.so.1 ${CMAKE_CURRENT_BINARY_DIR}/deps/src/cjson/libcjson.so.1.6.0 DESTINATION ${CMAKE_INSTALL_LIBDIR})
ExternalProject_Add(
linenoise
GIT_REPOSITORY https://github.com/antirez/linenoise.git
PREFIX deps
UPDATE_DISCONNECTED 1
INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}
INSTALL_COMMAND ""
CONFIGURE_COMMAND ""
BUILD_IN_SOURCE 1
CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}"
#PATCH_COMMAND patch -p1 < ${CMAKE_CURRENT_SOURCE_DIR}/003-linenoise-oflag.patch
BUILD_COMMAND gcc -c -Wall -Werror -fpic linenoise.c COMMAND gcc --shared -o liblinenoise.so linenoise.o)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}/deps/src/linenoise)
link_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}/deps/src/linenoise
${CMAKE_BINARY_DIR}
${LIBRARY_DIR})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/deps/src/linenoise/liblinenoise.so DESTINATION ${CMAKE_INSTALL_LIBDIR})
ExternalProject_Add(
msgpack
GIT_REPOSITORY https://github.com/msgpack/msgpack-c.git
GIT_TAG 2.1.4
PREFIX deps
UPDATE_DISCONNECTED 1
INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}
BUILD_IN_SOURCE 1
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DMSGPACK_BUILD_EXAMPLES=OFF -DMSGPACK_BUILD_TESTS=OFF
BUILD_COMMAND make)
set(MSGPACK_LIBRARIES "-lmsgpackc")
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}/msgpack/src/msgpack/include)
link_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}/deps/src/msgpack
${CMAKE_BINARY_DIR}
${LIBRARY_DIR})
else()
find_package(cJSON REQUIRED)
IF (NOT BUILD_ONLY_RTMESSAGE)
find_package(msgpack REQUIRED)
find_package(linenoise REQUIRED)
ENDIF ()
set(INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/include)
set(LIBRARY_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CJSON_INCLUDE_DIRS})
IF (NOT BUILD_ONLY_RTMESSAGE)
include_directories(${MSGPACK_INCLUDE_DIRS})
ENDIF ()
link_directories(${CMAKE_CURRENT_SOURCE_DIR})
if (ENABLE_RDKLOGGER)
include_directories(${RDKLOGGER__INCLUDE_DIRS})
add_definitions(-DENABLE_RDKLOGGER)
endif (ENABLE_RDKLOGGER)
if (INCLUDE_BREAKPAD)
add_definitions(-DINCLUDE_BREAKPAD)
endif (INCLUDE_BREAKPAD)
if (RDKC_BUILD)
add_definitions(-DRDKC_BUILD)
endif (RDKC_BUILD)
endif (BUILD_FOR_DESKTOP)
if (ENABLE_CODE_COVERAGE)
include (CodeCoverage)
if (NOT BUILD_FOR_DESKTOP)
string(APPEND COVERAGE_COMPILER_FLAGS " -fprofile-generate=/tmp/")
endif()
append_coverage_compiler_flags()
set(COVERAGE_EXCLUDES
"${CMAKE_CURRENT_BINARY_DIR}/unittests/gtest/*"
"test/*"
"utils/*"
"/usr/include/*"
"sampleapps/*")
option (ENABLE_UNIT_TESTING "ENABLE_UNIT_TESTING" ON)
if (BUILD_FOR_DESKTOP)
if (ENABLE_CODE_COVERAGE_GOVR)
setup_target_for_coverage_gcovr_html(NAME "${PROJECT_NAME}CodeCoverageUI")
setup_target_for_coverage_gcovr_xml(NAME "${PROJECT_NAME}CodeCoverage")
else ()
setup_target_for_coverage_lcov(NAME "${PROJECT_NAME}CodeCoverageUI")
endif()
endif()
endif()
if (ENABLE_STATIC_CODE_ANALYZER)
find_program(CLANG_TIDY_EXE run-clang-tidy REQUIRED)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
#set(CLANG_TIDY_CHECKS "-checks=-*,modernize-*,performance-*,bugprone-*,clang-diagnostic-*,clang-analyzer-*")
set(CLANG_TIDY_CHECKS "-checks=-google-*,-llvm-*,bugprone-*,cert-*,modernize-*,clang-diagnostic-*")
add_custom_target(
code-analysis
ALL
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CLANG_TIDY_EXE} ${CLANG_TIDY_CHECKS} 2>&1 > ${CMAKE_CURRENT_BINARY_DIR}/clang-tidy-output.txt
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/compile_commands.json)
endif()
if (ENABLE_RDKLOGGER)
find_package(rdklogger REQUIRED)
add_definitions(-DENABLE_RDKLOGGER)
endif (ENABLE_RDKLOGGER)
add_subdirectory(src)
IF (NOT BUILD_ONLY_RTMESSAGE)
add_subdirectory(utils)
add_subdirectory(test)
ENDIF ()
if(BUILD_RBUS_SAMPLE_APPS)
add_subdirectory(sampleapps)
endif()
if (ENABLE_UNIT_TESTING)
add_subdirectory(unittests)
endif()