From 59bdf3da67e564b5f21803bf28dd9174c61888f0 Mon Sep 17 00:00:00 2001 From: Bram Oosterhuis Date: Wed, 3 Jul 2024 16:18:22 +0200 Subject: [PATCH] Development/portable build (#1681) * 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 --- README.md | 2 +- Source/core/CMakeLists.txt | 2 +- Source/cryptalgo/CMakeLists.txt | 2 +- Source/extensions/localtracer/CMakeLists.txt | 2 +- .../privilegedrequest/CMakeLists.txt | 3 +- .../processcontainers/CMakeLists.txt | 2 +- .../warningreporting/CMakeLists.txt | 2 +- Source/messaging/CMakeLists.txt | 6 +-- Source/plugins/CMakeLists.txt | 2 +- Source/websocket/CMakeLists.txt | 2 +- cmake/common/CmakeHelperFunctions.cmake | 39 ++++++++++++++----- cmake/common/HeaderOnlyInstall.cmake | 39 ++++++++++++++----- docs/introduction/build_linux.md | 2 +- docs/introduction/intro.md | 2 - 14 files changed, 73 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 49ff9dbae7..b042667276 100644 --- a/README.md +++ b/README.md @@ -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). diff --git a/Source/core/CMakeLists.txt b/Source/core/CMakeLists.txt index bc3380d76d..a408e5adfc 100644 --- a/Source/core/CMakeLists.txt +++ b/Source/core/CMakeLists.txt @@ -252,7 +252,7 @@ target_include_directories( ${TARGET} PUBLIC $ $ #core.h - $) + $) if(LIBRT_FOUND) target_link_libraries(${TARGET} diff --git a/Source/cryptalgo/CMakeLists.txt b/Source/cryptalgo/CMakeLists.txt index eb42f04f61..2ca25af8cb 100644 --- a/Source/cryptalgo/CMakeLists.txt +++ b/Source/cryptalgo/CMakeLists.txt @@ -81,7 +81,7 @@ target_include_directories( ${TARGET} PUBLIC $ $ - $ + $ ) install( diff --git a/Source/extensions/localtracer/CMakeLists.txt b/Source/extensions/localtracer/CMakeLists.txt index a978c7e845..d51548ac5e 100644 --- a/Source/extensions/localtracer/CMakeLists.txt +++ b/Source/extensions/localtracer/CMakeLists.txt @@ -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) diff --git a/Source/extensions/privilegedrequest/CMakeLists.txt b/Source/extensions/privilegedrequest/CMakeLists.txt index a64eb7e6d8..21369ce91e 100644 --- a/Source/extensions/privilegedrequest/CMakeLists.txt +++ b/Source/extensions/privilegedrequest/CMakeLists.txt @@ -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) diff --git a/Source/extensions/processcontainers/CMakeLists.txt b/Source/extensions/processcontainers/CMakeLists.txt index 996b138342..b25939a346 100644 --- a/Source/extensions/processcontainers/CMakeLists.txt +++ b/Source/extensions/processcontainers/CMakeLists.txt @@ -85,7 +85,7 @@ target_include_directories( ${TARGET} PUBLIC $ $ - $ + $ ) if (PROCESSCONTAINERS_LXC) diff --git a/Source/extensions/warningreporting/CMakeLists.txt b/Source/extensions/warningreporting/CMakeLists.txt index 4e751ac725..c7f9d5f36f 100644 --- a/Source/extensions/warningreporting/CMakeLists.txt +++ b/Source/extensions/warningreporting/CMakeLists.txt @@ -57,7 +57,7 @@ target_include_directories( ${TARGET} PUBLIC $ $ - $ + $ ) install( diff --git a/Source/messaging/CMakeLists.txt b/Source/messaging/CMakeLists.txt index d8125bc442..e190eda829 100644 --- a/Source/messaging/CMakeLists.txt +++ b/Source/messaging/CMakeLists.txt @@ -72,7 +72,7 @@ target_include_directories( ${TARGET} PUBLIC $ $ - $ + $ ) install( @@ -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 diff --git a/Source/plugins/CMakeLists.txt b/Source/plugins/CMakeLists.txt index d973836719..a018bbc2f0 100644 --- a/Source/plugins/CMakeLists.txt +++ b/Source/plugins/CMakeLists.txt @@ -111,7 +111,7 @@ target_include_directories( ${TARGET} PUBLIC $ $ - $ + $ ) target_include_directories( ${TARGET_PROXYSTUBS} diff --git a/Source/websocket/CMakeLists.txt b/Source/websocket/CMakeLists.txt index 2f39a23b14..2a571b06eb 100644 --- a/Source/websocket/CMakeLists.txt +++ b/Source/websocket/CMakeLists.txt @@ -71,7 +71,7 @@ target_include_directories( ${TARGET} PUBLIC $ $ - $ + $ ) install( diff --git a/cmake/common/CmakeHelperFunctions.cmake b/cmake/common/CmakeHelperFunctions.cmake index 78fd3b245f..c071e235d6 100644 --- a/cmake/common/CmakeHelperFunctions.cmake +++ b/cmake/common/CmakeHelperFunctions.cmake @@ -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() @@ -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 @@ -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") @@ -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) @@ -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 @@ -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") @@ -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) @@ -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) diff --git a/cmake/common/HeaderOnlyInstall.cmake b/cmake/common/HeaderOnlyInstall.cmake index e2f5696821..53e0f84985 100644 --- a/cmake/common/HeaderOnlyInstall.cmake +++ b/cmake/common/HeaderOnlyInstall.cmake @@ -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) @@ -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}) @@ -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 @@ -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") @@ -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) @@ -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 @@ -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") @@ -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}) @@ -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) diff --git a/docs/introduction/build_linux.md b/docs/introduction/build_linux.md index c8ccb5373e..d677a310ff 100644 --- a/docs/introduction/build_linux.md +++ b/docs/introduction/build_linux.md @@ -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: diff --git a/docs/introduction/intro.md b/docs/introduction/intro.md index 3e2ed0d8e9..d343b14294 100644 --- a/docs/introduction/intro.md +++ b/docs/introduction/intro.md @@ -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