Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development/more cmake #1657

Merged
merged 11 commits into from
Jun 20, 2024
21 changes: 12 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ project(Thunder
DESCRIPTION "Thunder framework"
HOMEPAGE_URL "https://rdkcentral.github.io/Thunder/")

include(GNUInstallDirs)

set(VERSION ${${PROJECT_NAME}_VERSION})
set(VERSION_MAJOR ${${PROJECT_NAME}_VERSION_MAJOR})
set(VERSION_MINOR ${${PROJECT_NAME}_VERSION_MINOR})
Expand All @@ -42,7 +44,6 @@ option(HUMAN_VERSIONED_BINARIES
"Create binaries with a human readeable version suffix" ON)
option(VERSIONED_LIBRARY_LOADING
"Uses the major version (*.so.<major>) to load libraries rather then *.so" OFF)


if (BUILD_REFERENCE)
add_definitions (-DBUILD_REFERENCE=${BUILD_REFERENCE})
Expand All @@ -56,16 +57,15 @@ list(APPEND CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/common"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
"${CMAKE_SYSROOT}${CMAKE_INSTALL_PREFIX}/include/${PROJECT_NAME}/Modules")
"${CMAKE_SYSROOT}${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/Modules")

if (TOOLS_SYSROOT)
list(APPEND CMAKE_MODULE_PATH
"${TOOLS_SYSROOT}${CMAKE_INSTALL_PREFIX}/include/${PROJECT_NAME}/Modules")
"${TOOLS_SYSROOT}${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/Modules")
endif()

include(platform)
include(CmakeHelperFunctions)
include(GNUInstallDirs)

set(PLATFORM "PC_UNIX" CACHE STRING
"Defines on what platform the application will run")
Expand All @@ -78,7 +78,7 @@ find_package(ConfigGenerator REQUIRED)

if(NOT DEFINED BUILD_SHARED_LIBS)
set(BUILD_SHARED_LIBS ON CACHE INTERNAL "Enable shared objects by default")
message(STATUS "BUILD_SHARED_LIBS was not set, assuming ${BUILD_SHARED_LIBS}")
message(VERBOSE "Building shared libs")
endif()

#
Expand All @@ -89,7 +89,7 @@ if(NOT CMAKE_BUILD_TYPE)
message(AUTHOR_WARNING "CMAKE_BUILD_TYPE not set, assuming '${CMAKE_BUILD_TYPE}'")
endif()

message(STATUS "CMake build type: '${CMAKE_BUILD_TYPE}'")
message(VERBOSE "CMake build type: '${CMAKE_BUILD_TYPE}'")

# Remove optimization flags added by the build system
string(REGEX REPLACE "(-g[0123])" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
Expand All @@ -110,18 +110,21 @@ configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/project.cmake.in"

install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${NAMESPACE}.cmake"
RENAME "${NAMESPACE}Config.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE})
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}
COMPONENT ${NAMESPACE}_Development)

if(CMAKE_VERSION VERSION_LESS 3.20.0 AND LEGACY_CONFIG_GENERATOR)
install(DIRECTORY
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/config"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE})
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}
COMPONENT ${NAMESPACE}_Development)
endif(CMAKE_VERSION VERSION_LESS 3.20.0 AND LEGACY_CONFIG_GENERATOR)

install(DIRECTORY
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/common"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE})
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}
COMPONENT ${NAMESPACE}_Development)

if(APPLE)
# Mac needed variables
Expand Down
2 changes: 1 addition & 1 deletion Source/Thunder/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ install(
)

install(DIRECTORY
DESTINATION ${PERSISTENT_PATH}/${NAMESPACE}} COMPONENT ${NAMESPACE}_Runtime
DESTINATION ${PERSISTENT_PATH} COMPONENT ${NAMESPACE}_Runtime
DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE
)

Expand Down
16 changes: 8 additions & 8 deletions Source/Thunder/GenericConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ set(BINDING "0.0.0.0" CACHE STRING "The binding interface")
set(IDLE_TIME 180 CACHE STRING "Idle time")
set(SOFT_KILL_CHECK_WAIT_TIME 10 CACHE STRING "Soft kill check waiting time")
set(HARD_KILL_CHECK_WAIT_TIME 4 CACHE STRING "Hard kill check waiting time")
set(PERSISTENT_PATH "/root" CACHE STRING "Persistent path")
set(DATA_PATH "${CMAKE_INSTALL_FULL_DATAROOTDIR}/${NAMESPACE}" CACHE STRING "Data path")
set(SYSTEM_PATH "${CMAKE_INSTALL_FULL_LIBDIR}/${NAMESPACE_LIB}/plugins" CACHE STRING "System path")
set(WEBSERVER_PATH "/boot/www" CACHE STRING "Root path for the HTTP server")
set(PERSISTENT_PATH "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/${NAMESPACE}" CACHE PATH "Persistent path")
set(DATA_PATH "${CMAKE_INSTALL_FULL_DATAROOTDIR}/${NAMESPACE}" CACHE PATH "Data path")
set(SYSTEM_PATH "${CMAKE_INSTALL_FULL_LIBDIR}/${NAMESPACE_LIB}/plugins" CACHE PATH "System path")
set(WEBSERVER_PATH "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/www/html" CACHE PATH "Root path for the HTTP server")
set(WEBSERVER_PORT 8080 CACHE STRING "Port for the HTTP server")
set(PROXYSTUB_PATH "${CMAKE_INSTALL_FULL_LIBDIR}/${NAMESPACE_LIB}/proxystubs" CACHE STRING "Proxy stub path")
set(POSTMORTEM_PATH "/opt/minidumps" CACHE STRING "Core file path to do the postmortem of the crash")
set(PROXYSTUB_PATH "${CMAKE_INSTALL_FULL_LIBDIR}/${NAMESPACE_LIB}/proxystubs" CACHE PATH "Proxy stub path")
set(POSTMORTEM_PATH "/opt/minidumps" CACHE PATH "Core file path to do the postmortem of the crash")
set(MESSAGECONTROL_PATH "MessageDispatcher" CACHE STRING "MessageControl base path to create message files")
set(MESSAGING_PORT 0 CACHE STRING "The port for the messaging")
set(MESSAGING_STDOUT false CACHE STRING "Enable message rederict from stdout")
set(MESSAGING_STDERR false CACHE STRING "Enable message rederict from stderr")
set(MESSAGING_DATASIZE 20480 CACHE STRING "Size of the data buffer in bytes [max 63KB]")
set(CONFIG_INSTALL_PATH "${CMAKE_INSTALL_FULL_SYSCONFDIR}/${NAMESPACE}" CACHE STRING "Install location of the configuration")
set(CONFIG_INSTALL_PATH "${CMAKE_INSTALL_FULL_SYSCONFDIR}/${NAMESPACE}" CACHE PATH "Install location of the configuration")
set(IPV6_SUPPORT false CACHE STRING "Controls if should application supports ipv6")
set(LEGACY_INITIALZE false CACHE STRING "Enables legacy Plugin Initialize behaviour (Deinit not called on failed Init)")
set(PRIORITY 0 CACHE STRING "Change the nice level [-20 - 20]")
Expand Down Expand Up @@ -79,7 +79,7 @@ endif()
map_set(${CONFIG} idletime ${IDLE_TIME})
map_set(${CONFIG} softkillcheckwaittime ${SOFT_KILL_CHECK_WAIT_TIME})
map_set(${CONFIG} hardkillcheckwaittime ${HARD_KILL_CHECK_WAIT_TIME})
map_set(${CONFIG} persistentpath ${PERSISTENT_PATH}/${NAMESPACE})
map_set(${CONFIG} persistentpath ${PERSISTENT_PATH})
map_set(${CONFIG} volatilepath ${VOLATILE_PATH})
map_set(${CONFIG} datapath ${DATA_PATH})
map_set(${CONFIG} systempath ${SYSTEM_PATH})
Expand Down
2 changes: 1 addition & 1 deletion Source/Thunder/Thunder.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ipv6 = '@IPV6_SUPPORT@'
idletime = '@IDLE_TIME@'
softkillcheckwaittime = '@SOFT_KILL_CHECK_WAIT_TIME@'
hardkillcheckwaittime = '@HARD_KILL_CHECK_WAIT_TIME@'
persistentpath = '@PERSISTENT_PATH@/@NAMESPACE@'
persistentpath = '@PERSISTENT_PATH@'
volatilepath = '@VOLATILE_PATH@'
datapath = '@DATA_PATH@'
systempath = '@SYSTEM_PATH@'
Expand Down
4 changes: 2 additions & 2 deletions Source/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ find_package(ExecInfo)
find_package(LIBRT)

configure_file("${CMAKE_CURRENT_SOURCE_DIR}/Version.h.in" "${CMAKE_CURRENT_BINARY_DIR}/generated/core/Version.h" @ONLY)
message(STATUS "Generated ${CMAKE_CURRENT_BINARY_DIR}/generated/core/Version.h")
message(VERBOSE "Generated ${CMAKE_CURRENT_BINARY_DIR}/generated/core/Version.h")

add_library(${TARGET}
Module.cpp
Expand Down Expand Up @@ -157,7 +157,7 @@ target_compile_options (${TARGET} PRIVATE -Wno-psabi)
# All build flags that are applicable to the whole system should be set here in the
# core since the core is included everywhere so if they are set here, they are
# picked up everywhere!
if(DISABLE_TRACING)
if(DISABLE_TRACING OR NOT ENABLED_TRACING_LEVEL)
target_compile_definitions(${TARGET} PUBLIC _TRACE_LEVEL=0)
message(STATUS "Force trace level to 0")
else()
Expand Down
6 changes: 5 additions & 1 deletion Source/extensions/localtracer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
project(LocalTracer LANGUAGES CXX)
project(LocalTracer
VERSION 0.0.1
DESCRIPTION "Library to get tracing locally from e.g. your test code on the stdout."
LANGUAGES CXX)

cmake_minimum_required(VERSION 3.15)

set(MODULE_NAME ${NAMESPACE}LocalTracer)
Expand Down
5 changes: 4 additions & 1 deletion Source/extensions/privilegedrequest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

project(PrivilegedRequest LANGUAGES CXX)
project(PrivilegedRequest
VERSION 1.0.0
DESCRIPTION "With PrivilegedRequest you can make a file descriptor available to other processes."
LANGUAGES CXX)

cmake_minimum_required(VERSION 3.15)

Expand Down
4 changes: 2 additions & 2 deletions cmake/common/CmakeHelperFunctions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ function(InstallCMakeConfig)
VERSION ${_version}
COMPATIBILITY SameMajorVersion)

message(STATUS "${_target} added support for cmake consumers via '${_name}Config.cmake'")
message(VERBOSE "${_target} added support for cmake consumers via '${_name}Config.cmake'")

if(NOT "${_type}" STREQUAL "INTERFACE_LIBRARY")
# The alias is used by local targets project
Expand Down Expand Up @@ -608,7 +608,7 @@ function(InstallPackageConfig)
endif()
endforeach()

message(STATUS "${_target} added support for generic consumers via ${_pc_filename}")
message(VERBOSE "${_target} added support for generic consumers via ${_pc_filename}")

configure_file( "${_pc_template}"
"${CMAKE_CURRENT_BINARY_DIR}/${_pc_filename}"
Expand Down
2 changes: 1 addition & 1 deletion cmake/common/CreateLink.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function(CreateLink)

cmake_parse_arguments(Argument "${optionsArgs}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )

message(STATUS "Creating symlink ${Argument_LINK} -> ${Argument_TARGET}")
message(VERBOSE "Creating symlink ${Argument_LINK} -> ${Argument_TARGET}")

get_filename_component(LINK_DIR ${Argument_LINK} DIRECTORY)
file(MAKE_DIRECTORY "${LINK_DIR}")
Expand Down
4 changes: 2 additions & 2 deletions cmake/common/HeaderOnlyInstall.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function(HeaderOnlyInstallCMakeConfig)
VERSION ${_version}
COMPATIBILITY SameMajorVersion)

message(STATUS "${TARGET} added support for cmake consumers via '${_name}Config.cmake'")
message(VERBOSE "${TARGET} added support for cmake consumers via '${_name}Config.cmake'")

if(NOT "${_type}" STREQUAL "INTERFACE_LIBRARY" OR Argument_TREAT_AS_NORMAL)
# The alias is used by local targets project
Expand Down Expand Up @@ -294,7 +294,7 @@ function(HeaderOnlyInstallPackageConfig)
endif()
endforeach()

message(STATUS "${TARGET} added support for generic consumers via ${_pc_filename}")
message(VERBOSE "${TARGET} added support for generic consumers via ${_pc_filename}")

configure_file( "${_pc_template}"
"${CMAKE_CURRENT_BINARY_DIR}/${_pc_filename}"
Expand Down
44 changes: 13 additions & 31 deletions docs/introduction/build_linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ git clone https://github.com/rdkcentral/ThunderTools.git
```
Next, we need to run the following commands to build and then install the code generators inside ThunderTools:
```shell
cmake -G Ninja -S ThunderTools -B build/ThunderTools -DCMAKE_INSTALL_PREFIX="install/usr"
cmake -G Ninja -S ThunderTools -B build/ThunderTools -DCMAKE_INSTALL_PREFIX="install"

cmake --build build/ThunderTools --target install
```
Expand All @@ -54,17 +54,12 @@ Run the following commands to build and then install Thunder. The available `-DC

```shell
cmake -G Ninja -S Thunder -B build/Thunder \
-DBUILD_SHARED_LIBS=ON \
-DBINDING="127.0.0.1" \
-DCMAKE_BUILD_TYPE="Debug" \
-DCMAKE_INSTALL_PREFIX="install/usr" \
-DCMAKE_MODULE_PATH="${PWD}/install/usr/include/Thunder/Modules" \
-DDATA_PATH="${PWD}/install/usr/share/Thunder" \
-DPERSISTENT_PATH="${PWD}/install/var/thunder" \
-DCMAKE_INSTALL_PREFIX="install" \
-DPORT="55555" \
-DPROXYSTUB_PATH="${PWD}/install/usr/lib/thunder/proxystubs" \
-DSYSTEM_PATH="${PWD}/install/usr/lib/thunder/plugins" \
-DVOLATILE_PATH="tmp"
-DTOOLS_SYSROOT="${PWD}" \
-DINITV_SCRIPT=OFF

cmake --build build/Thunder --target install
```
Expand All @@ -84,8 +79,7 @@ Run the following commands to build and then install ThunderInterfaces:

```shell
cmake -G Ninja -S ThunderInterfaces -B build/ThunderInterfaces \
-DCMAKE_INSTALL_PREFIX="install/usr" \
-DCMAKE_MODULE_PATH="${PWD}/install/usr/include/Thunder/Modules"
-DCMAKE_INSTALL_PREFIX="install"

cmake --build build/ThunderInterfaces --target install
```
Expand All @@ -107,24 +101,18 @@ In the command below, there is a complete list of plugins that do not require an

```shell
cmake -G Ninja -S ThunderNanoServices -B build/ThunderNanoServices \
-DCMAKE_INSTALL_PREFIX="install/usr" \
-DCMAKE_MODULE_PATH="${PWD}/install/usr/include/Thunder/Modules" \
-DCMAKE_INSTALL_PREFIX="install" \
-DPLUGIN_COMMANDER=ON \
-DPLUGIN_DHCPSERVER=ON \
-DPLUGIN_DIALSERVER=ON \
-DPLUGIN_DICTIONARY=ON \
-DPLUGIN_FILETRANSFER=ON \
-DPLUGIN_IOCONNECTOR=ON \
-DPLUGIN_INPUTSWITCH=ON \
-DPLUGIN_NETWORKCONTROL=ON \
-DPLUGIN_PROCESSMONITOR=ON \
-DPLUGIN_RESOURCEMONITOR=ON \
-DPLUGIN_SYSTEMCOMMANDS=ON \
-DPLUGIN_SWITCHBOARD=ON \
-DPLUGIN_WEBPROXY=ON \
-DPLUGIN_WEBSERVER=ON \
-DPLUGIN_WEBSHELL=ON \
-DPLUGIN_WIFICONTROL=ON
-DPLUGIN_WEBSHELL=ON

cmake --build build/ThunderNanoServices --target install
```
Expand All @@ -143,11 +131,8 @@ In the command below, there is a complete list of plugins that do not require an

```shell
cmake -G Ninja -S ThunderNanoServicesRDK -B build/ThunderNanoServicesRDK \
-DCMAKE_INSTALL_PREFIX="install/usr" \
-DCMAKE_MODULE_PATH="${PWD}/install/usr/include/Thunder/Modules" \
-DPLUGIN_DEVICEIDENTIFICATION=ON \
-DCMAKE_INSTALL_PREFIX="install" \
-DPLUGIN_DEVICEINFO=ON \
-DPLUGIN_LOCATIONSYNC=ON \
-DPLUGIN_MESSAGECONTROL=ON \
-DPLUGIN_MESSENGER=ON \
-DPLUGIN_MONITOR=ON \
Expand All @@ -173,12 +158,10 @@ In the command below, there is a complete list of client libraries that do not r

```shell
cmake -G Ninja -S ThunderClientLibraries -B build/ThunderClientLibraries \
-DCMAKE_INSTALL_PREFIX="install/usr" \
-DCMAKE_MODULE_PATH="${PWD}/install/usr/include/Thunder/Modules" \
-DCMAKE_INSTALL_PREFIX="install" \
-DBLUETOOTHAUDIOSINK=ON \
-DDEVICEINFO=ON \
-DDISPLAYINFO=ON \
-DLOCALTRACER=ON \
-DSECURITYAGENT=ON \
-DPLAYERINFO=ON \
-DPROTOCOLS=ON \
Expand All @@ -205,8 +188,7 @@ Run the following commands to build and then install ThunderUI:

```shell
cmake -G Ninja -S ThunderUI -B build/ThunderUI \
-DCMAKE_INSTALL_PREFIX="install/usr" \
-DCMAKE_MODULE_PATH="${PWD}/install/usr/include/Thunder/Modules"
-DCMAKE_INSTALL_PREFIX="install"

cmake --build build/ThunderUI --target install
```
Expand All @@ -219,10 +201,10 @@ After everything has been built and installed correctly, we can run Thunder.
Since we installed Thunder in a custom installation directory, we need to provide an `LD_LIBRARY_PATH` to that location and set `PATH` to include the `bin` directory. If the libraries are installed in system-wide locations (e.g. `/usr/lib` and `/usr/bin`) then those environment variables are not required

```shell
export LD_LIBRARY_PATH=${PWD}/install/usr/lib:${LD_LIBRARY_PATH}
export PATH=${PWD}/install/usr/bin:${PATH}
export LD_LIBRARY_PATH=${PWD}/install/lib:${LD_LIBRARY_PATH}
export PATH=${PWD}/install/bin:${PATH}

$ Thunder -f -c ${PWD}/install/etc/Thunder/config.json
Thunder -f -c ${PWD}/install/etc/Thunder/config.json
```

The following arguments should be specified to the Thunder binary:
Expand Down
2 changes: 1 addition & 1 deletion docs/introduction/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## Introduction

Thunder (aka Thunder) is developed by [Metrological](https://www.metrological.com/) (a Comcast company), and provides a way for STB operators to implement business-logic in a modular way using plugins, and a consistent way for applications to control and query those plugins. By using a plugin-based architecture, it is possible to build a device with only the specific features that are required for that particular device.
Thunder is developed by [Metrological](https://www.metrological.com/) (a Comcast company), and provides a way for STB operators to implement business-logic in a modular way using plugins, and a consistent way for applications to control and query those plugins. By using a plugin-based architecture, it is possible to build a device with only the specific features that are required for that particular device.

!!! tip
Do not confuse Thunder and [WPEWebKit](https://github.com/WebPlatformForEmbedded/WPEWebKit/). Whilst both are maintained by the Metrological/WPE team, they are not related. [WPEWebKit](https://github.com/WebPlatformForEmbedded/WPEWebKit/) is a fork of the WebKit browser for embedded devices, and shares no code with Thunder
Expand Down