Skip to content

Commit

Permalink
Development/portable build (#1681)
Browse files Browse the repository at this point in the history
* cmake: use dynamic include folder

* cmake: find templates relative to the helper functions file

* cmake: find templates relative to the header only install function file

* cmake: local source path should not be dynamic

* cmake: add component definitions

* cmake: move to dynamic cmake paths

* docs: remove note

* docs: add missing package

* docs: cleanup double thunder
  • Loading branch information
bramoosterhuis committed Jul 3, 2024
1 parent 7f048da commit 59bdf3d
Show file tree
Hide file tree
Showing 14 changed files with 73 additions and 34 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
![Linux Build](https://github.com/rdkcentral/Thunder/actions/workflows/Build%20Thunder%20on%20Linux.yml/badge.svg) ![Windows Build](https://github.com/rdkcentral/Thunder/actions/workflows/Build%20Thunder%20on%20Windows.yml/badge.svg) ![Unit Test](https://github.com/rdkcentral/Thunder/actions/workflows/Test%20Thunder.yml/badge.svg)


Thunder (also known as Thunder) is an open-source plugin-based device abstraction layer, where business functionality can be implemented as plugins and applications can query and control those plugins. Using Thunder provides a consistent interface-driven development model for both plugins and client applications, with an RPC engine that is suited to both web-based and native apps.
Thunder is an open-source plugin-based device abstraction layer, where business functionality can be implemented as plugins and applications can query and control those plugins. Using Thunder provides a consistent interface-driven development model for both plugins and client applications, with an RPC engine that is suited to both web-based and native apps.

Designed from the ground up for embedded platforms and written in C++11, Thunder can be run on even the most low-power of devices (including ARM and MIPS-based platforms).

Expand Down
2 changes: 1 addition & 1 deletion Source/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ target_include_directories( ${TARGET}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/generated/core>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../> #core.h
$<INSTALL_INTERFACE:include/${NAMESPACE}>)
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE}>)

if(LIBRT_FOUND)
target_link_libraries(${TARGET}
Expand Down
2 changes: 1 addition & 1 deletion Source/cryptalgo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ target_include_directories( ${TARGET}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../>
$<INSTALL_INTERFACE:include/${NAMESPACE}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE}>
)

install(
Expand Down
2 changes: 1 addition & 1 deletion Source/extensions/localtracer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ target_compile_features(${MODULE_NAME} INTERFACE cxx_std_11)

install(TARGETS ${MODULE_NAME} EXPORT ${MODULE_NAME}Targets)

install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_INSTALL_INCLUDEDIR}/localtracer/localtracer.h
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/localtracer/localtracer.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE}/localtracer COMPONENT ${NAMESPACE}_Development)

include(HeaderOnlyInstall)
Expand Down
3 changes: 1 addition & 2 deletions Source/extensions/privilegedrequest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ target_compile_features(${MODULE_NAME} INTERFACE cxx_std_11)

install(TARGETS ${MODULE_NAME} EXPORT ${MODULE_NAME}Targets)

install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_INSTALL_INCLUDEDIR}/privilegedrequest/PrivilegedRequest.h
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/privilegedrequest/PrivilegedRequest.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE}/privilegedrequest COMPONENT ${NAMESPACE}_Development)

include(HeaderOnlyInstall)
Expand Down
2 changes: 1 addition & 1 deletion Source/extensions/processcontainers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ target_include_directories( ${TARGET}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../>
$<INSTALL_INTERFACE:include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

if (PROCESSCONTAINERS_LXC)
Expand Down
2 changes: 1 addition & 1 deletion Source/extensions/warningreporting/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ target_include_directories( ${TARGET}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../>
$<INSTALL_INTERFACE:include/${NAMESPACE}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE}>
)

install(
Expand Down
6 changes: 3 additions & 3 deletions Source/messaging/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ target_include_directories( ${TARGET}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../>
$<INSTALL_INTERFACE:include/${NAMESPACE}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE}>
)

install(
Expand All @@ -95,8 +95,8 @@ include(CreateLink)
InstallCompatibleCMakeConfig(
TARGET ${TARGET}
LEGACY_TARGET ${NAMESPACE}Tracing
LEGACY_INCLUDE_DIR "include/${NAMESPACE}"
LEGACY_PUBLIC_HEADER_LOCATION "include/${NAMESPACE}/tracing")
LEGACY_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE}"
LEGACY_PUBLIC_HEADER_LOCATION "${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE}/tracing")

createlink(
LINK ${CMAKE_CURRENT_BINARY_DIR}/tracing.h
Expand Down
2 changes: 1 addition & 1 deletion Source/plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ target_include_directories( ${TARGET}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/../>
$<INSTALL_INTERFACE:include/${NAMESPACE}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE}>
)

target_include_directories( ${TARGET_PROXYSTUBS}
Expand Down
2 changes: 1 addition & 1 deletion Source/websocket/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ target_include_directories( ${TARGET}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../>
$<INSTALL_INTERFACE:include/${NAMESPACE}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE}>
)

install(
Expand Down
39 changes: 30 additions & 9 deletions cmake/common/CmakeHelperFunctions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)

set(TEMPLATES_LOCATION_RELATIVE_FROM_ME "${CMAKE_CURRENT_LIST_DIR}/../templates/" CACHE INTERNAL "relative location to the templates from this file")

macro(add_element list element)
list(APPEND ${list} ${element})
endmacro()
Expand Down Expand Up @@ -317,7 +319,11 @@ function(InstallCMakeConfig)
if("${Argument_TEMPLATE}" STREQUAL "")
find_file( _config_template
NAMES "defaultConfig.cmake.in"
PATHS "${PROJECT_SOURCE_DIR}/cmake/templates" "${CMAKE_SYSROOT}/usr/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates" "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates"
PATHS
"${TEMPLATES_LOCATION_RELATIVE_FROM_ME}"
"${PROJECT_SOURCE_DIR}/cmake/templates"
"${CMAKE_SYSROOT}/usr/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates"
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates"
NO_DEFAULT_PATH
NO_CMAKE_ENVIRONMENT_PATH
NO_CMAKE_PATH
Expand All @@ -327,7 +333,11 @@ function(InstallCMakeConfig)

find_file(_config_template
NAMES "defaultConfig.cmake.in"
PATHS "${PROJECT_SOURCE_DIR}/cmake/templates" "${CMAKE_SYSROOT}/usr/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates" "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates" )
PATHS
"${TEMPLATES_LOCATION_RELATIVE_FROM_ME}"
"${PROJECT_SOURCE_DIR}/cmake/templates"
"${CMAKE_SYSROOT}/usr/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates"
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates" )

if(NOT EXISTS "${_config_template}")
message(SEND_ERROR "Config file generation failed, template '${_config_template}' not found")
Expand Down Expand Up @@ -457,12 +467,14 @@ function(InstallCMakeConfig)
install(EXPORT "${_target}Targets"
FILE "${_name}Targets.cmake"
NAMESPACE "${_name}::"
DESTINATION "${_install_path}/${_name}")
DESTINATION "${_install_path}/${_name}"
COMPONENT ${NAMESPACE}_Development)

install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/${_name}ConfigVersion.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${_name}Config.cmake"
DESTINATION "${_install_path}/${_name}")
DESTINATION "${_install_path}/${_name}"
COMPONENT ${NAMESPACE}_Development)
endforeach()
endfunction(InstallCMakeConfig)

Expand All @@ -480,7 +492,11 @@ function(InstallPackageConfig)
if("${Argument_TEMPLATE}" STREQUAL "")
find_file( _pc_template
NAMES "default.pc.in"
PATHS "${PROJECT_SOURCE_DIR}/cmake/templates" "${CMAKE_SYSROOT}/usr/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates" "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates"
PATHS
"${TEMPLATES_LOCATION_RELATIVE_FROM_ME}"
"${PROJECT_SOURCE_DIR}/cmake/templates"
"${CMAKE_SYSROOT}/usr/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates"
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates"
NO_DEFAULT_PATH
NO_CMAKE_ENVIRONMENT_PATH
NO_CMAKE_PATH
Expand All @@ -490,7 +506,11 @@ function(InstallPackageConfig)

find_file(_pc_template
NAMES "default.pc.in"
PATHS "${PROJECT_SOURCE_DIR}/cmake/templates" "${CMAKE_SYSROOT}/usr/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates" "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates")
PATHS
"${TEMPLATES_LOCATION_RELATIVE_FROM_ME}"
"${PROJECT_SOURCE_DIR}/cmake/templates"
"${CMAKE_SYSROOT}/usr/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates"
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates")

if(NOT EXISTS "${_pc_template}")
message(SEND_ERROR "PC file generation failed, template '${_pc_template}' not found")
Expand Down Expand Up @@ -615,7 +635,8 @@ function(InstallPackageConfig)
@ONLY)

install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${_pc_filename}"
DESTINATION "${_install_path}")
DESTINATION "${_install_path}"
COMPONENT ${NAMESPACE}_Development)
endforeach()
endfunction(InstallPackageConfig)

Expand All @@ -638,11 +659,11 @@ function(InstallFindModule)
else()
file(GLOB_RECURSE extra_files "${DIRECTORY}/*.cmake")
endif(Argument_RECURSE)
install(FILES "${extra_files}" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/modules)
install(FILES "${extra_files}" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/modules COMPONENT ${NAMESPACE}_Development)
endif()

if (Argument_FILES)
install(FILES "${Argument_FILES}" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/modules)
install(FILES "${Argument_FILES}" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/modules COMPONENT ${NAMESPACE}_Development)
endif()

endfunction(InstallFindModule)
Expand Down
39 changes: 30 additions & 9 deletions cmake/common/HeaderOnlyInstall.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
set(TEMPLATES_LOCATION_RELATIVE_FROM_ME "${CMAKE_CURRENT_LIST_DIR}/../templates/" CACHE INTERNAL "relative location to the templates from this file")

function(HeaderOnlyInstallCMakeConfig)
set(optionsArgs NO_SKIP_INTERFACE_LIBRARIES, TREAT_AS_NORMAL)
set(oneValueArgs LOCATION TEMPLATE TARGET)
Expand All @@ -9,7 +11,7 @@ function(HeaderOnlyInstallCMakeConfig)
message(FATAL_ERROR "Unknown keywords given to HeaderOnlyInstallCMakeConfig(): \"${Argument_UNPARSED_ARGUMENTS}\"")
endif()

set(_install_path "lib/cmake") # default path
set(_install_path "${CMAKE_INSTALL_LIBDIR}/cmake") # default path

set(TARGET ${Argument_TARGET})
set(NAME ${Argument_NAME})
Expand All @@ -21,7 +23,11 @@ function(HeaderOnlyInstallCMakeConfig)
if("${Argument_TEMPLATE}" STREQUAL "")
find_file( _config_template
NAMES "defaultConfig.cmake.in"
PATHS "${PROJECT_SOURCE_DIR}/cmake/templates" "${CMAKE_SYSROOT}/usr/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates" "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates"
PATHS
"${TEMPLATES_LOCATION_RELATIVE_FROM_ME}"
"${PROJECT_SOURCE_DIR}/cmake/templates"
"${CMAKE_SYSROOT}/usr/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates"
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates"
NO_DEFAULT_PATH
NO_CMAKE_ENVIRONMENT_PATH
NO_CMAKE_PATH
Expand All @@ -31,7 +37,11 @@ function(HeaderOnlyInstallCMakeConfig)

find_file(_config_template
NAMES "defaultConfig.cmake.in"
PATHS "${PROJECT_SOURCE_DIR}/cmake/templates" "${CMAKE_SYSROOT}/usr/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates" "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates" )
PATHS
"${TEMPLATES_LOCATION_RELATIVE_FROM_ME}"
"${PROJECT_SOURCE_DIR}/cmake/templates"
"${CMAKE_SYSROOT}/usr/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates"
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates" )

if(NOT EXISTS "${_config_template}")
message(SEND_ERROR "Config file generation failed, template '${_config_template}' not found")
Expand Down Expand Up @@ -151,12 +161,14 @@ function(HeaderOnlyInstallCMakeConfig)
EXPORT "${TARGET}Targets"
FILE "${_name}Targets.cmake"
NAMESPACE "${_name}::"
DESTINATION "${_install_path}/${_name}")
DESTINATION "${_install_path}/${_name}"
COMPONENT ${NAMESPACE}_Development)

install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/${_name}ConfigVersion.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${_name}Config.cmake"
DESTINATION "${_install_path}/${_name}")
DESTINATION "${_install_path}/${_name}"
COMPONENT ${NAMESPACE}_Development)

endfunction(HeaderOnlyInstallCMakeConfig)

Expand All @@ -174,7 +186,11 @@ function(HeaderOnlyInstallPackageConfig)
if("${Argument_TEMPLATE}" STREQUAL "")
find_file( _pc_template
NAMES "default.pc.in"
PATHS "${PROJECT_SOURCE_DIR}/cmake/templates" "${CMAKE_SYSROOT}/usr/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates" "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates"
PATHS
"${TEMPLATES_LOCATION_RELATIVE_FROM_ME}"
"${PROJECT_SOURCE_DIR}/cmake/templates"
"${CMAKE_SYSROOT}/usr/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates"
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates"
NO_DEFAULT_PATH
NO_CMAKE_ENVIRONMENT_PATH
NO_CMAKE_PATH
Expand All @@ -184,7 +200,11 @@ function(HeaderOnlyInstallPackageConfig)

find_file(_pc_template
NAMES "default.pc.in"
PATHS "${PROJECT_SOURCE_DIR}/cmake/templates" "${CMAKE_SYSROOT}/usr/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates" "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates")
PATHS
"${TEMPLATES_LOCATION_RELATIVE_FROM_ME}"
"${PROJECT_SOURCE_DIR}/cmake/templates"
"${CMAKE_SYSROOT}/usr/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates"
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE}/templates")

if(NOT EXISTS "${_pc_template}")
message(SEND_ERROR "PC file generation failed, template '${_pc_template}' not found")
Expand Down Expand Up @@ -229,7 +249,7 @@ function(HeaderOnlyInstallPackageConfig)
endif()

# Default path on UNIX, if you want Windows or Apple support add the path here. ;-)
set(_install_path "lib/pkgconfig")
set(_install_path "${CMAKE_INSTALL_LIBDIR}/pkgconfig")

if (${Argument_OUTPUT_NAME})
set(_pc_filename ${Argument_OUTPUT_NAME})
Expand Down Expand Up @@ -301,5 +321,6 @@ function(HeaderOnlyInstallPackageConfig)
@ONLY)

install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${_pc_filename}"
DESTINATION "${_install_path}")
DESTINATION "${_install_path}"
COMPONENT ${NAMESPACE}_Development)
endfunction(HeaderOnlyInstallPackageConfig)
2 changes: 1 addition & 1 deletion docs/introduction/build_linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The following instructions will use the `CMAKE_INSTALL_PREFIX` option to install
These instructions are based on Ubuntu 22.04 - you may need to change this for your distros package manager

```
sudo apt install build-essential cmake ninja-build libusb-1.0-0-dev zlib1g-dev libssl-dev
sudo apt install build-essential pkg-config cmake ninja-build libusb-1.0-0-dev zlib1g-dev libssl-dev
```

Thunder also uses Python 3 for code and documentation generation scripts. Ensure you have at least **Python 3.5** installed and install the [**jsonref**](https://pypi.org/project/jsonref/) library with pip:
Expand Down
2 changes: 0 additions & 2 deletions docs/introduction/intro.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# What is Thunder?
!!! note
The terms "**Thunder**" and "**Thunder**" may be used interchangeably throughout this documentation. The project was originally known as Thunder (since it was developed by the Web Platform for Embedded, or WPE, team). The name was changed to Thunder when it was incorporated into RDK, but the code still uses the name Thunder internally.

## Introduction

Expand Down

0 comments on commit 59bdf3d

Please sign in to comment.