From 6abed7e370f4f080a18c1595dbec240fffbb6ddc Mon Sep 17 00:00:00 2001 From: Volker Christian Date: Thu, 30 Jul 2026 18:47:36 +0200 Subject: [PATCH 1/7] Centralize CMake component packaging --- .cmake-format.py | 23 +- .github/workflows/ci.yml | 20 +- CMakeLists.txt | 1 + cmake/Packing.cmake | 132 +-- cmake/SNodeCComponent.cmake | 1006 +++++++++++++++++ cmake/ValidateComponentPackages.cmake | 277 +++++ src/CMakeLists.txt | 59 +- src/apps/CMakeLists.txt | 51 +- src/apps/database/CMakeLists.txt | 5 +- src/apps/echo/CMakeLists.txt | 10 +- src/apps/http/CMakeLists.txt | 35 +- .../authorization_server/CMakeLists.txt | 5 +- src/apps/oauth2/client_app/CMakeLists.txt | 5 +- .../oauth2/resource_server/CMakeLists.txt | 5 +- src/apps/tlslegacy/CMakeLists.txt | 10 +- src/apps/towercalculator/CMakeLists.txt | 5 +- src/apps/websocket/CMakeLists.txt | 10 +- .../subprotocol/client/echo/CMakeLists.txt | 7 +- .../subprotocol/server/echo/CMakeLists.txt | 7 +- src/cmake/Config.cmake.in | 50 +- src/cmake/GetAllTargetsDependencies.cmake | 87 -- src/core/CMakeLists.txt | 48 +- src/core/multiplexer/epoll/CMakeLists.txt | 14 +- src/core/multiplexer/poll/CMakeLists.txt | 14 +- src/core/multiplexer/select/CMakeLists.txt | 14 +- src/core/socket/CMakeLists.txt | 31 +- src/core/socket/stream/CMakeLists.txt | 33 +- src/core/socket/stream/legacy/CMakeLists.txt | 28 +- src/core/socket/stream/tls/CMakeLists.txt | 31 +- src/database/mariadb/CMakeLists.txt | 25 +- src/express/CMakeLists.txt | 28 +- src/express/legacy/in/CMakeLists.txt | 29 +- src/express/legacy/in6/CMakeLists.txt | 29 +- src/express/legacy/rc/CMakeLists.txt | 28 +- src/express/legacy/un/CMakeLists.txt | 29 +- src/express/tls/in/CMakeLists.txt | 29 +- src/express/tls/in6/CMakeLists.txt | 29 +- src/express/tls/rc/CMakeLists.txt | 28 +- src/express/tls/un/CMakeLists.txt | 29 +- src/iot/mqtt/CMakeLists.txt | 38 +- src/iot/mqtt/client/CMakeLists.txt | 42 +- src/iot/mqtt/client/packets/CMakeLists.txt | 12 +- src/iot/mqtt/packets/CMakeLists.txt | 12 +- src/iot/mqtt/server/CMakeLists.txt | 47 +- src/iot/mqtt/server/broker/CMakeLists.txt | 12 +- src/iot/mqtt/server/packets/CMakeLists.txt | 12 +- src/iot/mqtt/types/CMakeLists.txt | 12 +- src/log/CMakeLists.txt | 26 +- src/net/CMakeLists.txt | 38 +- src/net/in/CMakeLists.txt | 33 +- src/net/in/phy/CMakeLists.txt | 31 +- src/net/in/phy/stream/CMakeLists.txt | 31 +- src/net/in/stream/CMakeLists.txt | 31 +- src/net/in/stream/legacy/CMakeLists.txt | 27 +- src/net/in/stream/tls/CMakeLists.txt | 27 +- src/net/in6/CMakeLists.txt | 33 +- src/net/in6/phy/CMakeLists.txt | 31 +- src/net/in6/phy/stream/CMakeLists.txt | 31 +- src/net/in6/stream/CMakeLists.txt | 31 +- src/net/in6/stream/legacy/CMakeLists.txt | 27 +- src/net/in6/stream/tls/CMakeLists.txt | 27 +- src/net/l2/CMakeLists.txt | 33 +- src/net/l2/phy/CMakeLists.txt | 31 +- src/net/l2/phy/stream/CMakeLists.txt | 31 +- src/net/l2/stream/CMakeLists.txt | 31 +- src/net/l2/stream/legacy/CMakeLists.txt | 27 +- src/net/l2/stream/tls/CMakeLists.txt | 27 +- src/net/rc/CMakeLists.txt | 33 +- src/net/rc/phy/CMakeLists.txt | 31 +- src/net/rc/phy/stream/CMakeLists.txt | 31 +- src/net/rc/stream/CMakeLists.txt | 31 +- src/net/rc/stream/legacy/CMakeLists.txt | 27 +- src/net/rc/stream/tls/CMakeLists.txt | 27 +- src/net/un/CMakeLists.txt | 33 +- src/net/un/dgram/CMakeLists.txt | 27 +- src/net/un/phy/CMakeLists.txt | 31 +- src/net/un/phy/stream/CMakeLists.txt | 31 +- src/net/un/stream/CMakeLists.txt | 31 +- src/net/un/stream/legacy/CMakeLists.txt | 27 +- src/net/un/stream/tls/CMakeLists.txt | 27 +- src/tools/snodec-control/CMakeLists.txt | 4 + src/tools/snodec-control/src/CMakeLists.txt | 11 +- src/utils/CMakeLists.txt | 26 +- src/web/http/CMakeLists.txt | 43 +- src/web/http/client/CMakeLists.txt | 52 +- src/web/http/server/CMakeLists.txt | 49 +- src/web/websocket/CMakeLists.txt | 40 +- src/web/websocket/client/CMakeLists.txt | 29 +- src/web/websocket/server/CMakeLists.txt | 29 +- tests/CMakeLists.txt | 26 + tests/ComponentPackagingTest.cmake | 224 ++++ tests/ComponentRegistryValidationTest.cmake | 192 ++++ 92 files changed, 2608 insertions(+), 1601 deletions(-) create mode 100644 cmake/SNodeCComponent.cmake create mode 100644 cmake/ValidateComponentPackages.cmake delete mode 100644 src/cmake/GetAllTargetsDependencies.cmake create mode 100644 tests/ComponentPackagingTest.cmake create mode 100644 tests/ComponentRegistryValidationTest.cmake diff --git a/.cmake-format.py b/.cmake-format.py index ae6205141c..dfa91bffa2 100644 --- a/.cmake-format.py +++ b/.cmake-format.py @@ -4,8 +4,26 @@ with section("parse"): # Specify structure for custom cmake functions - additional_commands = { 'foo': { 'flags': ['BAR', 'BAZ'], - 'kwargs': {'DEPENDS': '*', 'HEADERS': '*', 'SOURCES': '*'}}} + additional_commands = { + 'snodec_install_component_development_files': { + 'kwargs': {'COMPONENT': 1, 'DESTINATION': 1, 'FILES': '*'}}, + 'snodec_install_component_headers': { + 'kwargs': {'COMPONENT': 1, 'DESTINATION': 1, 'DIRECTORY': 1, + 'EXCLUDE_PATTERNS': '*', 'FILES': '*', 'PATTERNS': '*'}}, + 'snodec_add_component': { + 'flags': ['PUBLIC_COMPONENT'], + 'kwargs': {'ARCHIVE_DESTINATION': 1, 'COMPONENT': 1, 'DEPENDS': '*', + 'DESCRIPTION': 1, 'DEVELOPMENT_DEPENDS': '*', + 'DISPLAY_NAME': 1, 'EXPORT_DESTINATION': 1, + 'LIBRARY_DESTINATION': 1, 'RUNTIME_DESTINATION': 1, + 'TARGET': 1}}, + 'snodec_install_runtime_targets': { + 'kwargs': {'COMPONENT': 1, 'LIBRARY_DESTINATION': 1, + 'RUNTIME_DESTINATION': 1, 'TARGETS': '*'}}, + 'snodec_register_runtime_component': { + 'kwargs': {'COMPONENT': 1, 'DEPENDS': '*', 'DESCRIPTION': 1, + 'DISPLAY_NAME': 1}} + } # Override configurations per-command where available override_spec = {} @@ -238,4 +256,3 @@ # A dictionary containing any per-command configuration overrides. Currently # only `command_case` is supported. per_command = {} - diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 15140d12aa..61e8c47ab7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,6 +32,7 @@ jobs: sudo apt-get update sudo apt-get install -y \ cmake \ + dpkg-dev \ g++ \ libbluetooth-dev \ libmagic-dev \ @@ -41,10 +42,27 @@ jobs: pkg-config - name: Configure - run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DSNODEC_BUILD_TESTS=ON -DSNODEC_BUILD_APPS=ON + run: >- + cmake -S . -B build + -DCMAKE_BUILD_TYPE=Debug + -DCMAKE_INSTALL_PREFIX=/usr + -DSNODEC_BUILD_TESTS=ON + -DSNODEC_BUILD_APPS=ON - name: Build run: cmake --build build --parallel 2 - name: Tests run: ctest --test-dir build --output-on-failure + + - name: Component packages + run: | + rm -rf build/_packages + cpack --config build/CPackConfig.cmake -G DEB + + - name: Validate component packages + run: | + cmake \ + -DPACKAGE_DIR=${{ github.workspace }}/build/_packages \ + -DCPACK_CONFIG=${{ github.workspace }}/build/CPackConfig.cmake \ + -P cmake/ValidateComponentPackages.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 819c060ff2..0818876bc0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,6 +54,7 @@ include(format) include(doxygen) include(uninstall) include(graphwiz) +include(SNodeCComponent) option(SNODEC_BUILD_TESTS "Build SNode.C tests" OFF) option(SNODEC_BUILD_APPS "Build SNode.C apps" ON) diff --git a/cmake/Packing.cmake b/cmake/Packing.cmake index 7ea97336ce..4b5d159575 100644 --- a/cmake/Packing.cmake +++ b/cmake/Packing.cmake @@ -37,26 +37,27 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -# these are cache variables, so they could be overwritten with -D, set(CPACK_PACKAGE_NAME ${PROJECT_NAME} CACHE STRING "The resulting package name" ) - set(CPACK_PACKAGE_CONTACT "me@vchrist.at") set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Volker Christian <${CPACK_PACKAGE_CONTACT}>" ) set(CPACK_PACKAGE_VENDOR "Volker Christian") -set(CPACK_VERBATIM_VARIABLES YES) - -set(CPACK_STRIP_FILES YES) +option(SNODEC_PACKAGE_STRIP "Strip binaries in generated packages" OFF) +set(SNODEC_PACKAGE_INSTALL_PREFIX + "/usr" + CACHE PATH "Installation prefix inside generated binary packages" +) +set(CPACK_VERBATIM_VARIABLES YES) +set(CPACK_STRIP_FILES ${SNODEC_PACKAGE_STRIP}) set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME}) set(CPACK_OUTPUT_FILE_PREFIX "${CMAKE_BINARY_DIR}/_packages") - -set(CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") +set(CPACK_PACKAGING_INSTALL_PREFIX "${SNODEC_PACKAGE_INSTALL_PREFIX}") set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}) set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR}) @@ -97,120 +98,13 @@ set( set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS ON) set(CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS ON) - set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT) - -set(CPACK_COMPONENTS_GROUPING ONE_PER_GROUP) +set(CPACK_COMPONENTS_GROUPING IGNORE) set(CPACK_DEB_COMPONENT_INSTALL YES) -get_cmake_property(CPACK_COMPONENTS_ALL COMPONENTS) -list(REMOVE_ITEM CPACK_COMPONENTS_ALL notneeded) -# CMake 3.28 omits this existing Unix-domain component from the global -# COMPONENTS property even though its install rule is configured. Normalize -# the published component model across supported CMake versions. -list(APPEND CPACK_COMPONENTS_ALL net-un-sphy-tream) -list(REMOVE_DUPLICATES CPACK_COMPONENTS_ALL) -list(SORT CPACK_COMPONENTS_ALL) +# Component ownership and dependency metadata are registered next to the +# corresponding targets. This final step only validates and materializes that +# distributed component model for CPack. +snodec_finalize_cpack_components() include(CPack) - -cpack_add_component(logger) -cpack_add_component(utils DEPENDS logger) - -cpack_add_component(mux-epoll) -cpack_add_component(mux-poll) -cpack_add_component(mux-select) - -cpack_add_component(core DEPENDS mux-${IO_Multiplexer} utils) -cpack_add_component(core-socket DEPENDS core) -cpack_add_component(core-socket-stream DEPENDS core-socket) -cpack_add_component(core-socket-stream-legacy DEPENDS core-socket-stream) -cpack_add_component(core-socket-stream-tls DEPENDS core-socket-stream) - -cpack_add_component(net) - -cpack_add_component(net-in DEPENDS net) -cpack_add_component(net-in6 DEPENDS net) -cpack_add_component(net-l2 DEPENDS net) -cpack_add_component(net-rc DEPENDS net) -cpack_add_component(net-un DEPENDS net) - -cpack_add_component(net-in-stream DEPENDS net-in) -cpack_add_component(net-in6-stream DEPENDS net-in6) -cpack_add_component(net-l2-stream DEPENDS net-l2) -cpack_add_component(net-rc-stream DEPENDS net-rc) -cpack_add_component(net-un-stream DEPENDS net-un) - -cpack_add_component( - net-in-stream-legacy DEPENDS net-in-stream core-socket-stream-legacy -) -cpack_add_component( - net-in6-stream-legacy DEPENDS net-in6-stream core-socket-stream-legacy -) -cpack_add_component( - net-l2-stream-legacy DEPENDS net-l2-stream core-socket-stream-legacy -) -cpack_add_component( - net-rc-stream-legacy DEPENDS net-rc-stream core-socket-stream-legacy -) -cpack_add_component( - net-un-stream-legacy DEPENDS net-un-stream core-socket-stream-legacy -) - -cpack_add_component( - net-in-stream-tls DEPENDS net-in-stream core-socket-stream-tls -) -cpack_add_component( - net-in6-stream-tls DEPENDS net-in6-stream core-socket-stream-tls -) -cpack_add_component( - net-l2-stream-tls DEPENDS net-l2-stream core-socket-stream-tls -) -cpack_add_component( - net-rc-stream-tls DEPENDS net-rc-stream core-socket-stream-tls -) -cpack_add_component( - net-un-stream-tls DEPENDS net-un-stream core-socket-stream-tls -) - -cpack_add_component(net-un-dgram DEPENDS net-un) - -cpack_add_component(http) -cpack_add_component(http-server DEPENDS http) -cpack_add_component(http-client DEPENDS http) -cpack_add_component(http-server-express DEPENDS http-server) - -cpack_add_component(websocket) -cpack_add_component(websocket-server DEPENDS websocket http-server) -cpack_add_component(websocket-client DEPENDS websocket http-client) - -cpack_add_component(mqtt) -cpack_add_component(mqtt-server DEPENDS mqtt) -cpack_add_component(mqtt-client DEPENDS mqtt) - -cpack_add_component(mqtt-fast) - -cpack_add_component(db-mariadb DEPENDS core) - -cpack_add_component( - apps - DISPLAY_NAME "Applications" - DESCRIPTION "We install Applications" - DEPENDS http-server-express - http-client - net-in-stream-tls - net-in6-stream-tls - net-l2-stream-tls - net-rc-stream-tls - net-un-stream-tls - net-in-stream-legacy - net-in6-stream-legacy - net-l2-stream-legacy - net-rc-stream-legacy - net-un-stream-legacy - core-socket-stream-legacy - core-socket-stream-tls - websocket-server - websocket-client - db-mariadb -) diff --git a/cmake/SNodeCComponent.cmake b/cmake/SNodeCComponent.cmake new file mode 100644 index 0000000000..503ab5becf --- /dev/null +++ b/cmake/SNodeCComponent.cmake @@ -0,0 +1,1006 @@ +# SNode.C - A Slim Toolkit for Network Communication +# Copyright (C) Volker Christian +# 2020, 2021, 2022, 2023, 2024, 2025, 2026 +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program. If not, see . +# +# --------------------------------------------------------------------------- +# +# MIT License +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +include_guard(GLOBAL) + +include(CMakeParseArguments) +include(CPackComponent) +include(GNUInstallDirs) + +# Every component is declared where its target is declared. These helpers own +# the runtime/development split, CMake exports, CPack metadata, package +# dependencies, and the public find_package() component registry. + +function(_snodec_component_key component result) + string(MAKE_C_IDENTIFIER "${component}" component_key) + string(TOUPPER "${component_key}" component_key) + set(${result} "${component_key}" PARENT_SCOPE) +endfunction() + +function(_snodec_validate_arguments prefix command_name) + if(${prefix}_UNPARSED_ARGUMENTS) + message( + FATAL_ERROR + "${command_name} received unknown arguments: ${${prefix}_UNPARSED_ARGUMENTS}" + ) + endif() + if(${prefix}_KEYWORDS_MISSING_VALUES) + message( + FATAL_ERROR + "${command_name} is missing values for: ${${prefix}_KEYWORDS_MISSING_VALUES}" + ) + endif() +endfunction() + +function(_snodec_component_property component property result) + _snodec_component_key("${component}" component_key) + get_property( + property_value GLOBAL + PROPERTY "SNODEC_COMPONENT_${component_key}_${property}" + ) + set(${result} "${property_value}" PARENT_SCOPE) +endfunction() + +function(_snodec_set_component_property component property) + _snodec_component_key("${component}" component_key) + set_property( + GLOBAL PROPERTY "SNODEC_COMPONENT_${component_key}_${property}" ${ARGN} + ) +endfunction() + +function(_snodec_append_component_property component property) + _snodec_component_key("${component}" component_key) + set_property( + GLOBAL APPEND + PROPERTY "SNODEC_COMPONENT_${component_key}_${property}" ${ARGN} + ) +endfunction() + +function(_snodec_record_install_component component) + set_property( + GLOBAL APPEND PROPERTY SNODEC_REFERENCED_INSTALL_COMPONENTS + "${component}" + ) +endfunction() + +function(_snodec_record_shlibdeps_private_directory target) + _snodec_real_target("${target}" real_target) + get_target_property(target_type "${real_target}" TYPE) + if(NOT target_type MATCHES "^(SHARED|MODULE)_LIBRARY$") + return() + endif() + + get_target_property( + library_output_directory "${real_target}" LIBRARY_OUTPUT_DIRECTORY + ) + get_target_property(target_binary_directory "${real_target}" BINARY_DIR) + if(NOT library_output_directory + OR library_output_directory STREQUAL + "library_output_directory-NOTFOUND" + ) + set(library_output_directory "${target_binary_directory}") + elseif(NOT IS_ABSOLUTE "${library_output_directory}") + get_filename_component( + library_output_directory "${library_output_directory}" ABSOLUTE + BASE_DIR "${target_binary_directory}" + ) + endif() + + set_property( + GLOBAL APPEND PROPERTY SNODEC_SHLIBDEPS_PRIVATE_DIRS + "${library_output_directory}" + ) +endfunction() + +function(_snodec_real_target target result) + get_target_property(aliased_target "${target}" ALIASED_TARGET) + if(aliased_target + AND NOT aliased_target STREQUAL "aliased_target-NOTFOUND" + ) + set(${result} "${aliased_target}" PARENT_SCOPE) + else() + set(${result} "${target}" PARENT_SCOPE) + endif() +endfunction() + +function(_snodec_set_target_component target component) + if(NOT TARGET "${target}") + message(FATAL_ERROR "Unknown SNode.C target '${target}'") + endif() + + _snodec_real_target("${target}" real_target) + get_property( + component_is_set TARGET "${real_target}" PROPERTY SNODEC_COMPONENT SET + ) + if(component_is_set) + get_target_property( + existing_component "${real_target}" SNODEC_COMPONENT + ) + if(NOT existing_component STREQUAL component) + message( + FATAL_ERROR + "Target '${target}' already belongs to SNode.C component '${existing_component}'" + ) + endif() + return() + endif() + + set_property( + TARGET "${real_target}" PROPERTY SNODEC_COMPONENT "${component}" + ) +endfunction() + +function(_snodec_register_component) + set(options PUBLIC RUNTIME_ONLY) + set(one_value_arguments COMPONENT DISPLAY_NAME DESCRIPTION) + set(multi_value_arguments DEPENDS DEVELOPMENT_DEPENDS TARGETS) + cmake_parse_arguments( + ARG "${options}" "${one_value_arguments}" "${multi_value_arguments}" + ${ARGN} + ) + _snodec_validate_arguments(ARG "_snodec_register_component") + + if(NOT ARG_COMPONENT) + message(FATAL_ERROR "COMPONENT is required") + endif() + if(ARG_COMPONENT MATCHES "-dev$") + message( + FATAL_ERROR + "SNode.C base component '${ARG_COMPONENT}' uses the reserved '-dev' suffix" + ) + endif() + if(ARG_PUBLIC AND ARG_RUNTIME_ONLY) + message( + FATAL_ERROR + "Runtime-only component '${ARG_COMPONENT}' cannot be a public find_package() component" + ) + endif() + if(NOT ARG_TARGETS) + message( + FATAL_ERROR + "SNode.C component '${ARG_COMPONENT}' has no associated targets" + ) + endif() + + get_property(registered_components GLOBAL PROPERTY SNODEC_BASE_COMPONENTS) + if(ARG_COMPONENT IN_LIST registered_components) + message( + FATAL_ERROR + "SNode.C component '${ARG_COMPONENT}' is registered twice" + ) + endif() + + _snodec_component_key("${ARG_COMPONENT}" component_key) + get_property( + keyed_component GLOBAL + PROPERTY "SNODEC_COMPONENT_${component_key}_NAME" + ) + if(keyed_component AND NOT keyed_component STREQUAL ARG_COMPONENT) + message( + FATAL_ERROR + "SNode.C components '${ARG_COMPONENT}' and '${keyed_component}' map to the same registry key" + ) + endif() + + list(REMOVE_ITEM ARG_DEPENDS "${ARG_COMPONENT}") + list(REMOVE_ITEM ARG_DEVELOPMENT_DEPENDS "${ARG_COMPONENT}") + list(REMOVE_DUPLICATES ARG_DEPENDS) + list(REMOVE_DUPLICATES ARG_DEVELOPMENT_DEPENDS) + list(REMOVE_DUPLICATES ARG_TARGETS) + + set_property( + GLOBAL APPEND PROPERTY SNODEC_BASE_COMPONENTS "${ARG_COMPONENT}" + ) + _snodec_set_component_property("${ARG_COMPONENT}" NAME "${ARG_COMPONENT}") + _snodec_set_component_property( + "${ARG_COMPONENT}" DISPLAY_NAME "${ARG_DISPLAY_NAME}" + ) + _snodec_set_component_property( + "${ARG_COMPONENT}" DESCRIPTION "${ARG_DESCRIPTION}" + ) + _snodec_set_component_property( + "${ARG_COMPONENT}" RUNTIME_ONLY "${ARG_RUNTIME_ONLY}" + ) + _snodec_set_component_property( + "${ARG_COMPONENT}" EXPLICIT_RUNTIME_DEPENDS ${ARG_DEPENDS} + ) + _snodec_set_component_property( + "${ARG_COMPONENT}" + EXPLICIT_DEVELOPMENT_DEPENDS + ${ARG_DEVELOPMENT_DEPENDS} + ) + _snodec_set_component_property( + "${ARG_COMPONENT}" TARGETS ${ARG_TARGETS} + ) + + foreach(target IN LISTS ARG_TARGETS) + _snodec_set_target_component("${target}" "${ARG_COMPONENT}") + endforeach() + + if(ARG_PUBLIC) + set_property( + GLOBAL APPEND PROPERTY SNODEC_PUBLIC_COMPONENTS "${ARG_COMPONENT}" + ) + endif() +endfunction() + +function(_snodec_unwrap_link_item link_item result) + set(unwrapped_link_item "${link_item}") + set(previous_link_item) + + while(NOT unwrapped_link_item STREQUAL previous_link_item) + set(previous_link_item "${unwrapped_link_item}") + if(unwrapped_link_item MATCHES "^\\$]+)>$") + set(unwrapped_link_item "${CMAKE_MATCH_1}") + elseif(unwrapped_link_item MATCHES + "^\\$]+)>$" + ) + set(unwrapped_link_item "${CMAKE_MATCH_1}") + elseif(unwrapped_link_item MATCHES + "^\\$]+)>$" + ) + set(unwrapped_link_item "${CMAKE_MATCH_1}") + elseif(unwrapped_link_item MATCHES + "^\\$]+)>$" + ) + set(unwrapped_link_item "${CMAKE_MATCH_1}") + endif() + endwhile() + + set(${result} "${unwrapped_link_item}" PARENT_SCOPE) +endfunction() + +function( + _snodec_collect_target_component_dependencies + target + own_component + dependency_kind + result +) + if(NOT TARGET "${target}") + message(FATAL_ERROR "Unknown SNode.C target '${target}'") + endif() + if(NOT dependency_kind MATCHES "^(RUNTIME|DEVELOPMENT)$") + message( + FATAL_ERROR + "Unknown SNode.C dependency kind '${dependency_kind}'" + ) + endif() + + _snodec_real_target("${target}" real_target) + set(pending_targets "${real_target}") + set(visited_targets) + set(component_dependencies) + + while(pending_targets) + list(POP_FRONT pending_targets current_target) + _snodec_real_target("${current_target}" current_target) + if(current_target IN_LIST visited_targets) + continue() + endif() + list(APPEND visited_targets "${current_target}") + + get_target_property(target_type "${current_target}" TYPE) + if(dependency_kind STREQUAL "DEVELOPMENT" + OR target_type STREQUAL "INTERFACE_LIBRARY" + ) + set(link_property INTERFACE_LINK_LIBRARIES) + else() + set(link_property LINK_LIBRARIES) + endif() + get_target_property( + link_libraries "${current_target}" "${link_property}" + ) + + if(NOT link_libraries + OR link_libraries STREQUAL "link_libraries-NOTFOUND" + ) + continue() + endif() + + foreach(link_item IN LISTS link_libraries) + _snodec_unwrap_link_item("${link_item}" dependency_target) + if(NOT TARGET "${dependency_target}") + continue() + endif() + + _snodec_real_target("${dependency_target}" dependency_target) + get_target_property( + dependency_component "${dependency_target}" SNODEC_COMPONENT + ) + if(dependency_component + AND NOT dependency_component STREQUAL + "dependency_component-NOTFOUND" + ) + if(NOT dependency_component STREQUAL own_component) + list( + APPEND component_dependencies + "${dependency_component}" + ) + continue() + endif() + endif() + + get_target_property( + dependency_imported "${dependency_target}" IMPORTED + ) + if(dependency_imported) + continue() + endif() + + get_target_property( + dependency_type "${dependency_target}" TYPE + ) + if(NOT dependency_component + AND dependency_type MATCHES "^(SHARED|MODULE)_LIBRARY$" + ) + message( + FATAL_ERROR + "Target '${current_target}' links unpackaged shared target '${dependency_target}'" + ) + endif() + list(APPEND pending_targets "${dependency_target}") + endforeach() + endwhile() + + list(REMOVE_DUPLICATES component_dependencies) + list(SORT component_dependencies) + set(${result} "${component_dependencies}" PARENT_SCOPE) +endfunction() + +function( + _snodec_validate_component_dependency_visit + component + dependency_kind + component_path +) + _snodec_component_key("${component}" component_key) + set(state_property + "SNODEC_${dependency_kind}_COMPONENT_GRAPH_${component_key}_STATE" + ) + get_property(component_state GLOBAL PROPERTY "${state_property}") + + if(component_state STREQUAL "VISITING") + list(APPEND component_path "${component}") + string(JOIN " -> " cycle_path ${component_path}) + string(TOLOWER "${dependency_kind}" dependency_kind_label) + message( + FATAL_ERROR + "Cyclic SNode.C ${dependency_kind_label} component dependency: ${cycle_path}" + ) + endif() + if(component_state STREQUAL "VISITED") + return() + endif() + + set_property(GLOBAL PROPERTY "${state_property}" VISITING) + list(APPEND component_path "${component}") + + _snodec_component_dependencies( + "${component}" "${dependency_kind}" component_dependencies + ) + get_property(registered_components GLOBAL PROPERTY SNODEC_BASE_COMPONENTS) + foreach(dependency IN LISTS component_dependencies) + if(NOT dependency IN_LIST registered_components) + message( + FATAL_ERROR + "SNode.C component '${component}' depends on unregistered component '${dependency}'" + ) + endif() + _snodec_validate_component_dependency_visit( + "${dependency}" "${dependency_kind}" "${component_path}" + ) + endforeach() + + set_property(GLOBAL PROPERTY "${state_property}" VISITED) +endfunction() + +function(_snodec_validate_component_dependency_graph dependency_kind) + if(NOT dependency_kind MATCHES "^(RUNTIME|DEVELOPMENT)$") + message( + FATAL_ERROR + "Unknown SNode.C dependency kind '${dependency_kind}'" + ) + endif() + + get_property(registered_components GLOBAL PROPERTY SNODEC_BASE_COMPONENTS) + list(REMOVE_DUPLICATES registered_components) + foreach(component IN LISTS registered_components) + _snodec_component_key("${component}" component_key) + set_property( + GLOBAL + PROPERTY + "SNODEC_${dependency_kind}_COMPONENT_GRAPH_${component_key}_STATE" + "" + ) + endforeach() + + foreach(component IN LISTS registered_components) + _snodec_validate_component_dependency_visit( + "${component}" "${dependency_kind}" "" + ) + endforeach() +endfunction() + +function(_snodec_component_dependencies component dependency_kind result) + _snodec_component_property("${component}" TARGETS component_targets) + + if(dependency_kind STREQUAL "RUNTIME") + _snodec_component_property( + "${component}" + EXPLICIT_RUNTIME_DEPENDS + component_dependencies + ) + elseif(dependency_kind STREQUAL "DEVELOPMENT") + _snodec_component_property( + "${component}" + EXPLICIT_DEVELOPMENT_DEPENDS + component_dependencies + ) + else() + message( + FATAL_ERROR + "Unknown SNode.C dependency kind '${dependency_kind}'" + ) + endif() + + foreach(target IN LISTS component_targets) + _snodec_collect_target_component_dependencies( + "${target}" + "${component}" + "${dependency_kind}" + target_component_dependencies + ) + list(APPEND component_dependencies ${target_component_dependencies}) + endforeach() + + list(REMOVE_ITEM component_dependencies "${component}") + list(REMOVE_DUPLICATES component_dependencies) + list(SORT component_dependencies) + set(${result} "${component_dependencies}" PARENT_SCOPE) +endfunction() + +function(snodec_add_component) + set(options PUBLIC_COMPONENT) + set( + one_value_arguments + TARGET + COMPONENT + RUNTIME_DESTINATION + LIBRARY_DESTINATION + ARCHIVE_DESTINATION + EXPORT_DESTINATION + DISPLAY_NAME + DESCRIPTION + ) + set(multi_value_arguments DEPENDS DEVELOPMENT_DEPENDS) + cmake_parse_arguments( + ARG "${options}" "${one_value_arguments}" "${multi_value_arguments}" + ${ARGN} + ) + _snodec_validate_arguments(ARG "snodec_add_component") + + if(NOT ARG_TARGET) + message(FATAL_ERROR "TARGET is required") + endif() + if(NOT TARGET "${ARG_TARGET}") + message(FATAL_ERROR "Unknown SNode.C target '${ARG_TARGET}'") + endif() + + _snodec_real_target("${ARG_TARGET}" real_target) + get_target_property(target_type "${real_target}" TYPE) + if(NOT target_type STREQUAL "SHARED_LIBRARY") + message( + FATAL_ERROR + "snodec_add_component expects a shared library, got '${ARG_TARGET}' (${target_type})" + ) + endif() + _snodec_record_shlibdeps_private_directory("${real_target}") + + if(NOT ARG_COMPONENT) + set(ARG_COMPONENT "${ARG_TARGET}") + endif() + if(NOT ARG_RUNTIME_DESTINATION) + set(ARG_RUNTIME_DESTINATION "${CMAKE_INSTALL_BINDIR}") + endif() + if(NOT ARG_LIBRARY_DESTINATION) + set(ARG_LIBRARY_DESTINATION "${CMAKE_INSTALL_LIBDIR}") + endif() + if(NOT ARG_ARCHIVE_DESTINATION) + set(ARG_ARCHIVE_DESTINATION "${ARG_LIBRARY_DESTINATION}") + endif() + if(NOT ARG_EXPORT_DESTINATION) + set(ARG_EXPORT_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/snodec") + endif() + + set( + register_arguments + COMPONENT "${ARG_COMPONENT}" + TARGETS "${real_target}" + ) + if(ARG_DISPLAY_NAME) + list(APPEND register_arguments DISPLAY_NAME "${ARG_DISPLAY_NAME}") + endif() + if(ARG_DESCRIPTION) + list(APPEND register_arguments DESCRIPTION "${ARG_DESCRIPTION}") + endif() + if(ARG_DEPENDS) + list(APPEND register_arguments DEPENDS ${ARG_DEPENDS}) + endif() + if(ARG_DEVELOPMENT_DEPENDS) + list( + APPEND register_arguments DEVELOPMENT_DEPENDS + ${ARG_DEVELOPMENT_DEPENDS} + ) + endif() + if(ARG_PUBLIC_COMPONENT) + list(APPEND register_arguments PUBLIC) + endif() + _snodec_register_component(${register_arguments}) + + set(development_component "${ARG_COMPONENT}-dev") + set(export_set "snodec_${ARG_COMPONENT}_Targets") + _snodec_record_install_component("${ARG_COMPONENT}") + _snodec_record_install_component("${development_component}") + + install( + TARGETS "${real_target}" + EXPORT "${export_set}" + RUNTIME DESTINATION "${ARG_RUNTIME_DESTINATION}" + COMPONENT "${ARG_COMPONENT}" + LIBRARY DESTINATION "${ARG_LIBRARY_DESTINATION}" + COMPONENT "${ARG_COMPONENT}" + NAMELINK_COMPONENT "${development_component}" + ARCHIVE DESTINATION "${ARG_ARCHIVE_DESTINATION}" + COMPONENT "${development_component}" + BUNDLE DESTINATION "${ARG_RUNTIME_DESTINATION}" + COMPONENT "${ARG_COMPONENT}" + ) + + install( + EXPORT "${export_set}" + FILE "${export_set}.cmake" + NAMESPACE snodec:: + DESTINATION "${ARG_EXPORT_DESTINATION}" + COMPONENT "${development_component}" + ) +endfunction() + +function(snodec_install_component_headers) + set(options) + set(one_value_arguments COMPONENT DIRECTORY DESTINATION) + set(multi_value_arguments FILES PATTERNS EXCLUDE_PATTERNS) + cmake_parse_arguments( + ARG "${options}" "${one_value_arguments}" "${multi_value_arguments}" + ${ARGN} + ) + _snodec_validate_arguments(ARG "snodec_install_component_headers") + + if(NOT ARG_COMPONENT) + message(FATAL_ERROR "COMPONENT is required") + endif() + if(ARG_COMPONENT MATCHES "-dev$") + message( + FATAL_ERROR + "Use the base component name, not '${ARG_COMPONENT}', for development files" + ) + endif() + if(NOT ARG_DESTINATION) + message( + FATAL_ERROR + "DESTINATION is required for component '${ARG_COMPONENT}'" + ) + endif() + if(ARG_DIRECTORY AND ARG_FILES) + message( + FATAL_ERROR + "Use either DIRECTORY or FILES for component '${ARG_COMPONENT}'" + ) + endif() + if(NOT ARG_DIRECTORY AND NOT ARG_FILES) + message( + FATAL_ERROR + "DIRECTORY or FILES is required for component '${ARG_COMPONENT}'" + ) + endif() + + set(development_component "${ARG_COMPONENT}-dev") + _snodec_record_install_component("${development_component}") + + if(ARG_FILES) + install( + FILES ${ARG_FILES} + DESTINATION "${ARG_DESTINATION}" + COMPONENT "${development_component}" + ) + return() + endif() + + set(source_directory "${ARG_DIRECTORY}") + string(REGEX REPLACE "/+$" "" source_directory "${source_directory}") + + set(pattern_arguments) + if(ARG_PATTERNS OR ARG_EXCLUDE_PATTERNS) + list(APPEND pattern_arguments FILES_MATCHING) + endif() + foreach(pattern IN LISTS ARG_PATTERNS) + list(APPEND pattern_arguments PATTERN "${pattern}") + endforeach() + foreach(pattern IN LISTS ARG_EXCLUDE_PATTERNS) + list(APPEND pattern_arguments PATTERN "${pattern}" EXCLUDE) + endforeach() + + install( + DIRECTORY "${source_directory}/" + DESTINATION "${ARG_DESTINATION}" + COMPONENT "${development_component}" + ${pattern_arguments} + ) +endfunction() + +function(snodec_install_component_development_files) + set(options) + set(one_value_arguments COMPONENT DESTINATION) + set(multi_value_arguments FILES) + cmake_parse_arguments( + ARG "${options}" "${one_value_arguments}" "${multi_value_arguments}" + ${ARGN} + ) + _snodec_validate_arguments( + ARG "snodec_install_component_development_files" + ) + + if(NOT ARG_COMPONENT) + message(FATAL_ERROR "COMPONENT is required") + endif() + if(NOT ARG_FILES) + message(FATAL_ERROR "FILES is required") + endif() + + snodec_install_component_headers( + COMPONENT "${ARG_COMPONENT}" + FILES ${ARG_FILES} + DESTINATION "${ARG_DESTINATION}" + ) +endfunction() + +function(snodec_install_runtime_targets) + set(options) + set(one_value_arguments COMPONENT RUNTIME_DESTINATION LIBRARY_DESTINATION) + set(multi_value_arguments TARGETS) + cmake_parse_arguments( + ARG "${options}" "${one_value_arguments}" "${multi_value_arguments}" + ${ARGN} + ) + _snodec_validate_arguments(ARG "snodec_install_runtime_targets") + + if(NOT ARG_COMPONENT) + message(FATAL_ERROR "COMPONENT is required") + endif() + if(NOT ARG_TARGETS) + message(FATAL_ERROR "TARGETS is required") + endif() + if(NOT ARG_RUNTIME_DESTINATION) + set(ARG_RUNTIME_DESTINATION "${CMAKE_INSTALL_BINDIR}") + endif() + if(NOT ARG_LIBRARY_DESTINATION) + set(ARG_LIBRARY_DESTINATION "${CMAKE_INSTALL_LIBDIR}") + endif() + + foreach(target IN LISTS ARG_TARGETS) + if(NOT TARGET "${target}") + message(FATAL_ERROR "Unknown SNode.C target '${target}'") + endif() + _snodec_real_target("${target}" real_target) + _snodec_set_target_component("${real_target}" "${ARG_COMPONENT}") + _snodec_record_shlibdeps_private_directory("${real_target}") + _snodec_append_component_property( + "${ARG_COMPONENT}" PENDING_TARGETS "${real_target}" + ) + endforeach() + + _snodec_record_install_component("${ARG_COMPONENT}") + install( + TARGETS ${ARG_TARGETS} + RUNTIME DESTINATION "${ARG_RUNTIME_DESTINATION}" + COMPONENT "${ARG_COMPONENT}" + LIBRARY DESTINATION "${ARG_LIBRARY_DESTINATION}" + COMPONENT "${ARG_COMPONENT}" + BUNDLE DESTINATION "${ARG_RUNTIME_DESTINATION}" + COMPONENT "${ARG_COMPONENT}" + ) +endfunction() + +function(snodec_register_runtime_component) + set(options) + set(one_value_arguments COMPONENT DISPLAY_NAME DESCRIPTION) + set(multi_value_arguments DEPENDS) + cmake_parse_arguments( + ARG "${options}" "${one_value_arguments}" "${multi_value_arguments}" + ${ARGN} + ) + _snodec_validate_arguments(ARG "snodec_register_runtime_component") + + if(NOT ARG_COMPONENT) + message(FATAL_ERROR "COMPONENT is required") + endif() + + _snodec_component_property( + "${ARG_COMPONENT}" PENDING_TARGETS component_targets + ) + if(NOT component_targets) + message( + FATAL_ERROR + "Runtime component '${ARG_COMPONENT}' has no installed targets" + ) + endif() + + set( + register_arguments + COMPONENT "${ARG_COMPONENT}" + TARGETS ${component_targets} + RUNTIME_ONLY + ) + if(ARG_DISPLAY_NAME) + list(APPEND register_arguments DISPLAY_NAME "${ARG_DISPLAY_NAME}") + endif() + if(ARG_DESCRIPTION) + list(APPEND register_arguments DESCRIPTION "${ARG_DESCRIPTION}") + endif() + if(ARG_DEPENDS) + list(APPEND register_arguments DEPENDS ${ARG_DEPENDS}) + endif() + _snodec_register_component(${register_arguments}) +endfunction() + +function(snodec_get_public_components result) + get_property(public_components GLOBAL PROPERTY SNODEC_PUBLIC_COMPONENTS) + list(REMOVE_DUPLICATES public_components) + list(SORT public_components) + set(${result} "${public_components}" PARENT_SCOPE) +endfunction() + +function(snodec_get_component_dependency_definitions result) + get_property(components GLOBAL PROPERTY SNODEC_BASE_COMPONENTS) + list(REMOVE_DUPLICATES components) + list(SORT components) + + set(dependency_definitions) + foreach(component IN LISTS components) + _snodec_component_property( + "${component}" RUNTIME_ONLY runtime_only + ) + if(runtime_only) + continue() + endif() + + _snodec_component_dependencies( + "${component}" DEVELOPMENT dependencies + ) + if(dependencies) + string( + APPEND dependency_definitions + "set(${component}_DEPENDENCIES ${dependencies})\n" + ) + endif() + endforeach() + + string( + REGEX REPLACE "\n$" "" dependency_definitions + "${dependency_definitions}" + ) + set(${result} "${dependency_definitions}" PARENT_SCOPE) +endfunction() + +macro(snodec_finalize_cpack_components) + get_property(_snodec_base_components GLOBAL PROPERTY SNODEC_BASE_COMPONENTS) + get_property( + _snodec_referenced_install_components GLOBAL + PROPERTY SNODEC_REFERENCED_INSTALL_COMPONENTS + ) + list(REMOVE_DUPLICATES _snodec_base_components) + list(REMOVE_DUPLICATES _snodec_referenced_install_components) + + if(NOT _snodec_base_components) + message(FATAL_ERROR "No SNode.C components were registered") + endif() + + _snodec_validate_component_dependency_graph(RUNTIME) + _snodec_validate_component_dependency_graph(DEVELOPMENT) + + set(_snodec_cpack_components) + foreach(_snodec_component IN LISTS _snodec_base_components) + _snodec_component_property( + "${_snodec_component}" DISPLAY_NAME _snodec_display_name + ) + _snodec_component_property( + "${_snodec_component}" DESCRIPTION _snodec_description + ) + _snodec_component_property( + "${_snodec_component}" RUNTIME_ONLY _snodec_runtime_only + ) + _snodec_component_dependencies( + "${_snodec_component}" + RUNTIME + _snodec_runtime_dependencies + ) + _snodec_component_dependencies( + "${_snodec_component}" + DEVELOPMENT + _snodec_development_dependencies + ) + + set( + _snodec_referenced_dependencies + ${_snodec_runtime_dependencies} + ${_snodec_development_dependencies} + ) + list(REMOVE_DUPLICATES _snodec_referenced_dependencies) + foreach(_snodec_dependency IN LISTS _snodec_referenced_dependencies) + if(NOT _snodec_dependency IN_LIST _snodec_base_components) + message( + FATAL_ERROR + "SNode.C component '${_snodec_component}' depends on unregistered component '${_snodec_dependency}'" + ) + endif() + endforeach() + + if(NOT _snodec_component IN_LIST _snodec_referenced_install_components) + message( + FATAL_ERROR + "SNode.C component '${_snodec_component}' has no runtime install rules" + ) + endif() + + set(_snodec_runtime_arguments) + if(_snodec_display_name) + list( + APPEND _snodec_runtime_arguments DISPLAY_NAME + "${_snodec_display_name}" + ) + endif() + if(_snodec_description) + list( + APPEND _snodec_runtime_arguments DESCRIPTION + "${_snodec_description}" + ) + endif() + if(_snodec_runtime_dependencies) + list( + APPEND _snodec_runtime_arguments DEPENDS + ${_snodec_runtime_dependencies} + ) + endif() + cpack_add_component( + "${_snodec_component}" ${_snodec_runtime_arguments} + ) + list(APPEND _snodec_cpack_components "${_snodec_component}") + + if(NOT _snodec_runtime_only) + set(_snodec_development_component "${_snodec_component}-dev") + if(NOT _snodec_development_component IN_LIST + _snodec_referenced_install_components + ) + message( + FATAL_ERROR + "SNode.C component '${_snodec_component}' has no development install rules" + ) + endif() + + set( + _snodec_cpack_development_dependencies + "${_snodec_component}" + ) + foreach(_snodec_dependency IN LISTS + _snodec_development_dependencies + ) + _snodec_component_property( + "${_snodec_dependency}" + RUNTIME_ONLY + _snodec_dependency_runtime_only + ) + if(_snodec_dependency_runtime_only) + list( + APPEND _snodec_cpack_development_dependencies + "${_snodec_dependency}" + ) + else() + list( + APPEND _snodec_cpack_development_dependencies + "${_snodec_dependency}-dev" + ) + endif() + endforeach() + list(REMOVE_DUPLICATES _snodec_cpack_development_dependencies) + list(SORT _snodec_cpack_development_dependencies) + + cpack_add_component( + "${_snodec_development_component}" + DISPLAY_NAME "${_snodec_component} development" + DESCRIPTION + "Headers and CMake package metadata for ${_snodec_component}" + DEPENDS ${_snodec_cpack_development_dependencies} + ) + list( + APPEND _snodec_cpack_components + "${_snodec_development_component}" + ) + endif() + endforeach() + + foreach(_snodec_referenced_component IN LISTS + _snodec_referenced_install_components + ) + if(NOT _snodec_referenced_component IN_LIST _snodec_cpack_components) + message( + FATAL_ERROR + "Install rules reference unregistered SNode.C component '${_snodec_referenced_component}'" + ) + endif() + endforeach() + + get_cmake_property(_snodec_cmake_install_components COMPONENTS) + list(REMOVE_ITEM _snodec_cmake_install_components notneeded) + list(REMOVE_DUPLICATES _snodec_cmake_install_components) + foreach(_snodec_install_component IN LISTS + _snodec_cmake_install_components + ) + if(NOT _snodec_install_component IN_LIST _snodec_cpack_components) + message( + FATAL_ERROR + "CMake install component '${_snodec_install_component}' has no SNode.C CPack registration" + ) + endif() + endforeach() + + get_property( + _snodec_shlibdeps_private_dirs GLOBAL + PROPERTY SNODEC_SHLIBDEPS_PRIVATE_DIRS + ) + list(REMOVE_DUPLICATES _snodec_shlibdeps_private_dirs) + list(SORT _snodec_shlibdeps_private_dirs) + + list(REMOVE_DUPLICATES _snodec_cpack_components) + list(SORT _snodec_cpack_components) + set(CPACK_COMPONENTS_ALL ${_snodec_cpack_components}) + set( + CPACK_DEBIAN_PACKAGE_SHLIBDEPS_PRIVATE_DIRS + ${_snodec_shlibdeps_private_dirs} + ) +endmacro() diff --git a/cmake/ValidateComponentPackages.cmake b/cmake/ValidateComponentPackages.cmake new file mode 100644 index 0000000000..e5406c7a46 --- /dev/null +++ b/cmake/ValidateComponentPackages.cmake @@ -0,0 +1,277 @@ +# SNode.C - A Slim Toolkit for Network Communication +# Copyright (C) Volker Christian +# 2026 +# +# This file may be used under the terms of the GNU Lesser General Public +# License version 3 or later, or under the MIT License. + +cmake_minimum_required(VERSION 3.18) + +if(NOT DEFINED PACKAGE_DIR) + message(FATAL_ERROR "PACKAGE_DIR is required") +endif() +if(NOT DEFINED CPACK_CONFIG) + message(FATAL_ERROR "CPACK_CONFIG is required") +endif() + +find_program(DPKG_DEB_EXECUTABLE dpkg-deb REQUIRED) +include("${CPACK_CONFIG}") + +file(GLOB deb_packages "${PACKAGE_DIR}/*.deb") +list(LENGTH deb_packages deb_package_count) +list(LENGTH CPACK_COMPONENTS_ALL expected_package_count) +if(NOT deb_package_count EQUAL expected_package_count) + message( + FATAL_ERROR + "Expected ${expected_package_count} component packages, found ${deb_package_count} in '${PACKAGE_DIR}'" + ) +endif() + +function(read_deb_field package_file field result) + execute_process( + COMMAND "${DPKG_DEB_EXECUTABLE}" --field "${package_file}" "${field}" + RESULT_VARIABLE field_result + OUTPUT_VARIABLE field_value + ERROR_VARIABLE field_error + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(NOT field_result EQUAL 0) + message( + FATAL_ERROR + "Could not read ${field} from '${package_file}': ${field_error}" + ) + endif() + set(${result} "${field_value}" PARENT_SCOPE) +endfunction() + +set(component_package_names) +foreach(deb_package IN LISTS deb_packages) + read_deb_field("${deb_package}" Package package_name) + list(APPEND component_package_names "${package_name}") + string(MAKE_C_IDENTIFIER "${package_name}" package_key) + set("DEB_PACKAGE_FILE_${package_key}" "${deb_package}") +endforeach() + +function(find_component_package component result_name result_file) + set(matches) + foreach(package_name IN LISTS component_package_names) + if(package_name MATCHES "-${component}$") + list(APPEND matches "${package_name}") + endif() + endforeach() + + list(LENGTH matches match_count) + if(NOT match_count EQUAL 1) + message( + FATAL_ERROR + "Expected exactly one Debian package for component '${component}', found: ${matches}" + ) + endif() + + list(GET matches 0 package_name) + string(MAKE_C_IDENTIFIER "${package_name}" package_key) + set(${result_name} "${package_name}" PARENT_SCOPE) + set(${result_file} "${DEB_PACKAGE_FILE_${package_key}}" PARENT_SCOPE) +endfunction() + +function(assert_no_component_package component) + foreach(package_name IN LISTS component_package_names) + if(package_name MATCHES "-${component}$") + message( + FATAL_ERROR + "Unexpected Debian package '${package_name}' for component '${component}'" + ) + endif() + endforeach() +endfunction() + +function(read_deb_contents package_file result) + execute_process( + COMMAND "${DPKG_DEB_EXECUTABLE}" --contents "${package_file}" + RESULT_VARIABLE contents_result + OUTPUT_VARIABLE contents + ERROR_VARIABLE contents_error + ) + if(NOT contents_result EQUAL 0) + message( + FATAL_ERROR + "Could not inspect '${package_file}': ${contents_error}" + ) + endif() + set(${result} "${contents}" PARENT_SCOPE) +endfunction() + +function(read_deb_dependency_names package_file result) + read_deb_field("${package_file}" Depends package_dependencies) + string(REPLACE "," ";" dependency_groups "${package_dependencies}") + + set(dependency_names) + foreach(dependency_group IN LISTS dependency_groups) + string(REPLACE "|" ";" alternatives "${dependency_group}") + foreach(alternative IN LISTS alternatives) + string(STRIP "${alternative}" alternative) + if(alternative) + string(REGEX REPLACE "[ \t(].*$" "" dependency_name + "${alternative}" + ) + list(APPEND dependency_names "${dependency_name}") + endif() + endforeach() + endforeach() + + list(REMOVE_DUPLICATES dependency_names) + set(${result} "${dependency_names}" PARENT_SCOPE) +endfunction() + +function(assert_package_dependency component dependency_component) + find_component_package("${component}" package_name package_file) + find_component_package( + "${dependency_component}" dependency_package_name + dependency_package_file + ) + read_deb_dependency_names("${package_file}" package_dependencies) + if(NOT dependency_package_name IN_LIST package_dependencies) + message( + FATAL_ERROR + "Package '${package_name}' does not depend on '${dependency_package_name}': ${package_dependencies}" + ) + endif() +endfunction() + +function(assert_no_package_dependency component dependency_component) + find_component_package("${component}" package_name package_file) + find_component_package( + "${dependency_component}" dependency_package_name + dependency_package_file + ) + read_deb_dependency_names("${package_file}" package_dependencies) + if(dependency_package_name IN_LIST package_dependencies) + message( + FATAL_ERROR + "Package '${package_name}' unexpectedly depends on '${dependency_package_name}': ${package_dependencies}" + ) + endif() +endfunction() + +foreach(component IN LISTS CPACK_COMPONENTS_ALL) + find_component_package("${component}" package_name package_file) + read_deb_contents("${package_file}" package_contents) + if(package_contents MATCHES "[./]usr/local/") + message( + FATAL_ERROR + "Package '${package_name}' installs below /usr/local:\n${package_contents}" + ) + endif() + + if(component MATCHES "-dev$") + string(REGEX REPLACE "-dev$" "" runtime_component "${component}") + assert_package_dependency("${component}" "${runtime_component}") + + if(package_contents MATCHES "[./]usr/include/|[./]usr/lib/.*/cmake/snodec/|[./]usr/lib/cmake/snodec/") + # At least one development artifact is present. Individual key + # components are checked more precisely below. + else() + message( + FATAL_ERROR + "Development package '${package_name}' has no headers or CMake metadata:\n${package_contents}" + ) + endif() + endif() +endforeach() + +foreach(package_name IN LISTS component_package_names) + if(package_name MATCHES "sphy|mqtt-fast|unspecified") + message(FATAL_ERROR "Unexpected obsolete package '${package_name}'") + endif() +endforeach() + +find_component_package(core core_package_name core_package_file) +find_component_package(core-dev core_dev_package_name core_dev_package_file) +read_deb_contents("${core_package_file}" core_contents) +read_deb_contents("${core_dev_package_file}" core_dev_contents) + +if(NOT core_contents MATCHES "libsnodec-core\\.so\\.1") + message(FATAL_ERROR "The core runtime package has no versioned library") +endif() +if(core_contents MATCHES "/include/|/cmake/snodec/|libsnodec-core\\.so ->") + message( + FATAL_ERROR + "The core runtime package contains development artifacts:\n${core_contents}" + ) +endif() +if(NOT core_dev_contents MATCHES "/include/snode\\.c/core/") + message(FATAL_ERROR "The core development package has no public headers") +endif() +if(NOT core_dev_contents MATCHES + "/cmake/snodec/snodec_core_Targets\\.cmake" +) + message( + FATAL_ERROR + "The core development package has no exported CMake target metadata" + ) +endif() +if(NOT core_dev_contents MATCHES "libsnodec-core\\.so ->") + message( + FATAL_ERROR + "The core development package has no unversioned library namelink" + ) +endif() + +set(core_runtime_dependencies_var "CPACK_COMPONENT_CORE_DEPENDS") +set(selected_multiplexer_components) +foreach(dependency IN LISTS ${core_runtime_dependencies_var}) + if(dependency MATCHES "^mux-") + list(APPEND selected_multiplexer_components "${dependency}") + endif() +endforeach() +list(LENGTH selected_multiplexer_components selected_multiplexer_count) +if(NOT selected_multiplexer_count EQUAL 1) + message( + FATAL_ERROR + "core must depend on exactly one multiplexer component: " + "${${core_runtime_dependencies_var}}" + ) +endif() +list(GET selected_multiplexer_components 0 selected_multiplexer_component) + +assert_package_dependency(core "${selected_multiplexer_component}") +assert_package_dependency(core utils) +assert_package_dependency(core-dev core) +assert_package_dependency(core-dev utils-dev) +assert_no_package_dependency( + core-dev "${selected_multiplexer_component}-dev" +) + +assert_package_dependency(net-in6-phy-stream net-in6-phy) +assert_package_dependency(net-in6-phy-stream-dev net-in6-phy-stream) +assert_package_dependency(net-in6-phy-stream-dev net-in6-phy-dev) + +assert_package_dependency( + http-server-express-tls-in http-server-express +) +assert_package_dependency( + http-server-express-tls-in net-in-stream-tls +) +assert_package_dependency( + http-server-express-tls-in-dev http-server-express-dev +) +assert_package_dependency( + http-server-express-tls-in-dev net-in-stream-tls-dev +) + +assert_package_dependency(mqtt-client-websocket mqtt-client) +assert_package_dependency(mqtt-client-websocket websocket-client) +assert_package_dependency(mqtt-client-websocket-dev mqtt-client-dev) +assert_package_dependency(mqtt-client-websocket-dev websocket-client-dev) + +find_component_package(apps apps_package_name apps_package_file) +find_component_package( + snodec-control snodec_control_package_name snodec_control_package_file +) +assert_no_component_package(apps-dev) +assert_no_component_package(snodec-control-dev) + +message( + STATUS + "Validated ${deb_package_count} SNode.C runtime/development component packages" +) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 24d5281fdc..894201b307 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -67,7 +67,6 @@ endif() set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") include(AppendSourceFileConfig) -include(GetAllTargetsDependencies) include(GNUInstallDirs) include(CMakePackageConfigHelpers) @@ -148,52 +147,11 @@ endif() add_subdirectory(tools) -get_all_targets_dependencies(SNODEC_LIST_OF_ALL_TARGETS_DEPENDENCIES log) -get_all_targets_dependencies(SNODEC_LIST_OF_ALL_TARGETS_DEPENDENCIES utils) -get_all_targets_dependencies(SNODEC_LIST_OF_ALL_TARGETS_DEPENDENCIES core) -get_all_targets_dependencies(SNODEC_LIST_OF_ALL_TARGETS_DEPENDENCIES net) -get_all_targets_dependencies(SNODEC_LIST_OF_ALL_TARGETS_DEPENDENCIES web) -get_all_targets_dependencies(SNODEC_LIST_OF_ALL_TARGETS_DEPENDENCIES express) -get_all_targets_dependencies(SNODEC_LIST_OF_ALL_TARGETS_DEPENDENCIES database) -get_all_targets_dependencies(SNODEC_LIST_OF_ALL_TARGETS_DEPENDENCIES iot) - -set(SUPPORTED_COMPONENTS - core - core-socket-stream-legacy - core-socket-stream-tls - net - net-in-stream-legacy - net-in6-stream-legacy - net-un-stream-legacy - net-in-stream-tls - net-in6-stream-tls - net-un-stream-tls - ${NET-RC-STREAM-LEGACY} - ${NET-RC-STREAM-TLS} - ${NET-L2-STREAM-LEGACY} - ${NET-L2-STREAM-TLS} - net-un-dgram - db-mariadb - http - http-server - http-client - http-server-express - http-server-express-legacy-in - http-server-express-legacy-in6 - http-server-express-legacy-rc - http-server-express-legacy-un - http-server-express-tls-in - http-server-express-tls-in6 - http-server-express-tls-rc - http-server-express-tls-un - websocket-server - websocket-client - mqtt - mqtt-server - mqtt-client - mqtt-server-websocket - mqtt-client-websocket +snodec_get_component_dependency_definitions( + SNODEC_LIST_OF_ALL_TARGETS_DEPENDENCIES ) + +snodec_get_public_components(SUPPORTED_COMPONENTS) string(JOIN "\n " SUPPORTED_COMPONENTS ${SUPPORTED_COMPONENTS}) configure_package_config_file( @@ -210,9 +168,10 @@ write_basic_package_version_file( COMPATIBILITY SameMinorVersion ) -install( - FILES "${CMAKE_CURRENT_BINARY_DIR}/snodecConfig.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/snodecConfigVersion.cmake" +snodec_install_component_development_files( + COMPONENT core + FILES + ${CMAKE_CURRENT_BINARY_DIR}/snodecConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/snodecConfigVersion.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT "core" ) diff --git a/src/apps/CMakeLists.txt b/src/apps/CMakeLists.txt index 8f823078a2..f92f7f7fc4 100644 --- a/src/apps/CMakeLists.txt +++ b/src/apps/CMakeLists.txt @@ -51,8 +51,9 @@ set_target_properties( snode.c PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_RPATH};${HTTP_INSTALL_RPATH}" ) -install(TARGETS snode.c RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - COMPONENT apps +snodec_install_runtime_targets( + COMPONENT apps + TARGETS snode.c ) add_executable(express-compat-server express_compat_server.cpp) @@ -63,8 +64,9 @@ set_target_properties( express-compat-server PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_RPATH};${HTTP_INSTALL_RPATH}" ) -install(TARGETS express-compat-server - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT apps +snodec_install_runtime_targets( + COMPONENT apps + TARGETS express-compat-server ) add_executable(testpost testpost.cpp) @@ -75,8 +77,9 @@ set_target_properties( testpost PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_RPATH};${HTTP_INSTALL_RPATH}" ) -install(TARGETS testpost RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - COMPONENT apps +snodec_install_runtime_targets( + COMPONENT apps + TARGETS testpost ) if(NLOHMANN_JSON_FOUND) @@ -88,8 +91,9 @@ if(NLOHMANN_JSON_FOUND) jsonserver PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_RPATH};${HTTP_INSTALL_RPATH}" ) - install(TARGETS jsonserver RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - COMPONENT apps + snodec_install_runtime_targets( + COMPONENT apps + TARGETS jsonserver ) endif(NLOHMANN_JSON_FOUND) @@ -99,8 +103,9 @@ set_target_properties( jsonclient PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_RPATH};${HTTP_INSTALL_RPATH}" ) -install(TARGETS jsonclient RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - COMPONENT apps +snodec_install_runtime_targets( + COMPONENT apps + TARGETS jsonclient ) if(LIBMARIADB_FOUND) @@ -113,8 +118,9 @@ if(LIBMARIADB_FOUND) testregex PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_RPATH};${HTTP_INSTALL_RPATH}" ) - install(TARGETS testregex RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - COMPONENT apps + snodec_install_runtime_targets( + COMPONENT apps + TARGETS testregex ) endif(LIBMARIADB_FOUND) @@ -126,20 +132,23 @@ set_target_properties( warema-jalousien PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_RPATH};${HTTP_INSTALL_RPATH}" ) -install(TARGETS warema-jalousien RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - COMPONENT apps +snodec_install_runtime_targets( + COMPONENT apps + TARGETS warema-jalousien ) add_executable(testpipe testpipe.cpp) target_link_libraries(testpipe PRIVATE core) -install(TARGETS testpipe RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - COMPONENT apps +snodec_install_runtime_targets( + COMPONENT apps + TARGETS testpipe ) add_executable(configtest configtest.cpp) target_link_libraries(configtest PRIVATE core) -install(TARGETS configtest RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - COMPONENT apps +snodec_install_runtime_targets( + COMPONENT apps + TARGETS configtest ) macro(subdirlist result curdir) @@ -164,3 +173,9 @@ subdirlist(subdirs ${CMAKE_CURRENT_SOURCE_DIR}) foreach(subdir ${subdirs}) add_subdirectory(${subdir}) endforeach() + +snodec_register_runtime_component( + COMPONENT apps + DISPLAY_NAME "Applications" + DESCRIPTION "SNode.C example and utility applications" +) diff --git a/src/apps/database/CMakeLists.txt b/src/apps/database/CMakeLists.txt index c77181cdc1..ad72cd3520 100644 --- a/src/apps/database/CMakeLists.txt +++ b/src/apps/database/CMakeLists.txt @@ -27,8 +27,9 @@ if(LIBMARIADB_FOUND) "$" "$" ) - install(TARGETS testmariadb RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - COMPONENT apps + snodec_install_runtime_targets( + COMPONENT apps + TARGETS testmariadb ) endif(LIBMARIADB_FOUND) diff --git a/src/apps/echo/CMakeLists.txt b/src/apps/echo/CMakeLists.txt index 16cc3de76b..2e142f55b8 100644 --- a/src/apps/echo/CMakeLists.txt +++ b/src/apps/echo/CMakeLists.txt @@ -108,8 +108,9 @@ foreach(NET IN LISTS NETS) PRIVATE NET=${NET} NET_TYPE=${NET_TYPE} STREAM=${STREAM} STREAM_TYPE=${STREAM_TYPE} ) - install(TARGETS echoclient-${STREAM}-${NET} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT apps + snodec_install_runtime_targets( + COMPONENT apps + TARGETS echoclient-${STREAM}-${NET} ) add_executable( @@ -124,8 +125,9 @@ foreach(NET IN LISTS NETS) PRIVATE NET=${NET} NET_TYPE=${NET_TYPE} STREAM=${STREAM} STREAM_TYPE=${STREAM_TYPE} ) - install(TARGETS echoserver-${STREAM}-${NET} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT apps + snodec_install_runtime_targets( + COMPONENT apps + TARGETS echoserver-${STREAM}-${NET} ) endforeach() endforeach() diff --git a/src/apps/http/CMakeLists.txt b/src/apps/http/CMakeLists.txt index a3a091efb4..2099825ef6 100644 --- a/src/apps/http/CMakeLists.txt +++ b/src/apps/http/CMakeLists.txt @@ -111,8 +111,9 @@ foreach(NET IN LISTS NETS) PRIVATE NET=${NET} NET_TYPE=${NET_TYPE} STREAM=${STREAM} STREAM_TYPE=${STREAM_TYPE} ) - install(TARGETS httpserver-${STREAM}-${NET} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT apps + snodec_install_runtime_targets( + COMPONENT apps + TARGETS httpserver-${STREAM}-${NET} ) add_executable( @@ -132,8 +133,9 @@ foreach(NET IN LISTS NETS) PRIVATE NET=${NET} NET_TYPE=${NET_TYPE} STREAM=${STREAM} STREAM_TYPE=${STREAM_TYPE} ) - install(TARGETS httpclient-${STREAM}-${NET} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT apps + snodec_install_runtime_targets( + COMPONENT apps + TARGETS httpclient-${STREAM}-${NET} ) endforeach() endforeach() @@ -147,8 +149,9 @@ target_link_libraries( httplowlevelclient PUBLIC net-in-stream-legacy net-in-stream-tls http-client ) -install(TARGETS httplowlevelclient RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - COMPONENT apps +snodec_install_runtime_targets( + COMPONENT apps + TARGETS httplowlevelclient ) add_executable(verysimpleserver verysimpleserver.cpp ConfigWWW.cpp) @@ -160,8 +163,9 @@ set_target_properties( verysimpleserver PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_RPATH};${HTTP_INSTALL_RPATH}" ) -install(TARGETS verysimpleserver RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - COMPONENT apps +snodec_install_runtime_targets( + COMPONENT apps + TARGETS verysimpleserver ) add_executable(vhostserver vhostserver.cpp ConfigWWW.cpp) @@ -173,8 +177,9 @@ set_target_properties( vhostserver PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_RPATH};${HTTP_INSTALL_RPATH}" ) -install(TARGETS vhostserver RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - COMPONENT apps +snodec_install_runtime_targets( + COMPONENT apps + TARGETS vhostserver ) add_executable( @@ -188,8 +193,9 @@ set_target_properties( testbasicauthentication PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_RPATH};${HTTP_INSTALL_RPATH}" ) -install(TARGETS testbasicauthentication - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT apps +snodec_install_runtime_targets( + COMPONENT apps + TARGETS testbasicauthentication ) add_executable(testexpressnext testexpressnext.cpp) @@ -201,6 +207,7 @@ set_target_properties( testexpressnext PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_RPATH};${HTTP_INSTALL_RPATH}" ) -install(TARGETS testexpressnext RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - COMPONENT apps +snodec_install_runtime_targets( + COMPONENT apps + TARGETS testexpressnext ) diff --git a/src/apps/oauth2/authorization_server/CMakeLists.txt b/src/apps/oauth2/authorization_server/CMakeLists.txt index 767b3d4632..a30a18063e 100644 --- a/src/apps/oauth2/authorization_server/CMakeLists.txt +++ b/src/apps/oauth2/authorization_server/CMakeLists.txt @@ -58,6 +58,7 @@ if(SNODEC_INTREE_BUILD) endif(SNODEC_INTREE_BUILD) -install(TARGETS authorization_server RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - COMPONENT apps +snodec_install_runtime_targets( + COMPONENT apps + TARGETS authorization_server ) diff --git a/src/apps/oauth2/client_app/CMakeLists.txt b/src/apps/oauth2/client_app/CMakeLists.txt index f0c6a3aebc..693ca7fe22 100644 --- a/src/apps/oauth2/client_app/CMakeLists.txt +++ b/src/apps/oauth2/client_app/CMakeLists.txt @@ -57,6 +57,7 @@ if(SNODEC_INTREE_BUILD) endif(SNODEC_INTREE_BUILD) -install(TARGETS client_app RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - COMPONENT apps +snodec_install_runtime_targets( + COMPONENT apps + TARGETS client_app ) diff --git a/src/apps/oauth2/resource_server/CMakeLists.txt b/src/apps/oauth2/resource_server/CMakeLists.txt index c11ffacd4c..fedd02a791 100644 --- a/src/apps/oauth2/resource_server/CMakeLists.txt +++ b/src/apps/oauth2/resource_server/CMakeLists.txt @@ -62,6 +62,7 @@ if(SNODEC_INTREE_BUILD) endif(SNODEC_INTREE_BUILD) -install(TARGETS resource_server RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - COMPONENT apps +snodec_install_runtime_targets( + COMPONENT apps + TARGETS resource_server ) diff --git a/src/apps/tlslegacy/CMakeLists.txt b/src/apps/tlslegacy/CMakeLists.txt index d9683a4d01..f3aca50e0c 100644 --- a/src/apps/tlslegacy/CMakeLists.txt +++ b/src/apps/tlslegacy/CMakeLists.txt @@ -10,14 +10,16 @@ add_executable(tlslegacyserver tlslegacyserver.cpp) target_link_libraries( tlslegacyserver PRIVATE tlslegacysocketcontext net-in-stream-tls ) -install(TARGETS tlslegacyserver RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - COMPONENT apps +snodec_install_runtime_targets( + COMPONENT apps + TARGETS tlslegacyserver ) add_executable(tlslegacyclient tlslegacyclient.cpp) target_link_libraries( tlslegacyclient PRIVATE tlslegacysocketcontext net-in-stream-tls ) -install(TARGETS tlslegacyclient RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - COMPONENT apps +snodec_install_runtime_targets( + COMPONENT apps + TARGETS tlslegacyclient ) diff --git a/src/apps/towercalculator/CMakeLists.txt b/src/apps/towercalculator/CMakeLists.txt index 685951fe99..f9f6e762ed 100644 --- a/src/apps/towercalculator/CMakeLists.txt +++ b/src/apps/towercalculator/CMakeLists.txt @@ -49,6 +49,7 @@ add_executable(towerCalculation ${TOWERCALCULATION_CPP} ${TOWERCALCULATION_H}) target_link_libraries(towerCalculation PRIVATE core) -install(TARGETS towerCalculation RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - COMPONENT apps +snodec_install_runtime_targets( + COMPONENT apps + TARGETS towerCalculation ) diff --git a/src/apps/websocket/CMakeLists.txt b/src/apps/websocket/CMakeLists.txt index a2f3082dbf..d5b6507945 100644 --- a/src/apps/websocket/CMakeLists.txt +++ b/src/apps/websocket/CMakeLists.txt @@ -58,8 +58,9 @@ set_target_properties( wsechoserver PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_RPATH};${HTTP_INSTALL_RPATH}" ) -install(TARGETS wsechoserver RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - COMPONENT apps +snodec_install_runtime_targets( + COMPONENT apps + TARGETS wsechoserver ) set(WSECHOCLIENT_CPP echoclient.cpp) @@ -77,8 +78,9 @@ set_target_properties( wsechoclient PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_RPATH};${HTTP_INSTALL_RPATH}" ) -install(TARGETS wsechoclient RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - COMPONENT apps +snodec_install_runtime_targets( + COMPONENT apps + TARGETS wsechoclient ) add_subdirectory(subprotocol) diff --git a/src/apps/websocket/subprotocol/client/echo/CMakeLists.txt b/src/apps/websocket/subprotocol/client/echo/CMakeLists.txt index a64e8d2e58..7869e1ae66 100644 --- a/src/apps/websocket/subprotocol/client/echo/CMakeLists.txt +++ b/src/apps/websocket/subprotocol/client/echo/CMakeLists.txt @@ -79,9 +79,10 @@ set_target_properties( "${CMAKE_INSTALL_PREFIX}/${HTTP_UPGRADE_INSTALL_LIBDIR}" ) -install(TARGETS websocket-echo-client - LIBRARY DESTINATION ${WEBSOCKET_SUBPROTOCOL_INSTALL_LIBDIR} - COMPONENT apps +snodec_install_runtime_targets( + COMPONENT apps + TARGETS websocket-echo-client + LIBRARY_DESTINATION ${WEBSOCKET_SUBPROTOCOL_INSTALL_LIBDIR} ) if(CHECK_INCLUDES) diff --git a/src/apps/websocket/subprotocol/server/echo/CMakeLists.txt b/src/apps/websocket/subprotocol/server/echo/CMakeLists.txt index ff9608fe11..b5708cdd94 100644 --- a/src/apps/websocket/subprotocol/server/echo/CMakeLists.txt +++ b/src/apps/websocket/subprotocol/server/echo/CMakeLists.txt @@ -79,9 +79,10 @@ set_target_properties( "${CMAKE_INSTALL_PREFIX}/${HTTP_UPGRADE_INSTALL_LIBDIR}" ) -install(TARGETS websocket-echo-server - LIBRARY DESTINATION ${WEBSOCKET_SUBPROTOCOL_INSTALL_LIBDIR} - COMPONENT apps +snodec_install_runtime_targets( + COMPONENT apps + TARGETS websocket-echo-server + LIBRARY_DESTINATION ${WEBSOCKET_SUBPROTOCOL_INSTALL_LIBDIR} ) if(CHECK_INCLUDES) diff --git a/src/cmake/Config.cmake.in b/src/cmake/Config.cmake.in index e648597ca4..a8907ded4b 100644 --- a/src/cmake/Config.cmake.in +++ b/src/cmake/Config.cmake.in @@ -39,10 +39,10 @@ # # ########################################################################### # -@SNODEC_LIST_OF_ALL_TARGETS_DEPENDENCIES@ - @PACKAGE_INIT@ +@SNODEC_LIST_OF_ALL_TARGETS_DEPENDENCIES@ + macro(load_component_with_dependencies _comp _lspace _ladd) if(NOT ${_comp}_LOADED) if(${_comp}_DEPENDENCIES) @@ -50,12 +50,12 @@ macro(load_component_with_dependencies _comp _lspace _ladd) message("${_lspace}${_comp}: loading dependencies " "\'${CURRENT_COMP_DEPENDENCIES}\'" ) - foreach(_depcomp ${${_comp}_DEPENDENCIES}) + foreach(_depcomp IN LISTS ${_comp}_DEPENDENCIES) load_component_with_dependencies( ${_depcomp} "${_lspace}${_ladd}" "${_ladd}" ) - endforeach(_depcomp ${${_comp}_DEPENDENCIES}) - endif(${_comp}_DEPENDENCIES) + endforeach() + endif() include("${CMAKE_CURRENT_LIST_DIR}/snodec_${_comp}_Targets.cmake") include("${CMAKE_CURRENT_LIST_DIR}/snodec_${_comp}_Targets_Config.cmake" OPTIONAL RESULT_VARIABLE ${_comp}_TARGETS_CONFIG_FILE @@ -63,40 +63,32 @@ macro(load_component_with_dependencies _comp _lspace _ladd) message("${_lspace}${_comp}: loaded") if(NOT "${${_comp}_TARGETS_CONFIG_FILE}" STREQUAL "NOTFOUND") message("${_lspace}${_comp}: configured") - endif(NOT "${${_comp}_TARGETS_CONFIG_FILE}" STREQUAL "NOTFOUND") + endif() set(${_comp}_LOADED true) - else(NOT ${_comp}_LOADED) + else() message("${_lspace}${_comp}: already loaded") - endif(NOT ${_comp}_LOADED) + endif() endmacro() set(_supported_components @SUPPORTED_COMPONENTS@) set(snodec_FOUND TRUE) -foreach(_comp ${snodec_FIND_COMPONENTS}) +foreach(_comp IN LISTS snodec_FIND_COMPONENTS) if(NOT _comp IN_LIST _supported_components) - set(snodec_FOUND FALSE) - set(snodec_NOT_FOUND_MESSAGE - "Unsupported SNode.C component requested: ${_comp}" - ) - break() - else(NOT _comp IN_LIST _supported_components) + set(snodec_${_comp}_FOUND FALSE) + if(snodec_FIND_REQUIRED_${_comp}) + set(snodec_NOT_FOUND_MESSAGE + "Unsupported SNode.C component requested: ${_comp}" + ) + endif() + else() load_component_with_dependencies(${_comp} "" " ") - check_required_components(${_comp}) - endif(NOT _comp IN_LIST _supported_components) -endforeach(_comp ${snodec_FIND_COMPONENTS}) + set(snodec_${_comp}_FOUND TRUE) + endif() +endforeach() + +check_required_components(snodec) if(snodec_FOUND) - set(CMAKE_SKIP_RPATH FALSE) - set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) - list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES - "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" isSystemDir - ) - if("${isSystemDir}" STREQUAL "-1") - set(CMAKE_INSTALL_RPATH - "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" - ) - endif("${isSystemDir}" STREQUAL "-1") set(SNODEC_SOVERSION @SNODEC_SOVERSION@) - add_link_options(LINKER:--as-needed) endif() diff --git a/src/cmake/GetAllTargetsDependencies.cmake b/src/cmake/GetAllTargetsDependencies.cmake deleted file mode 100644 index 9a1cce70d0..0000000000 --- a/src/cmake/GetAllTargetsDependencies.cmake +++ /dev/null @@ -1,87 +0,0 @@ -# SNode.C - A Slim Toolkit for Network Communication -# Copyright (C) Volker Christian -# 2020, 2021, 2022, 2023, 2024, 2025, 2026 -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, see . -# -# --------------------------------------------------------------------------- -# -# MIT License -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. - -# Collect all currently added targets in all subdirectories -function(get_all_targets_dependencies RESULT DIR) - get_property(SUBDIRECTORIES DIRECTORY "${DIR}" PROPERTY SUBDIRECTORIES) - - foreach(SUBDIRECTORIE IN LISTS SUBDIRECTORIES) - get_all_targets_dependencies(${RESULT} "${SUBDIRECTORIE}") - endforeach(SUBDIRECTORIE IN LISTS SUBDIRECTORIES) - - get_directory_property(TARGETS DIRECTORY "${DIR}" BUILDSYSTEM_TARGETS) - foreach(TARGET IN LISTS TARGETS) - unset(LIBRARY_DEPENDENCIES) - get_target_property(TARGET_TYPE "${TARGET}" TYPE) - if (${TARGET_TYPE} STREQUAL "INTERFACE_LIBRARY") - get_target_property(TARGET_LIBRARY_DEPENDENCIES ${TARGET} INTERFACE_LINK_LIBRARIES) - else(${TARGET_TYPE} STREQUAL "INTERFACE_LIBRARY") - get_target_property(TARGET_LIBRARY_DEPENDENCIES ${TARGET} LINK_LIBRARIES) - endif(${TARGET_TYPE} STREQUAL "INTERFACE_LIBRARY") - if (NOT "${TARGET_LIBRARY_DEPENDENCIES}" STREQUAL "TARGET_LIBRARY_DEPENDENCIES-NOTFOUND") - foreach(TARGET_LIBRARY_DEPENDENCY IN LISTS TARGET_LIBRARY_DEPENDENCIES) - if (TARGET "${TARGET_LIBRARY_DEPENDENCY}") - get_target_property(TARGET_LIBRARY_DEPENDENCY_type "${TARGET_LIBRARY_DEPENDENCY}" TYPE) - get_target_property(TARGET_LIBRARY_DEPENDENCY_imported "${TARGET_LIBRARY_DEPENDENCY}" IMPORTED) - if(NOT "${TARGET_LIBRARY_DEPENDENCY_type}" STREQUAL "STATIC_LIBRARY" - AND NOT TARGET_LIBRARY_DEPENDENCY_imported - AND NOT "${TARGET_LIBRARY_DEPENDENCY}" MATCHES "::") - list(APPEND LIBRARY_DEPENDENCIES ${TARGET_LIBRARY_DEPENDENCY}) - endif() - endif(TARGET "${TARGET_LIBRARY_DEPENDENCY}") - endforeach() - if (LIBRARY_DEPENDENCIES) - if (NOT LIBRARY_DEPENDENCIES_LINES) - set(LIBRARY_DEPENDENCIES_LINES "set(${TARGET}_DEPENDENCIES ${LIBRARY_DEPENDENCIES})") - else(NOT LIBRARY_DEPENDENCIES_LINES) - string(APPEND LIBRARY_DEPENDENCIES_LINES "\nset(${TARGET}_DEPENDENCIES ${LIBRARY_DEPENDENCIES})") - endif(NOT LIBRARY_DEPENDENCIES_LINES) - endif(LIBRARY_DEPENDENCIES) - endif(NOT "${TARGET_LIBRARY_DEPENDENCIES}" STREQUAL "TARGET_LIBRARY_DEPENDENCIES-NOTFOUND") - endforeach(TARGET IN LISTS TARGETS) - - if (LIBRARY_DEPENDENCIES_LINES) - if (${RESULT}) - string(APPEND ${RESULT} "\n") - endif(${RESULT}) - string(APPEND ${RESULT} "${LIBRARY_DEPENDENCIES_LINES}") - endif() - - set(${RESULT} "${${RESULT}}" PARENT_SCOPE) -endfunction() diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 28abb986ba..ba03a3218f 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -159,38 +159,30 @@ set_target_properties( OUTPUT_NAME snodec-core ) -install( - TARGETS core - EXPORT snodec_core_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT core +snodec_add_component( + TARGET core + PUBLIC_COMPONENT ) -install( +snodec_install_component_headers( + COMPONENT core DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/core - COMPONENT core - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "." EXCLUDE - PATTERN "EventLoop.h" EXCLUDE - PATTERN "EventMultiplexer.h" EXCLUDE - PATTERN "DescriptorEventPublisher.h" EXCLUDE - PATTERN "TimerEventPublisher.h" EXCLUDE - PATTERN "timer/IntervalTimer.h" EXCLUDE - PATTERN "timer/IntervalTimerStopable.h" EXCLUDE - PATTERN "timer/SingleshoTimer.h" EXCLUDE - PATTERN "cmake" EXCLUDE - PATTERN "multiplexer" EXCLUDE - PATTERN "socket" EXCLUDE -) - -install( - EXPORT snodec_core_Targets - FILE snodec_core_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT core + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + "." + EventLoop.h + EventMultiplexer.h + DescriptorEventPublisher.h + TimerEventPublisher.h + timer/IntervalTimer.h + timer/IntervalTimerStopable.h + timer/SingleshoTimer.h + cmake + multiplexer + socket ) add_subdirectory(socket) diff --git a/src/core/multiplexer/epoll/CMakeLists.txt b/src/core/multiplexer/epoll/CMakeLists.txt index 95f2698dad..696212d563 100644 --- a/src/core/multiplexer/epoll/CMakeLists.txt +++ b/src/core/multiplexer/epoll/CMakeLists.txt @@ -60,16 +60,6 @@ set_target_properties( target_link_options(mux-epoll PRIVATE LINKER:-z,undefs) -install( - TARGETS mux-epoll - EXPORT snodec_mux-epoll_Targets - LIBRARY DESTINATION ${CMAKE_INISTALL_LIBDIR} COMPONENT mux-epoll -) - -install( - EXPORT snodec_mux-epoll_Targets - FILE snodec_mux-epoll_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT mux-epoll +snodec_add_component( + TARGET mux-epoll ) diff --git a/src/core/multiplexer/poll/CMakeLists.txt b/src/core/multiplexer/poll/CMakeLists.txt index 0b6976bfeb..903d9f0a97 100644 --- a/src/core/multiplexer/poll/CMakeLists.txt +++ b/src/core/multiplexer/poll/CMakeLists.txt @@ -60,16 +60,6 @@ set_target_properties( target_link_options(mux-poll PRIVATE LINKER:-z,undefs) -install( - TARGETS mux-poll - EXPORT snodec_mux-poll_Targets - LIBRARY DESTINATION ${CMAKE_INISTALL_LIBDIR} COMPONENT mux-poll -) - -install( - EXPORT snodec_mux-poll_Targets - FILE snodec_mux-poll_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT mux-poll +snodec_add_component( + TARGET mux-poll ) diff --git a/src/core/multiplexer/select/CMakeLists.txt b/src/core/multiplexer/select/CMakeLists.txt index 77c029d192..0ae17bb217 100644 --- a/src/core/multiplexer/select/CMakeLists.txt +++ b/src/core/multiplexer/select/CMakeLists.txt @@ -60,16 +60,6 @@ set_target_properties( target_link_options(mux-select PRIVATE LINKER:-z,undefs) -install( - TARGETS mux-select - EXPORT snodec_mux-select_Targets - LIBRARY DESTINATION ${CMAKE_INISTALL_LIBDIR} COMPONENT mux-select -) - -install( - EXPORT snodec_mux-select_Targets - FILE snodec_mux-select_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT mux-select +snodec_add_component( + TARGET mux-select ) diff --git a/src/core/socket/CMakeLists.txt b/src/core/socket/CMakeLists.txt index 815dbac3ed..9c6205152a 100644 --- a/src/core/socket/CMakeLists.txt +++ b/src/core/socket/CMakeLists.txt @@ -60,30 +60,21 @@ set_target_properties( OUTPUT_NAME snodec-core-socket ) -install( - TARGETS core-socket - EXPORT snodec_core-socket_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT core-socket +snodec_add_component( + TARGET core-socket ) -install( +snodec_install_component_headers( + COMPONENT core-socket DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/core/socket - COMPONENT core-socket - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "." EXCLUDE - PATTERN "stream" EXCLUDE - PATTERN "dgram" EXCLUDE -) - -install( - EXPORT snodec_core-socket_Targets - FILE snodec_core-socket_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT core-socket + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + "." + stream + dgram ) add_subdirectory(stream) diff --git a/src/core/socket/stream/CMakeLists.txt b/src/core/socket/stream/CMakeLists.txt index 0d48357f0f..5ccf5f197c 100644 --- a/src/core/socket/stream/CMakeLists.txt +++ b/src/core/socket/stream/CMakeLists.txt @@ -87,31 +87,22 @@ set_target_properties( OUTPUT_NAME snodec-core-socket-stream ) -install( - TARGETS core-socket-stream - EXPORT snodec_core-socket-stream_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT core-socket-stream +snodec_add_component( + TARGET core-socket-stream ) -install( +snodec_install_component_headers( + COMPONENT core-socket-stream DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/core/socket/stream - COMPONENT core-socket-stream - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "." EXCLUDE - PATTERN "legacy" EXCLUDE - PATTERN "tls" EXCLUDE - PATTERN "pu" EXCLUDE -) - -install( - EXPORT snodec_core-socket-stream_Targets - FILE snodec_core-socket-stream_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT core-socket-stream + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + "." + legacy + tls + pu ) add_subdirectory(legacy) diff --git a/src/core/socket/stream/legacy/CMakeLists.txt b/src/core/socket/stream/legacy/CMakeLists.txt index a37bb4ebfb..7cfa2810b0 100644 --- a/src/core/socket/stream/legacy/CMakeLists.txt +++ b/src/core/socket/stream/legacy/CMakeLists.txt @@ -73,27 +73,17 @@ set_target_properties( OUTPUT_NAME snodec-core-socket-stream-legacy ) -install( - TARGETS core-socket-stream-legacy - EXPORT snodec_core-socket-stream-legacy_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - COMPONENT core-socket-stream-legacy +snodec_add_component( + TARGET core-socket-stream-legacy + PUBLIC_COMPONENT ) -install( +snodec_install_component_headers( + COMPONENT core-socket-stream-legacy DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/core/socket/stream/legacy - COMPONENT core-socket-stream-legacy - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE -) - -install( - EXPORT snodec_core-socket-stream-legacy_Targets - FILE snodec_core-socket-stream-legacy_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT core-socket-stream-legacy + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/core/socket/stream/tls/CMakeLists.txt b/src/core/socket/stream/tls/CMakeLists.txt index e964c8e88f..0c889e4282 100644 --- a/src/core/socket/stream/tls/CMakeLists.txt +++ b/src/core/socket/stream/tls/CMakeLists.txt @@ -95,30 +95,21 @@ else(NOT OpenSSL_FOUND) OUTPUT_NAME snodec-core-socket-stream-tls ) - install( - TARGETS core-socket-stream-tls - EXPORT snodec_core-socket-stream-tls_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - COMPONENT core-socket-stream-tls + snodec_add_component( + TARGET core-socket-stream-tls + PUBLIC_COMPONENT ) - install( + snodec_install_component_headers( + COMPONENT core-socket-stream-tls DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/core/socket/stream/tls - COMPONENT core-socket-stream-tls - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE - PATTERN "detail" EXCLUDE - ) - - install( - EXPORT snodec_core-socket-stream-tls_Targets - FILE snodec_core-socket-stream-tls_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT core-socket-stream-tls + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + detail ) endif(NOT OpenSSL_FOUND) diff --git a/src/database/mariadb/CMakeLists.txt b/src/database/mariadb/CMakeLists.txt index 1ff1744dd8..2428598d7e 100644 --- a/src/database/mariadb/CMakeLists.txt +++ b/src/database/mariadb/CMakeLists.txt @@ -110,28 +110,19 @@ if(LIBMARIADB_FOUND) OUTPUT_NAME snodec-db-mariadb ) - install( - TARGETS db-mariadb - EXPORT snodec_db-mariadb_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT db-mariadb + snodec_add_component( + TARGET db-mariadb + PUBLIC_COMPONENT ) - install( - EXPORT snodec_db-mariadb_Targets - FILE snodec_db-mariadb_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec + snodec_install_component_headers( COMPONENT db-mariadb - ) - - install( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION include/snode.c/database/mariadb - COMPONENT db-mariadb - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) endif(LIBMARIADB_FOUND) diff --git a/src/express/CMakeLists.txt b/src/express/CMakeLists.txt index a7ec6d1b24..a95814562b 100644 --- a/src/express/CMakeLists.txt +++ b/src/express/CMakeLists.txt @@ -138,28 +138,20 @@ set_target_properties( INSTALL_RPATH "${HTTP_INSTALL_RPATH}" ) -install( - TARGETS http-server-express - EXPORT snodec_http-server-express_Targets - LIBRARY DESTINATION ${HTTP_INSTALL_LIBDIR} COMPONENT http-server-express +snodec_add_component( + TARGET http-server-express + LIBRARY_DESTINATION ${HTTP_INSTALL_LIBDIR} + PUBLIC_COMPONENT ) -install( +snodec_install_component_headers( + COMPONENT http-server-express DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/express - COMPONENT http-server-express - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE -) - -install( - EXPORT snodec_http-server-express_Targets - FILE snodec_http-server-express_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT http-server-express + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) add_subdirectory(legacy) diff --git a/src/express/legacy/in/CMakeLists.txt b/src/express/legacy/in/CMakeLists.txt index 27ac75888f..7f615fcabd 100644 --- a/src/express/legacy/in/CMakeLists.txt +++ b/src/express/legacy/in/CMakeLists.txt @@ -75,27 +75,18 @@ set_target_properties( INSTALL_RPATH "${HTTP_INSTALL_RPATH}" ) -install( - TARGETS http-server-express-legacy-in - EXPORT snodec_http-server-express-legacy-in_Targets - LIBRARY DESTINATION ${HTTP_INSTALL_LIBDIR} - COMPONENT http-server-express-legacy-in +snodec_add_component( + TARGET http-server-express-legacy-in + LIBRARY_DESTINATION ${HTTP_INSTALL_LIBDIR} + PUBLIC_COMPONENT ) -install( +snodec_install_component_headers( + COMPONENT http-server-express-legacy-in DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/express/legacy/in - COMPONENT http-server-express-legacy-in - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE -) - -install( - EXPORT snodec_http-server-express-legacy-in_Targets - FILE snodec_http-server-express-legacy-in_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT http-server-express-legacy-in + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/express/legacy/in6/CMakeLists.txt b/src/express/legacy/in6/CMakeLists.txt index e654d06dba..444b74f10b 100644 --- a/src/express/legacy/in6/CMakeLists.txt +++ b/src/express/legacy/in6/CMakeLists.txt @@ -75,27 +75,18 @@ set_target_properties( INSTALL_RPATH "${HTTP_INSTALL_RPATH}" ) -install( - TARGETS http-server-express-legacy-in6 - EXPORT snodec_http-server-express-legacy-in6_Targets - LIBRARY DESTINATION ${HTTP_INSTALL_LIBDIR} - COMPONENT http-server-express-legacy-in6 +snodec_add_component( + TARGET http-server-express-legacy-in6 + LIBRARY_DESTINATION ${HTTP_INSTALL_LIBDIR} + PUBLIC_COMPONENT ) -install( +snodec_install_component_headers( + COMPONENT http-server-express-legacy-in6 DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/express/legacy/in6 - COMPONENT http-server-express-legacy-in6 - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE -) - -install( - EXPORT snodec_http-server-express-legacy-in6_Targets - FILE snodec_http-server-express-legacy-in6_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT http-server-express-legacy-in6 + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/express/legacy/rc/CMakeLists.txt b/src/express/legacy/rc/CMakeLists.txt index 160989678f..06e941ce97 100644 --- a/src/express/legacy/rc/CMakeLists.txt +++ b/src/express/legacy/rc/CMakeLists.txt @@ -77,28 +77,20 @@ if(BLUEZ_FOUND) INSTALL_RPATH "${HTTP_INSTALL_RPATH}" ) - install( - TARGETS http-server-express-legacy-rc - EXPORT snodec_http-server-express-legacy-rc_Targets - LIBRARY DESTINATION ${HTTP_INSTALL_LIBDIR} - COMPONENT http-server-express-legacy-rc + snodec_add_component( + TARGET http-server-express-legacy-rc + LIBRARY_DESTINATION ${HTTP_INSTALL_LIBDIR} + PUBLIC_COMPONENT ) - install( + snodec_install_component_headers( + COMPONENT http-server-express-legacy-rc DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/express/legacy/rc - COMPONENT http-server-express-legacy-rc - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) - install( - EXPORT snodec_http-server-express-legacy-rc_Targets - FILE snodec_http-server-express-legacy-rc_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT http-server-express-legacy-rc - ) endif(BLUEZ_FOUND) diff --git a/src/express/legacy/un/CMakeLists.txt b/src/express/legacy/un/CMakeLists.txt index 81358f10f7..8090b12f8f 100644 --- a/src/express/legacy/un/CMakeLists.txt +++ b/src/express/legacy/un/CMakeLists.txt @@ -75,27 +75,18 @@ set_target_properties( INSTALL_RPATH "${HTTP_INSTALL_RPATH}" ) -install( - TARGETS http-server-express-legacy-un - EXPORT snodec_http-server-express-legacy-un_Targets - LIBRARY DESTINATION ${HTTP_INSTALL_LIBDIR} - COMPONENT http-server-express-legacy-un +snodec_add_component( + TARGET http-server-express-legacy-un + LIBRARY_DESTINATION ${HTTP_INSTALL_LIBDIR} + PUBLIC_COMPONENT ) -install( +snodec_install_component_headers( + COMPONENT http-server-express-legacy-un DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/express/legacy/un - COMPONENT http-server-express-legacy-un - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE -) - -install( - EXPORT snodec_http-server-express-legacy-un_Targets - FILE snodec_http-server-express-legacy-un_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT http-server-express-legacy-un + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/express/tls/in/CMakeLists.txt b/src/express/tls/in/CMakeLists.txt index 3c09426275..7fb78a5fda 100644 --- a/src/express/tls/in/CMakeLists.txt +++ b/src/express/tls/in/CMakeLists.txt @@ -72,27 +72,18 @@ set_target_properties( INSTALL_RPATH "${HTTP_INSTALL_RPATH}" ) -install( - TARGETS http-server-express-tls-in - EXPORT snodec_http-server-express-tls-in_Targets - LIBRARY DESTINATION ${HTTP_INSTALL_LIBDIR} - COMPONENT http-server-express-tls-in +snodec_add_component( + TARGET http-server-express-tls-in + LIBRARY_DESTINATION ${HTTP_INSTALL_LIBDIR} + PUBLIC_COMPONENT ) -install( +snodec_install_component_headers( + COMPONENT http-server-express-tls-in DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/express/tls/in - COMPONENT http-server-express-tls-in - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE -) - -install( - EXPORT snodec_http-server-express-tls-in_Targets - FILE snodec_http-server-express-tls-in_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT http-server-express-tls-in + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/express/tls/in6/CMakeLists.txt b/src/express/tls/in6/CMakeLists.txt index f18806b540..bcfa10d13b 100644 --- a/src/express/tls/in6/CMakeLists.txt +++ b/src/express/tls/in6/CMakeLists.txt @@ -75,27 +75,18 @@ set_target_properties( INSTALL_RPATH "${HTTP_INSTALL_RPATH}" ) -install( - TARGETS http-server-express-tls-in6 - EXPORT snodec_http-server-express-tls-in6_Targets - LIBRARY DESTINATION ${HTTP_INSTALL_LIBDIR} - COMPONENT http-server-express-tls-in6 +snodec_add_component( + TARGET http-server-express-tls-in6 + LIBRARY_DESTINATION ${HTTP_INSTALL_LIBDIR} + PUBLIC_COMPONENT ) -install( +snodec_install_component_headers( + COMPONENT http-server-express-tls-in6 DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/express/tls/in6 - COMPONENT http-server-express-tls-in6 - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE -) - -install( - EXPORT snodec_http-server-express-tls-in6_Targets - FILE snodec_http-server-express-tls-in6_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT http-server-express-tls-in6 + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/express/tls/rc/CMakeLists.txt b/src/express/tls/rc/CMakeLists.txt index 8f153d81d0..05db643e14 100644 --- a/src/express/tls/rc/CMakeLists.txt +++ b/src/express/tls/rc/CMakeLists.txt @@ -76,28 +76,20 @@ if(BLUEZ_FOUND) INSTALL_RPATH "${HTTP_INSTALL_RPATH}" ) - install( - TARGETS http-server-express-tls-rc - EXPORT snodec_http-server-express-tls-rc_Targets - LIBRARY DESTINATION ${HTTP_INSTALL_LIBDIR} - COMPONENT http-server-express-tls-rc + snodec_add_component( + TARGET http-server-express-tls-rc + LIBRARY_DESTINATION ${HTTP_INSTALL_LIBDIR} + PUBLIC_COMPONENT ) - install( + snodec_install_component_headers( + COMPONENT http-server-express-tls-rc DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/express/tls/rc - COMPONENT http-server-express-tls-rc - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) - install( - EXPORT snodec_http-server-express-tls-rc_Targets - FILE snodec_http-server-express-tls-rc_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT http-server-express-tls-rc - ) endif(BLUEZ_FOUND) diff --git a/src/express/tls/un/CMakeLists.txt b/src/express/tls/un/CMakeLists.txt index 1d6b39ce1d..1b8d32fbfe 100644 --- a/src/express/tls/un/CMakeLists.txt +++ b/src/express/tls/un/CMakeLists.txt @@ -72,27 +72,18 @@ set_target_properties( INSTALL_RPATH "${HTTP_INSTALL_RPATH}" ) -install( - TARGETS http-server-express-tls-un - EXPORT snodec_http-server-express-tls-un_Targets - LIBRARY DESTINATION ${HTTP_INSTALL_LIBDIR} - COMPONENT http-server-express-tls-un +snodec_add_component( + TARGET http-server-express-tls-un + LIBRARY_DESTINATION ${HTTP_INSTALL_LIBDIR} + PUBLIC_COMPONENT ) -install( +snodec_install_component_headers( + COMPONENT http-server-express-tls-un DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/express/tls/un - COMPONENT http-server-express-tls-un - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE -) - -install( - EXPORT snodec_http-server-express-tls-un_Targets - FILE snodec_http-server-express-tls-un_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT http-server-express-tls-un + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/iot/mqtt/CMakeLists.txt b/src/iot/mqtt/CMakeLists.txt index 64396737f5..ad43aed03a 100644 --- a/src/iot/mqtt/CMakeLists.txt +++ b/src/iot/mqtt/CMakeLists.txt @@ -98,33 +98,25 @@ if(NLOHMANN_JSON_FOUND) OUTPUT_NAME snodec-mqtt ) - install( - TARGETS mqtt - EXPORT snodec_mqtt_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/${MQTT_INSTALL_DIR} - COMPONENT mqtt + snodec_add_component( + TARGET mqtt + LIBRARY_DESTINATION ${CMAKE_INSTALL_LIBDIR}/${MQTT_INSTALL_DIR} + PUBLIC_COMPONENT ) - install( + snodec_install_component_headers( + COMPONENT mqtt DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${MQTT_INSTALL_INCLUDEDIR} - COMPONENT mqtt - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE - PATTERN "server" EXCLUDE - PATTERN "client" EXCLUDE - PATTERN "types" EXCLUDE - PATTERN "packets" EXCLUDE - ) - - install( - EXPORT snodec_mqtt_Targets - FILE snodec_mqtt_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT mqtt + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + server + client + types + packets ) add_subdirectory(server) diff --git a/src/iot/mqtt/client/CMakeLists.txt b/src/iot/mqtt/client/CMakeLists.txt index 7f0e249597..1c618ef9fb 100644 --- a/src/iot/mqtt/client/CMakeLists.txt +++ b/src/iot/mqtt/client/CMakeLists.txt @@ -69,25 +69,16 @@ set_target_properties( INSTALL_RPATH "${MQTT_RPATH};${HTTP_INSTALL_RPATH}/upgrade" ) -install( - TARGETS mqtt-client - EXPORT snodec_mqtt-client_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/${MQTT_INSTALL_DIR} - COMPONENT mqtt-client +snodec_add_component( + TARGET mqtt-client + LIBRARY_DESTINATION ${CMAKE_INSTALL_LIBDIR}/${MQTT_INSTALL_DIR} + PUBLIC_COMPONENT ) -install( +snodec_install_component_development_files( + COMPONENT mqtt-client FILES Mqtt.h DESTINATION ${MQTT_INSTALL_INCLUDEDIR}/client - COMPONENT mqtt-client -) - -install( - EXPORT snodec_mqtt-client_Targets - FILE snodec_mqtt-client_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT mqtt-client ) set(MQTT_CLIENT_WEBSOCKET_CPP SubProtocol.cpp) @@ -119,23 +110,14 @@ set_target_properties( INSTALL_RPATH "${MQTT_RPATH};${HTTP_INSTALL_RPATH}/upgrade" ) -install( - TARGETS mqtt-client-websocket - EXPORT snodec_mqtt-client-websocket_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/${MQTT_INSTALL_DIR} - COMPONENT mqtt-client-websocket +snodec_add_component( + TARGET mqtt-client-websocket + LIBRARY_DESTINATION ${CMAKE_INSTALL_LIBDIR}/${MQTT_INSTALL_DIR} + PUBLIC_COMPONENT ) -install( +snodec_install_component_development_files( + COMPONENT mqtt-client-websocket FILES SubProtocol.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${MQTT_INSTALL_DIR}/client - COMPONENT mqtt-client-websocket -) - -install( - EXPORT snodec_mqtt-client-websocket_Targets - FILE snodec_mqtt-client-websocket_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT mqtt-client-websocket ) diff --git a/src/iot/mqtt/client/packets/CMakeLists.txt b/src/iot/mqtt/client/packets/CMakeLists.txt index 9b9bddaf4c..72dffe117d 100644 --- a/src/iot/mqtt/client/packets/CMakeLists.txt +++ b/src/iot/mqtt/client/packets/CMakeLists.txt @@ -76,12 +76,12 @@ target_include_directories( mqtt-client-packets PUBLIC "$" ) -install( +snodec_install_component_headers( + COMPONENT mqtt-client DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${MQTT_INSTALL_INCLUDEDIR}/client/packets - COMPONENT mqtt-client - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/iot/mqtt/packets/CMakeLists.txt b/src/iot/mqtt/packets/CMakeLists.txt index ba1dd96eaa..43b493af3d 100644 --- a/src/iot/mqtt/packets/CMakeLists.txt +++ b/src/iot/mqtt/packets/CMakeLists.txt @@ -83,12 +83,12 @@ target_include_directories( mqtt-packets PUBLIC "$" ) -install( +snodec_install_component_headers( + COMPONENT mqtt DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${MQTT_INSTALL_INCLUDEDIR}/packets - COMPONENT mqtt - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/iot/mqtt/server/CMakeLists.txt b/src/iot/mqtt/server/CMakeLists.txt index 6afb383ea1..e69ba6d1f7 100644 --- a/src/iot/mqtt/server/CMakeLists.txt +++ b/src/iot/mqtt/server/CMakeLists.txt @@ -74,25 +74,19 @@ set_target_properties( INSTALL_RPATH "${MQTT_RPATH};${HTTP_INSTALL_RPATH}/upgrade" ) -install( - TARGETS mqtt-server - EXPORT snodec_mqtt-server_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/${MQTT_INSTALL_DIR} - COMPONENT mqtt-server +snodec_add_component( + TARGET mqtt-server + LIBRARY_DESTINATION ${CMAKE_INSTALL_LIBDIR}/${MQTT_INSTALL_DIR} + PUBLIC_COMPONENT ) -install( - FILES Mqtt.h SharedSocketContextFactory.h SocketContextFactory.h - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${MQTT_INSTALL_DIR}/server - COMPONENT mqtt-server -) - -install( - EXPORT snodec_mqtt-server_Targets - FILE snodec_mqtt-server_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec +snodec_install_component_development_files( COMPONENT mqtt-server + FILES + Mqtt.h + SharedSocketContextFactory.h + SocketContextFactory.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${MQTT_INSTALL_DIR}/server ) set(MQTT_SERVER_WEBSOCKET_CPP SubProtocol.cpp) @@ -124,23 +118,14 @@ set_target_properties( INSTALL_RPATH "${MQTT_RPATH};${HTTP_INSTALL_RPATH}/upgrade" ) -install( - TARGETS mqtt-server-websocket - EXPORT snodec_mqtt-server-websocket_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/${MQTT_INSTALL_DIR} - COMPONENT mqtt-server-websocket +snodec_add_component( + TARGET mqtt-server-websocket + LIBRARY_DESTINATION ${CMAKE_INSTALL_LIBDIR}/${MQTT_INSTALL_DIR} + PUBLIC_COMPONENT ) -install( +snodec_install_component_development_files( + COMPONENT mqtt-server-websocket FILES SubProtocol.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${MQTT_INSTALL_DIR}/server - COMPONENT mqtt-server-websocket -) - -install( - EXPORT snodec_mqtt-server-websocket_Targets - FILE snodec_mqtt-server-websocket_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT mqtt-server-websocket ) diff --git a/src/iot/mqtt/server/broker/CMakeLists.txt b/src/iot/mqtt/server/broker/CMakeLists.txt index 0be8863709..5e02580b47 100644 --- a/src/iot/mqtt/server/broker/CMakeLists.txt +++ b/src/iot/mqtt/server/broker/CMakeLists.txt @@ -58,12 +58,12 @@ target_include_directories( mqtt-broker PUBLIC "$" ) -install( +snodec_install_component_headers( + COMPONENT mqtt-server DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${MQTT_INSTALL_INCLUDEDIR}/server/broker - COMPONENT mqtt-server - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/iot/mqtt/server/packets/CMakeLists.txt b/src/iot/mqtt/server/packets/CMakeLists.txt index 381f652aaa..ead31184fa 100644 --- a/src/iot/mqtt/server/packets/CMakeLists.txt +++ b/src/iot/mqtt/server/packets/CMakeLists.txt @@ -78,12 +78,12 @@ target_include_directories( mqtt-server-packets PUBLIC "$" ) -install( +snodec_install_component_headers( + COMPONENT mqtt-server DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${MQTT_INSTALL_INCLUDEDIR}/server/packets - COMPONENT mqtt-server - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/iot/mqtt/types/CMakeLists.txt b/src/iot/mqtt/types/CMakeLists.txt index 57981afcc7..8651215a4e 100644 --- a/src/iot/mqtt/types/CMakeLists.txt +++ b/src/iot/mqtt/types/CMakeLists.txt @@ -63,12 +63,12 @@ target_include_directories( mqtt-types PUBLIC "$" ) -install( +snodec_install_component_headers( + COMPONENT mqtt DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${MQTT_INSTALL_INCLUDEDIR}/types - COMPONENT mqtt - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/log/CMakeLists.txt b/src/log/CMakeLists.txt index 61af39e5a2..fa140844e1 100644 --- a/src/log/CMakeLists.txt +++ b/src/log/CMakeLists.txt @@ -89,26 +89,16 @@ set_target_properties( OUTPUT_NAME snodec-logger ) -install( - TARGETS logger - EXPORT snodec_logger_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT logger +snodec_add_component( + TARGET logger ) -install( +snodec_install_component_headers( + COMPONENT logger DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION include/snode.c/log - COMPONENT logger - FILES_MATCHING - PATTERN "*.h" - PATTERN "cmake" EXCLUDE - PATTERN "detail" EXCLUDE -) - -install( - EXPORT snodec_logger_Targets - FILE snodec_logger_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT logger + PATTERNS *.h + EXCLUDE_PATTERNS + cmake + detail ) diff --git a/src/net/CMakeLists.txt b/src/net/CMakeLists.txt index 401baf6a0f..045ea90ea0 100644 --- a/src/net/CMakeLists.txt +++ b/src/net/CMakeLists.txt @@ -215,33 +215,25 @@ set_target_properties( OUTPUT_NAME snodec-net ) -install( - TARGETS net - EXPORT snodec_net_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT net +snodec_add_component( + TARGET net + PUBLIC_COMPONENT ) -install( +snodec_install_component_headers( + COMPONENT net DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net - COMPONENT net - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE - PATTERN "in" EXCLUDE - PATTERN "in6" EXCLUDE - PATTERN "l2" EXCLUDE - PATTERN "rc" EXCLUDE - PATTERN "un" EXCLUDE -) - -install( - EXPORT snodec_net_Targets - FILE snodec_net_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT net + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + in + in6 + l2 + rc + un ) add_subdirectory(in) diff --git a/src/net/in/CMakeLists.txt b/src/net/in/CMakeLists.txt index ee2eab2fc4..aea1e28be1 100644 --- a/src/net/in/CMakeLists.txt +++ b/src/net/in/CMakeLists.txt @@ -69,31 +69,22 @@ set_target_properties( OUTPUT_NAME snodec-net-in ) -install( - TARGETS net-in - EXPORT snodec_net-in_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT net-in +snodec_add_component( + TARGET net-in ) -install( +snodec_install_component_headers( + COMPONENT net-in DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/in - COMPONENT net-in - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE - PATTERN "stream" EXCLUDE - PATTERN "dgram" EXCLUDE - PATTERN "phy" EXCLUDE -) - -install( - EXPORT snodec_net-in_Targets - FILE snodec_net-in_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT net-in + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + stream + dgram + phy ) add_subdirectory(phy) diff --git a/src/net/in/phy/CMakeLists.txt b/src/net/in/phy/CMakeLists.txt index 16e718e053..44f387c673 100644 --- a/src/net/in/phy/CMakeLists.txt +++ b/src/net/in/phy/CMakeLists.txt @@ -60,30 +60,21 @@ set_target_properties( OUTPUT_NAME snodec-net-in-phy ) -install( - TARGETS net-in-phy - EXPORT snodec_net-in-phy_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT net-in-phy +snodec_add_component( + TARGET net-in-phy ) -install( +snodec_install_component_headers( + COMPONENT net-in-phy DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/in/phy - COMPONENT net-in-phy - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE - PATTERN "stream" EXCLUDE - PATTERN "dgram" EXCLUDE -) - -install( - EXPORT snodec_net-in-phy_Targets - FILE snodec_net-in-phy_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT net-in-phy + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + stream + dgram ) add_subdirectory(stream) diff --git a/src/net/in/phy/stream/CMakeLists.txt b/src/net/in/phy/stream/CMakeLists.txt index f874a682a3..e1ec569179 100644 --- a/src/net/in/phy/stream/CMakeLists.txt +++ b/src/net/in/phy/stream/CMakeLists.txt @@ -66,28 +66,19 @@ set_target_properties( OUTPUT_NAME snodec-net-in-phy-stream ) -install( - TARGETS net-in-phy-stream - EXPORT snodec_net-in-phy-stream_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT net-in-phy-stream +snodec_add_component( + TARGET net-in-phy-stream ) -install( +snodec_install_component_headers( + COMPONENT net-in-phy-stream DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/in/phy/stream - COMPONENT net-in-phy-stream - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE - PATTERN "legacy" EXCLUDE - PATTERN "tls" EXCLUDE -) - -install( - EXPORT snodec_net-in-phy-stream_Targets - FILE snodec_net-in-phy-stream_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT net-in-phy-stream + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + legacy + tls ) diff --git a/src/net/in/stream/CMakeLists.txt b/src/net/in/stream/CMakeLists.txt index 287421412f..67391f660e 100644 --- a/src/net/in/stream/CMakeLists.txt +++ b/src/net/in/stream/CMakeLists.txt @@ -80,30 +80,21 @@ set_target_properties( OUTPUT_NAME snodec-net-in-stream ) -install( - TARGETS net-in-stream - EXPORT snodec_net-in-stream_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT net-in-stream +snodec_add_component( + TARGET net-in-stream ) -install( +snodec_install_component_headers( + COMPONENT net-in-stream DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/in/stream - COMPONENT net-in-stream - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE - PATTERN "legacy" EXCLUDE - PATTERN "tls" EXCLUDE -) - -install( - EXPORT snodec_net-in-stream_Targets - FILE snodec_net-in-stream_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT net-in-stream + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + legacy + tls ) add_subdirectory(legacy) diff --git a/src/net/in/stream/legacy/CMakeLists.txt b/src/net/in/stream/legacy/CMakeLists.txt index f355b7dcbe..5273e0f597 100644 --- a/src/net/in/stream/legacy/CMakeLists.txt +++ b/src/net/in/stream/legacy/CMakeLists.txt @@ -71,26 +71,17 @@ set_target_properties( OUTPUT_NAME snodec-net-in-stream-legacy ) -install( - TARGETS net-in-stream-legacy - EXPORT snodec_net-in-stream-legacy_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT net-in-stream-legacy +snodec_add_component( + TARGET net-in-stream-legacy + PUBLIC_COMPONENT ) -install( +snodec_install_component_headers( + COMPONENT net-in-stream-legacy DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/in/stream/legacy - COMPONENT net-in-stream-legacy - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE -) - -install( - EXPORT snodec_net-in-stream-legacy_Targets - FILE snodec_net-in-stream-legacy_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT net-in-stream-legacy + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/net/in/stream/tls/CMakeLists.txt b/src/net/in/stream/tls/CMakeLists.txt index 8ea3dfdb56..5f101c99b5 100644 --- a/src/net/in/stream/tls/CMakeLists.txt +++ b/src/net/in/stream/tls/CMakeLists.txt @@ -69,26 +69,17 @@ set_target_properties( OUTPUT_NAME snodec-net-in-stream-tls ) -install( - TARGETS net-in-stream-tls - EXPORT snodec_net-in-stream-tls_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT net-in-stream-tls +snodec_add_component( + TARGET net-in-stream-tls + PUBLIC_COMPONENT ) -install( +snodec_install_component_headers( + COMPONENT net-in-stream-tls DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/in/stream/tls - COMPONENT net-in-stream-tls - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE -) - -install( - EXPORT snodec_net-in-stream-tls_Targets - FILE snodec_net-in-stream-tls_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT net-in-stream-tls + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/net/in6/CMakeLists.txt b/src/net/in6/CMakeLists.txt index 9ba47b35c5..6fc956a852 100644 --- a/src/net/in6/CMakeLists.txt +++ b/src/net/in6/CMakeLists.txt @@ -73,31 +73,22 @@ set_target_properties( OUTPUT_NAME snodec-net-in6 ) -install( - TARGETS net-in6 - EXPORT snodec_net-in6_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT net-in6 +snodec_add_component( + TARGET net-in6 ) -install( +snodec_install_component_headers( + COMPONENT net-in6 DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/in6 - COMPONENT net-in6 - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE - PATTERN "stream" EXCLUDE - PATTERN "dgram" EXCLUDE - PATTERN "phy" EXCLUDE -) - -install( - EXPORT snodec_net-in6_Targets - FILE snodec_net-in6_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT net-in6 + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + stream + dgram + phy ) add_subdirectory(phy) diff --git a/src/net/in6/phy/CMakeLists.txt b/src/net/in6/phy/CMakeLists.txt index 0f33f193f0..55f6769f2e 100644 --- a/src/net/in6/phy/CMakeLists.txt +++ b/src/net/in6/phy/CMakeLists.txt @@ -60,30 +60,21 @@ set_target_properties( OUTPUT_NAME snodec-net-in6-phy ) -install( - TARGETS net-in6-phy - EXPORT snodec_net-in6-phy_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT net-in6-phy +snodec_add_component( + TARGET net-in6-phy ) -install( +snodec_install_component_headers( + COMPONENT net-in6-phy DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/in6/phy - COMPONENT net-in6-phy - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE - PATTERN "stream" EXCLUDE - PATTERN "dgram" EXCLUDE -) - -install( - EXPORT snodec_net-in6-phy_Targets - FILE snodec_net-in6-phy_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT net-in6-phy + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + stream + dgram ) add_subdirectory(stream) diff --git a/src/net/in6/phy/stream/CMakeLists.txt b/src/net/in6/phy/stream/CMakeLists.txt index c0bd22a939..484a20b4aa 100644 --- a/src/net/in6/phy/stream/CMakeLists.txt +++ b/src/net/in6/phy/stream/CMakeLists.txt @@ -66,28 +66,19 @@ set_target_properties( OUTPUT_NAME snodec-net-in6-phy-stream ) -install( - TARGETS net-in6-phy-stream - EXPORT snodec_net-in6-phy-stream_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT net-in6-stream +snodec_add_component( + TARGET net-in6-phy-stream ) -install( +snodec_install_component_headers( + COMPONENT net-in6-phy-stream DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/in6/phy/stream - COMPONENT net-in6-phy-stream - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE - PATTERN "legacy" EXCLUDE - PATTERN "tls" EXCLUDE -) - -install( - EXPORT snodec_net-in6-phy-stream_Targets - FILE snodec_net-in6-phy-stream_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT net-in6-phy-stream + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + legacy + tls ) diff --git a/src/net/in6/stream/CMakeLists.txt b/src/net/in6/stream/CMakeLists.txt index 80cc58d547..fab87bfb56 100644 --- a/src/net/in6/stream/CMakeLists.txt +++ b/src/net/in6/stream/CMakeLists.txt @@ -83,30 +83,21 @@ set_target_properties( OUTPUT_NAME snodec-net-in6-stream ) -install( - TARGETS net-in6-stream - EXPORT snodec_net-in6-stream_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT net-in6-stream +snodec_add_component( + TARGET net-in6-stream ) -install( +snodec_install_component_headers( + COMPONENT net-in6-stream DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/in6/stream - COMPONENT net-in6-stream - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE - PATTERN "legacy" EXCLUDE - PATTERN "tls" EXCLUDE -) - -install( - EXPORT snodec_net-in6-stream_Targets - FILE snodec_net-in6-stream_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT net-in6-stream + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + legacy + tls ) add_subdirectory(legacy) diff --git a/src/net/in6/stream/legacy/CMakeLists.txt b/src/net/in6/stream/legacy/CMakeLists.txt index 31e3692791..e60a571e5f 100644 --- a/src/net/in6/stream/legacy/CMakeLists.txt +++ b/src/net/in6/stream/legacy/CMakeLists.txt @@ -71,26 +71,17 @@ set_target_properties( OUTPUT_NAME snodec-net-in6-stream-legacy ) -install( - TARGETS net-in6-stream-legacy - EXPORT snodec_net-in6-stream-legacy_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT net-in6-stream-legacy +snodec_add_component( + TARGET net-in6-stream-legacy + PUBLIC_COMPONENT ) -install( +snodec_install_component_headers( + COMPONENT net-in6-stream-legacy DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/in6/stream/legacy - COMPONENT net-in6-stream-legacy - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE -) - -install( - EXPORT snodec_net-in6-stream-legacy_Targets - FILE snodec_net-in6-stream-legacy_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT net-in6-stream-legacy + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/net/in6/stream/tls/CMakeLists.txt b/src/net/in6/stream/tls/CMakeLists.txt index cc35f57927..01282ad19d 100644 --- a/src/net/in6/stream/tls/CMakeLists.txt +++ b/src/net/in6/stream/tls/CMakeLists.txt @@ -70,26 +70,17 @@ set_target_properties( OUTPUT_NAME snodec-net-in6-stream-tls ) -install( - TARGETS net-in6-stream-tls - EXPORT snodec_net-in6-stream-tls_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT net-in6-stream-tls +snodec_add_component( + TARGET net-in6-stream-tls + PUBLIC_COMPONENT ) -install( +snodec_install_component_headers( + COMPONENT net-in6-stream-tls DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/in6/stream/tls - COMPONENT net-in6-stream-tls - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE -) - -install( - EXPORT snodec_net-in6-stream-tls_Targets - FILE snodec_net-in6-stream-tls_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT net-in6-stream-tls + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/net/l2/CMakeLists.txt b/src/net/l2/CMakeLists.txt index f02bcf0bdd..c25d156ce5 100644 --- a/src/net/l2/CMakeLists.txt +++ b/src/net/l2/CMakeLists.txt @@ -65,31 +65,22 @@ if(BLUEZ_FOUND) OUTPUT_NAME snodec-net-l2 ) - install( - TARGETS net-l2 - EXPORT snodec_net-l2_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT net-l2 + snodec_add_component( + TARGET net-l2 ) - install( + snodec_install_component_headers( + COMPONENT net-l2 DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/l2 - COMPONENT net-l2 - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE - PATTERN "stream" EXCLUDE - PATTERN "dgram" EXCLUDE - PATTERN "phy" EXCLUDE - ) - - install( - EXPORT snodec_net-l2_Targets - FILE snodec_net-l2_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT net-l2 + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + stream + dgram + phy ) add_subdirectory(phy) diff --git a/src/net/l2/phy/CMakeLists.txt b/src/net/l2/phy/CMakeLists.txt index ee317d5e27..92fb0300db 100644 --- a/src/net/l2/phy/CMakeLists.txt +++ b/src/net/l2/phy/CMakeLists.txt @@ -60,30 +60,21 @@ set_target_properties( OUTPUT_NAME snodec-net-l2-phy ) -install( - TARGETS net-l2-phy - EXPORT snodec_net-l2-phy_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT net-l2-phy +snodec_add_component( + TARGET net-l2-phy ) -install( +snodec_install_component_headers( + COMPONENT net-l2-phy DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/l2/phy - COMPONENT net-l2-phy - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE - PATTERN "stream" EXCLUDE - PATTERN "dgram" EXCLUDE -) - -install( - EXPORT snodec_net-l2-phy_Targets - FILE snodec_net-l2-phy_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT net-l2-phy + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + stream + dgram ) add_subdirectory(stream) diff --git a/src/net/l2/phy/stream/CMakeLists.txt b/src/net/l2/phy/stream/CMakeLists.txt index e400949ce6..47d1a8f9a4 100644 --- a/src/net/l2/phy/stream/CMakeLists.txt +++ b/src/net/l2/phy/stream/CMakeLists.txt @@ -66,28 +66,19 @@ set_target_properties( OUTPUT_NAME snodec-net-l2-phy-stream ) -install( - TARGETS net-l2-phy-stream - EXPORT snodec_net-l2-phy-stream_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT net-l2-stream +snodec_add_component( + TARGET net-l2-phy-stream ) -install( +snodec_install_component_headers( + COMPONENT net-l2-phy-stream DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/l2/phy/stream - COMPONENT net-l2-phy-stream - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE - PATTERN "legacy" EXCLUDE - PATTERN "tls" EXCLUDE -) - -install( - EXPORT snodec_net-l2-phy-stream_Targets - FILE snodec_net-l2-phy-stream_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT net-l2-phy-stream + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + legacy + tls ) diff --git a/src/net/l2/stream/CMakeLists.txt b/src/net/l2/stream/CMakeLists.txt index 2c9c1f0b36..c29f77e157 100644 --- a/src/net/l2/stream/CMakeLists.txt +++ b/src/net/l2/stream/CMakeLists.txt @@ -64,30 +64,21 @@ set_target_properties( OUTPUT_NAME snodec-net-l2-stream ) -install( - TARGETS net-l2-stream - EXPORT snodec_net-l2-stream_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT net-l2-stream +snodec_add_component( + TARGET net-l2-stream ) -install( +snodec_install_component_headers( + COMPONENT net-l2-stream DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/l2/stream - COMPONENT net-l2-stream - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE - PATTERN "legacy" EXCLUDE - PATTERN "tls" EXCLUDE -) - -install( - EXPORT snodec_net-l2-stream_Targets - FILE snodec_net-l2-stream_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT net-l2-stream + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + legacy + tls ) add_subdirectory(legacy) diff --git a/src/net/l2/stream/legacy/CMakeLists.txt b/src/net/l2/stream/legacy/CMakeLists.txt index a859abcb08..7f7f88caa2 100644 --- a/src/net/l2/stream/legacy/CMakeLists.txt +++ b/src/net/l2/stream/legacy/CMakeLists.txt @@ -76,26 +76,17 @@ set(NET-L2-STREAM-LEGACY CACHE INTERNAL "net-l2-stream-legacy component" ) -install( - TARGETS net-l2-stream-legacy - EXPORT snodec_net-l2-stream-legacy_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT net-l2-stream-legacy +snodec_add_component( + TARGET net-l2-stream-legacy + PUBLIC_COMPONENT ) -install( +snodec_install_component_headers( + COMPONENT net-l2-stream-legacy DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/l2/stream/legacy - COMPONENT net-l2-stream-legacy - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE -) - -install( - EXPORT snodec_net-l2-stream-legacy_Targets - FILE snodec_net-l2-stream-legacy_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT net-l2-stream-legacy + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/net/l2/stream/tls/CMakeLists.txt b/src/net/l2/stream/tls/CMakeLists.txt index ee302aab45..c5094ee2a7 100644 --- a/src/net/l2/stream/tls/CMakeLists.txt +++ b/src/net/l2/stream/tls/CMakeLists.txt @@ -74,26 +74,17 @@ set(NET-L2-STREAM-TLS CACHE INTERNAL "net-l2-stream-tls component" ) -install( - TARGETS net-l2-stream-tls - EXPORT snodec_net-l2-stream-tls_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT net-l2-stream-tls +snodec_add_component( + TARGET net-l2-stream-tls + PUBLIC_COMPONENT ) -install( +snodec_install_component_headers( + COMPONENT net-l2-stream-tls DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/l2/stream/tls - COMPONENT net-l2-stream-tls - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE -) - -install( - EXPORT snodec_net-l2-stream-tls_Targets - FILE snodec_net-l2-stream-tls_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT net-l2-stream-tls + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/net/rc/CMakeLists.txt b/src/net/rc/CMakeLists.txt index 5bb0d5f6ae..e862b17cdd 100644 --- a/src/net/rc/CMakeLists.txt +++ b/src/net/rc/CMakeLists.txt @@ -65,31 +65,22 @@ if(BLUEZ_FOUND) OUTPUT_NAME snodec-net-rc ) - install( - TARGETS net-rc - EXPORT snodec_net-rc_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT net-rc + snodec_add_component( + TARGET net-rc ) - install( + snodec_install_component_headers( + COMPONENT net-rc DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/rc - COMPONENT net-rc - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE - PATTERN "stream" EXCLUDE - PATTERN "dgram" EXCLUDE - PATTERN "phy" EXCLUDE - ) - - install( - EXPORT snodec_net-rc_Targets - FILE snodec_net-rc_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT net-rc + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + stream + dgram + phy ) add_subdirectory(phy) diff --git a/src/net/rc/phy/CMakeLists.txt b/src/net/rc/phy/CMakeLists.txt index 7d1d3e73ea..965823dd9c 100644 --- a/src/net/rc/phy/CMakeLists.txt +++ b/src/net/rc/phy/CMakeLists.txt @@ -60,30 +60,21 @@ set_target_properties( OUTPUT_NAME snodec-net-rc-phy ) -install( - TARGETS net-rc-phy - EXPORT snodec_net-rc-phy_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT net-rc-phy +snodec_add_component( + TARGET net-rc-phy ) -install( +snodec_install_component_headers( + COMPONENT net-rc-phy DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/rc/phy - COMPONENT net-rc-phy - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE - PATTERN "stream" EXCLUDE - PATTERN "dgram" EXCLUDE -) - -install( - EXPORT snodec_net-rc-phy_Targets - FILE snodec_net-rc-phy_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT net-rc-phy + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + stream + dgram ) add_subdirectory(stream) diff --git a/src/net/rc/phy/stream/CMakeLists.txt b/src/net/rc/phy/stream/CMakeLists.txt index 2ac1fc2ac9..9f7847154e 100644 --- a/src/net/rc/phy/stream/CMakeLists.txt +++ b/src/net/rc/phy/stream/CMakeLists.txt @@ -66,28 +66,19 @@ set_target_properties( OUTPUT_NAME snodec-net-rc-phy-stream ) -install( - TARGETS net-rc-phy-stream - EXPORT snodec_net-rc-phy-stream_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT net-rc-stream +snodec_add_component( + TARGET net-rc-phy-stream ) -install( +snodec_install_component_headers( + COMPONENT net-rc-phy-stream DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/rc/phy/stream - COMPONENT net-rc-phy-stream - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE - PATTERN "legacy" EXCLUDE - PATTERN "tls" EXCLUDE -) - -install( - EXPORT snodec_net-rc-phy-stream_Targets - FILE snodec_net-rc-phy-stream_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT net-rc-phy-stream + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + legacy + tls ) diff --git a/src/net/rc/stream/CMakeLists.txt b/src/net/rc/stream/CMakeLists.txt index 980f21d405..fa1fccd56b 100644 --- a/src/net/rc/stream/CMakeLists.txt +++ b/src/net/rc/stream/CMakeLists.txt @@ -64,30 +64,21 @@ set_target_properties( OUTPUT_NAME snodec-net-rc-stream ) -install( - TARGETS net-rc-stream - EXPORT snodec_net-rc-stream_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT net-rc-stream +snodec_add_component( + TARGET net-rc-stream ) -install( +snodec_install_component_headers( + COMPONENT net-rc-stream DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/rc/stream - COMPONENT net-rc-stream - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE - PATTERN "legacy" EXCLUDE - PATTERN "tls" EXCLUDE -) - -install( - EXPORT snodec_net-rc-stream_Targets - FILE snodec_net-rc-stream_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT net-rc-stream + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + legacy + tls ) add_subdirectory(legacy) diff --git a/src/net/rc/stream/legacy/CMakeLists.txt b/src/net/rc/stream/legacy/CMakeLists.txt index 929b0b00ae..c283f8ddf1 100644 --- a/src/net/rc/stream/legacy/CMakeLists.txt +++ b/src/net/rc/stream/legacy/CMakeLists.txt @@ -76,26 +76,17 @@ set(NET-RC-STREAM-LEGACY CACHE INTERNAL "net-rc-stream-legacy component" ) -install( - TARGETS net-rc-stream-legacy - EXPORT snodec_net-rc-stream-legacy_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT net-rc-stream-legacy +snodec_add_component( + TARGET net-rc-stream-legacy + PUBLIC_COMPONENT ) -install( +snodec_install_component_headers( + COMPONENT net-rc-stream-legacy DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/rc/stream/legacy - COMPONENT net-rc-stream-legacy - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE -) - -install( - EXPORT snodec_net-rc-stream-legacy_Targets - FILE snodec_net-rc-stream-legacy_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT net-rc-stream-legacy + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/net/rc/stream/tls/CMakeLists.txt b/src/net/rc/stream/tls/CMakeLists.txt index 39f7cf2bf0..b107f299cb 100644 --- a/src/net/rc/stream/tls/CMakeLists.txt +++ b/src/net/rc/stream/tls/CMakeLists.txt @@ -74,26 +74,17 @@ set(NET-RC-STREAM-TLS CACHE INTERNAL "net-rc-stream-tls component" ) -install( - TARGETS net-rc-stream-tls - EXPORT snodec_net-rc-stream-tls_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT net-rc-stream-tls +snodec_add_component( + TARGET net-rc-stream-tls + PUBLIC_COMPONENT ) -install( +snodec_install_component_headers( + COMPONENT net-rc-stream-tls DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/rc/stream/tls - COMPONENT net-rc-stream-tls - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE -) - -install( - EXPORT snodec_net-rc-stream-tls_Targets - FILE snodec_net-rc-stream-tls_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT net-rc-stream-tls + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/net/un/CMakeLists.txt b/src/net/un/CMakeLists.txt index 9daf9c3b7b..8382904dd5 100644 --- a/src/net/un/CMakeLists.txt +++ b/src/net/un/CMakeLists.txt @@ -60,31 +60,22 @@ set_target_properties( OUTPUT_NAME snodec-net-un ) -install( - TARGETS net-un - EXPORT snodec_net-un_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT net-un +snodec_add_component( + TARGET net-un ) -install( +snodec_install_component_headers( + COMPONENT net-un DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/un - COMPONENT net-un - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE - PATTERN "stream" EXCLUDE - PATTERN "dgram" EXCLUDE - PATTERN "phy" EXCLUDE -) - -install( - EXPORT snodec_net-un_Targets - FILE snodec_net-un_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT net-un + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + stream + dgram + phy ) add_subdirectory(phy) diff --git a/src/net/un/dgram/CMakeLists.txt b/src/net/un/dgram/CMakeLists.txt index 101b02c7c5..a300cb1d41 100644 --- a/src/net/un/dgram/CMakeLists.txt +++ b/src/net/un/dgram/CMakeLists.txt @@ -60,26 +60,17 @@ set_target_properties( OUTPUT_NAME snodec-net-un-dgram ) -install( - TARGETS net-un-dgram - EXPORT snodec_net-un-dgram_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT net-un-dgram +snodec_add_component( + TARGET net-un-dgram + PUBLIC_COMPONENT ) -install( +snodec_install_component_headers( + COMPONENT net-un-dgram DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/un/dgram - COMPONENT net-un-dgram - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE -) - -install( - EXPORT snodec_net-un-dgram_Targets - FILE snodec_net-un-dgram_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT net-un-dgram + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/net/un/phy/CMakeLists.txt b/src/net/un/phy/CMakeLists.txt index 2eec98eda9..1d90f8ff92 100644 --- a/src/net/un/phy/CMakeLists.txt +++ b/src/net/un/phy/CMakeLists.txt @@ -60,30 +60,21 @@ set_target_properties( OUTPUT_NAME snodec-net-un-phy ) -install( - TARGETS net-un-phy - EXPORT snodec_net-un-phy_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT net-un-phy +snodec_add_component( + TARGET net-un-phy ) -install( +snodec_install_component_headers( + COMPONENT net-un-phy DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/un/phy - COMPONENT net-un-phy - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE - PATTERN "stream" EXCLUDE - PATTERN "dgram" EXCLUDE -) - -install( - EXPORT snodec_net-un-phy_Targets - FILE snodec_net-un-phy_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT net-un-phy + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + stream + dgram ) add_subdirectory(stream) diff --git a/src/net/un/phy/stream/CMakeLists.txt b/src/net/un/phy/stream/CMakeLists.txt index edd217ab95..08c6bafdaa 100644 --- a/src/net/un/phy/stream/CMakeLists.txt +++ b/src/net/un/phy/stream/CMakeLists.txt @@ -66,28 +66,19 @@ set_target_properties( OUTPUT_NAME snodec-net-un-phy-stream ) -install( - TARGETS net-un-phy-stream - EXPORT snodec_net-un-phy-stream_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT net-un-phy-stream +snodec_add_component( + TARGET net-un-phy-stream ) -install( +snodec_install_component_headers( + COMPONENT net-un-phy-stream DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/un/phy/stream - COMPONENT net-un-phy-stream - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE - PATTERN "legacy" EXCLUDE - PATTERN "tls" EXCLUDE -) - -install( - EXPORT snodec_net-un-phy-stream_Targets - FILE snodec_net-un-phy-stream_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT net-un-sphy-tream + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + legacy + tls ) diff --git a/src/net/un/stream/CMakeLists.txt b/src/net/un/stream/CMakeLists.txt index 8b79012e24..af2e24c896 100644 --- a/src/net/un/stream/CMakeLists.txt +++ b/src/net/un/stream/CMakeLists.txt @@ -64,30 +64,21 @@ set_target_properties( OUTPUT_NAME snodec-net-un-stream ) -install( - TARGETS net-un-stream - EXPORT snodec_net-un-stream_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT net-un-stream +snodec_add_component( + TARGET net-un-stream ) -install( +snodec_install_component_headers( + COMPONENT net-un-stream DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/un/stream - COMPONENT net-un-stream - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE - PATTERN "legacy" EXCLUDE - PATTERN "tls" EXCLUDE -) - -install( - EXPORT snodec_net-un-stream_Targets - FILE snodec_net-un-stream_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT net-un-stream + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + legacy + tls ) add_subdirectory(legacy) diff --git a/src/net/un/stream/legacy/CMakeLists.txt b/src/net/un/stream/legacy/CMakeLists.txt index 8a530fe139..4f17f6e7a4 100644 --- a/src/net/un/stream/legacy/CMakeLists.txt +++ b/src/net/un/stream/legacy/CMakeLists.txt @@ -71,26 +71,17 @@ set_target_properties( OUTPUT_NAME snodec-net-un-stream-legacy ) -install( - TARGETS net-un-stream-legacy - EXPORT snodec_net-un-stream-legacy_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT net-un-stream-legacy +snodec_add_component( + TARGET net-un-stream-legacy + PUBLIC_COMPONENT ) -install( +snodec_install_component_headers( + COMPONENT net-un-stream-legacy DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/un/stream/legacy - COMPONENT net-un-stream-legacy - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE -) - -install( - EXPORT snodec_net-un-stream-legacy_Targets - FILE snodec_net-un-stream-legacy_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT net-un-stream-legacy + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/net/un/stream/tls/CMakeLists.txt b/src/net/un/stream/tls/CMakeLists.txt index 99c676e9fd..e661cfe11d 100644 --- a/src/net/un/stream/tls/CMakeLists.txt +++ b/src/net/un/stream/tls/CMakeLists.txt @@ -69,26 +69,17 @@ set_target_properties( OUTPUT_NAME snodec-net-un-stream-tls ) -install( - TARGETS net-un-stream-tls - EXPORT snodec_net-un-stream-tls_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT net-un-stream-tls +snodec_add_component( + TARGET net-un-stream-tls + PUBLIC_COMPONENT ) -install( +snodec_install_component_headers( + COMPONENT net-un-stream-tls DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/un/stream/tls - COMPONENT net-un-stream-tls - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE -) - -install( - EXPORT snodec_net-un-stream-tls_Targets - FILE snodec_net-un-stream-tls_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT net-un-stream-tls + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/tools/snodec-control/CMakeLists.txt b/src/tools/snodec-control/CMakeLists.txt index becac85711..2a989f01c7 100644 --- a/src/tools/snodec-control/CMakeLists.txt +++ b/src/tools/snodec-control/CMakeLists.txt @@ -17,6 +17,10 @@ project( include(GNUInstallDirs) +if(NOT COMMAND snodec_install_runtime_targets) + include("${CMAKE_CURRENT_LIST_DIR}/../../../cmake/SNodeCComponent.cmake") +endif() + set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) diff --git a/src/tools/snodec-control/src/CMakeLists.txt b/src/tools/snodec-control/src/CMakeLists.txt index 735d95b75e..e042912d7a 100644 --- a/src/tools/snodec-control/src/CMakeLists.txt +++ b/src/tools/snodec-control/src/CMakeLists.txt @@ -90,4 +90,13 @@ add_executable( ) target_link_libraries(snodec-control PRIVATE snodec-control-core snodec-control-ui) -install(TARGETS snodec-control RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +snodec_install_runtime_targets( + COMPONENT snodec-control + TARGETS snodec-control +) + +snodec_register_runtime_component( + COMPONENT snodec-control + DISPLAY_NAME "SNode.C control utility" + DESCRIPTION "Runtime files for the snodec-control utility" +) diff --git a/src/utils/CMakeLists.txt b/src/utils/CMakeLists.txt index ccae3ddb12..9dd7cfff36 100644 --- a/src/utils/CMakeLists.txt +++ b/src/utils/CMakeLists.txt @@ -101,26 +101,16 @@ set_target_properties( OUTPUT_NAME snodec-utils ) -install( - TARGETS utils - EXPORT snodec_utils_Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT utils +snodec_add_component( + TARGET utils ) -install( +snodec_install_component_headers( + COMPONENT utils DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/utils - COMPONENT utils - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE -) - -install( - EXPORT snodec_utils_Targets - FILE snodec_utils_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT utils + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/web/http/CMakeLists.txt b/src/web/http/CMakeLists.txt index e1533c3311..2f84ea7a76 100644 --- a/src/web/http/CMakeLists.txt +++ b/src/web/http/CMakeLists.txt @@ -147,32 +147,25 @@ set_target_properties( HTTP_UPGRADE_INSTALL_LIBDIR ${HTTP_UPGRADE_INSTALL_LIBDIR} ) -install( - TARGETS http - EXPORT snodec_http_Targets - LIBRARY DESTINATION ${HTTP_INSTALL_LIBDIR} COMPONENT http +snodec_add_component( + TARGET http + LIBRARY_DESTINATION ${HTTP_INSTALL_LIBDIR} + PUBLIC_COMPONENT ) -install( +snodec_install_component_headers( + COMPONENT http DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${HTTP_INSTALL_INCLUDEDIR} - COMPONENT http - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE - PATTERN "server" EXCLUDE - PATTERN "client" EXCLUDE - PATTERN "legacy" EXCLUDE - PATTERN "tls" EXCLUDE -) - -install( - EXPORT snodec_http_Targets - FILE snodec_http_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT http + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + server + client + legacy + tls ) add_subdirectory(server) @@ -183,8 +176,8 @@ configure_file( @ONLY ) -install( - FILES "${CMAKE_CURRENT_BINARY_DIR}/snodec_http_Targets_Config.cmake" - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec +snodec_install_component_development_files( COMPONENT http + FILES ${CMAKE_CURRENT_BINARY_DIR}/snodec_http_Targets_Config.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec ) diff --git a/src/web/http/client/CMakeLists.txt b/src/web/http/client/CMakeLists.txt index 311f5dc5cd..dbc0124485 100644 --- a/src/web/http/client/CMakeLists.txt +++ b/src/web/http/client/CMakeLists.txt @@ -109,44 +109,36 @@ set_target_properties( HTTP_UPGRADE_INSTALL_LIBDIR "${HTTP_UPGRADE_INSTALL_LIBDIR}" ) -install( +snodec_add_component( + TARGET http-client + LIBRARY_DESTINATION ${HTTP_INSTALL_LIBDIR} + PUBLIC_COMPONENT +) + +snodec_install_component_headers( + COMPONENT http-client DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${HTTP_INSTALL_INCLUDEDIR}/client - COMPONENT http-client - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) -install( +snodec_install_component_headers( + COMPONENT http-client DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../legacy/ DESTINATION ${HTTP_INSTALL_INCLUDEDIR}/legacy - COMPONENT http-client - FILES_MATCHING - PATTERN "Client.h" - PATTERN "EventSource.h" + PATTERNS + Client.h + EventSource.h ) -install( +snodec_install_component_headers( + COMPONENT http-client DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../tls/ DESTINATION ${HTTP_INSTALL_INCLUDEDIR}/tls - COMPONENT http-client - FILES_MATCHING - PATTERN "Client.h" - PATTERN "EventSource.h" -) - -install( - TARGETS http-client - EXPORT snodec_http-client_Targets - LIBRARY DESTINATION ${HTTP_INSTALL_LIBDIR} COMPONENT http-client -) - -install( - EXPORT snodec_http-client_Targets - FILE snodec_http-client_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT http-client + PATTERNS + Client.h + EventSource.h ) diff --git a/src/web/http/server/CMakeLists.txt b/src/web/http/server/CMakeLists.txt index 2823e9afdb..6ba358a3bf 100644 --- a/src/web/http/server/CMakeLists.txt +++ b/src/web/http/server/CMakeLists.txt @@ -93,43 +93,34 @@ set_target_properties( HTTP_UPGRADE_INSTALL_LIBDIR "${HTTP_UPGRADE_INSTALL_LIBDIR}" ) -install( +snodec_add_component( + TARGET http-server + LIBRARY_DESTINATION ${HTTP_INSTALL_LIBDIR} + PUBLIC_COMPONENT +) + +snodec_install_component_headers( + COMPONENT http-server DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${HTTP_INSTALL_INCLUDEDIR}/server - COMPONENT http-server - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE - PATTERN "pu" EXCLUDE + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + pu ) -install( +snodec_install_component_headers( + COMPONENT http-server DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../legacy/ DESTINATION ${HTTP_INSTALL_INCLUDEDIR}/legacy - COMPONENT http-server - FILES_MATCHING - PATTERN "Server.h" + PATTERNS Server.h ) -install( +snodec_install_component_headers( + COMPONENT http-server DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../tls/ DESTINATION ${HTTP_INSTALL_INCLUDEDIR}/tls - COMPONENT http-server - FILES_MATCHING - PATTERN "Server.h" -) - -install( - TARGETS http-server - EXPORT snodec_http-server_Targets - LIBRARY DESTINATION ${HTTP_INSTALL_LIBDIR} COMPONENT http-server -) - -install( - EXPORT snodec_http-server_Targets - FILE snodec_http-server_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT http-server + PATTERNS Server.h ) diff --git a/src/web/websocket/CMakeLists.txt b/src/web/websocket/CMakeLists.txt index 346a549b6c..b81d15ee8f 100644 --- a/src/web/websocket/CMakeLists.txt +++ b/src/web/websocket/CMakeLists.txt @@ -92,31 +92,23 @@ set_target_properties( ${WEBSOCKET_SUBPROTOCOL_INSTALL_LIBDIR} ) -install( - TARGETS websocket - EXPORT snodec_websocket_Targets - LIBRARY DESTINATION ${HTTP_UPGRADE_INSTALL_LIBDIR} COMPONENT websocket +snodec_add_component( + TARGET websocket + LIBRARY_DESTINATION ${HTTP_UPGRADE_INSTALL_LIBDIR} ) -install( +snodec_install_component_headers( + COMPONENT websocket DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${WEBSOCKET_INSTALL_INCLUDEDIR} - COMPONENT websocket - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE - PATTERN "client" EXCLUDE - PATTERN "server" EXCLUDE - PATTERN "subprotocol" EXCLUDE -) - -install( - EXPORT snodec_websocket_Targets - FILE snodec_websocket_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT websocket + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + client + server + subprotocol ) add_subdirectory(server) @@ -127,8 +119,8 @@ configure_file( snodec_websocket_Targets_Config.cmake @ONLY ) -install( - FILES "${CMAKE_CURRENT_BINARY_DIR}/snodec_websocket_Targets_Config.cmake" - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec +snodec_install_component_development_files( COMPONENT websocket + FILES ${CMAKE_CURRENT_BINARY_DIR}/snodec_websocket_Targets_Config.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec ) diff --git a/src/web/websocket/client/CMakeLists.txt b/src/web/websocket/client/CMakeLists.txt index 8165624a87..f8f565b2de 100644 --- a/src/web/websocket/client/CMakeLists.txt +++ b/src/web/websocket/client/CMakeLists.txt @@ -106,27 +106,18 @@ target_compile_options( target_link_libraries(websocket-client PUBLIC websocket http-client) -install( - TARGETS websocket-client - EXPORT snodec_websocket-client_Targets - LIBRARY DESTINATION ${HTTP_UPGRADE_INSTALL_LIBDIR} - COMPONENT websocket-client +snodec_add_component( + TARGET websocket-client + LIBRARY_DESTINATION ${HTTP_UPGRADE_INSTALL_LIBDIR} + PUBLIC_COMPONENT ) -install( +snodec_install_component_headers( + COMPONENT websocket-client DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${WEBSOCKET_INSTALL_INCLUDEDIR}/client - COMPONENT websocket-client - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE -) - -install( - EXPORT snodec_websocket-client_Targets - FILE snodec_websocket-client_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT websocket-client + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/web/websocket/server/CMakeLists.txt b/src/web/websocket/server/CMakeLists.txt index 7a376f570e..102a79db68 100644 --- a/src/web/websocket/server/CMakeLists.txt +++ b/src/web/websocket/server/CMakeLists.txt @@ -88,27 +88,18 @@ target_compile_options( target_link_libraries(websocket-server PUBLIC websocket http-server) -install( - TARGETS websocket-server - EXPORT snodec_websocket-server_Targets - LIBRARY DESTINATION ${HTTP_UPGRADE_INSTALL_LIBDIR} - COMPONENT websocket-server +snodec_add_component( + TARGET websocket-server + LIBRARY_DESTINATION ${HTTP_UPGRADE_INSTALL_LIBDIR} + PUBLIC_COMPONENT ) -install( +snodec_install_component_headers( + COMPONENT websocket-server DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${WEBSOCKET_INSTALL_INCLUDEDIR}/server - COMPONENT websocket-server - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "cmake" EXCLUDE -) - -install( - EXPORT snodec_websocket-server_Targets - FILE snodec_websocket-server_Targets.cmake - NAMESPACE snodec:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - COMPONENT websocket-server + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 100b81378c..89203603a0 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -59,3 +59,29 @@ set_tests_properties( StagedInstalledConsumerTest PROPERTIES LABELS "install;consumer" TIMEOUT 120 ) + +add_test( + NAME ComponentPackagingTest + COMMAND + ${CMAKE_COMMAND} -DSNODEC_BUILD_DIR=${CMAKE_BINARY_DIR} + -DSNODEC_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR} + -DSNODEC_INSTALL_INCLUDEDIR=${CMAKE_INSTALL_INCLUDEDIR} + -DSNODEC_SHARED_LIBRARY_PREFIX=${CMAKE_SHARED_LIBRARY_PREFIX} + -DSNODEC_SHARED_LIBRARY_SUFFIX=${CMAKE_SHARED_LIBRARY_SUFFIX} -P + ${CMAKE_CURRENT_SOURCE_DIR}/ComponentPackagingTest.cmake +) +set_tests_properties( + ComponentPackagingTest PROPERTIES LABELS "install;packaging" TIMEOUT 120 +) + +add_test( + NAME ComponentRegistryValidationTest + COMMAND + ${CMAKE_COMMAND} -DSNODEC_SOURCE_DIR=${CMAKE_SOURCE_DIR} + -DSNODEC_TEST_BINARY_DIR=${CMAKE_BINARY_DIR} -P + ${CMAKE_CURRENT_SOURCE_DIR}/ComponentRegistryValidationTest.cmake +) +set_tests_properties( + ComponentRegistryValidationTest + PROPERTIES LABELS "cmake;packaging" TIMEOUT 120 +) diff --git a/tests/ComponentPackagingTest.cmake b/tests/ComponentPackagingTest.cmake new file mode 100644 index 0000000000..b9488a7eeb --- /dev/null +++ b/tests/ComponentPackagingTest.cmake @@ -0,0 +1,224 @@ +# SNode.C - A Slim Toolkit for Network Communication +# Copyright (C) Volker Christian +# 2020, 2021, 2022, 2023, 2024, 2025, 2026 +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program. If not, see . +# +# --------------------------------------------------------------------------- +# +# MIT License +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +if(NOT SNODEC_BUILD_DIR) + message(FATAL_ERROR "SNODEC_BUILD_DIR is required") +endif() +if(NOT SNODEC_INSTALL_LIBDIR) + message(FATAL_ERROR "SNODEC_INSTALL_LIBDIR is required") +endif() +if(NOT SNODEC_INSTALL_INCLUDEDIR) + message(FATAL_ERROR "SNODEC_INSTALL_INCLUDEDIR is required") +endif() +if(NOT DEFINED SNODEC_SHARED_LIBRARY_PREFIX) + message(FATAL_ERROR "SNODEC_SHARED_LIBRARY_PREFIX is required") +endif() +if(NOT DEFINED SNODEC_SHARED_LIBRARY_SUFFIX) + message(FATAL_ERROR "SNODEC_SHARED_LIBRARY_SUFFIX is required") +endif() + +set(stage "${SNODEC_BUILD_DIR}/component-packaging-test") +set(runtime_prefix "${stage}/runtime") +set(development_prefix "${stage}/development") +file(REMOVE_RECURSE "${stage}") + +function(install_component component prefix) + execute_process( + COMMAND + "${CMAKE_COMMAND}" --install "${SNODEC_BUILD_DIR}" --prefix + "${prefix}" --component "${component}" + RESULT_VARIABLE install_result + OUTPUT_VARIABLE install_output + ERROR_VARIABLE install_error + ) + if(NOT install_result EQUAL 0) + message( + FATAL_ERROR + "installation of component '${component}' failed\n" + "${install_output}\n${install_error}" + ) + endif() +endfunction() + +install_component(core "${runtime_prefix}") + +set( + core_library_name + "${SNODEC_SHARED_LIBRARY_PREFIX}snodec-core${SNODEC_SHARED_LIBRARY_SUFFIX}" +) +set( + core_library + "${runtime_prefix}/${SNODEC_INSTALL_LIBDIR}/${core_library_name}" +) +if(EXISTS "${core_library}" OR IS_SYMLINK "${core_library}") + message(FATAL_ERROR "runtime component contains development namelink") +endif() +file( + GLOB versioned_core_libraries + LIST_DIRECTORIES FALSE + "${core_library}.*" +) +if(NOT versioned_core_libraries) + message(FATAL_ERROR "runtime component contains no versioned core library") +endif() +file( + GLOB_RECURSE runtime_headers + LIST_DIRECTORIES FALSE + "${runtime_prefix}/${SNODEC_INSTALL_INCLUDEDIR}/*" +) +if(runtime_headers) + message(FATAL_ERROR "runtime component contains headers: ${runtime_headers}") +endif() +file( + GLOB_RECURSE runtime_cmake_files + LIST_DIRECTORIES FALSE + "${runtime_prefix}/${SNODEC_INSTALL_LIBDIR}/cmake/*" +) +if(runtime_cmake_files) + message( + FATAL_ERROR + "runtime component contains CMake package files: ${runtime_cmake_files}" + ) +endif() + +install_component(core-dev "${development_prefix}") + +set( + development_core_library + "${development_prefix}/${SNODEC_INSTALL_LIBDIR}/${core_library_name}" +) +if(NOT EXISTS "${development_core_library}" + AND NOT IS_SYMLINK "${development_core_library}" +) + message(FATAL_ERROR "development component contains no core namelink") +endif() +file( + GLOB development_versioned_core_libraries + LIST_DIRECTORIES FALSE + "${development_core_library}.*" +) +if(development_versioned_core_libraries) + message( + FATAL_ERROR + "development component contains versioned runtime libraries: " + "${development_versioned_core_libraries}" + ) +endif() +if(NOT EXISTS + "${development_prefix}/${SNODEC_INSTALL_INCLUDEDIR}/snode.c/core/SNodeC.h" +) + message(FATAL_ERROR "development component contains no public core headers") +endif() +if(NOT EXISTS + "${development_prefix}/${SNODEC_INSTALL_LIBDIR}/cmake/snodec/snodecConfig.cmake" +) + message(FATAL_ERROR "development component contains no package config") +endif() +if(NOT EXISTS + "${development_prefix}/${SNODEC_INSTALL_LIBDIR}/cmake/snodec/snodec_core_Targets.cmake" +) + message(FATAL_ERROR "development component contains no core target export") +endif() + +include("${SNODEC_BUILD_DIR}/CPackConfig.cmake") +foreach( + expected_component + IN ITEMS core core-dev net-un-phy-stream net-un-phy-stream-dev +) + if(NOT expected_component IN_LIST CPACK_COMPONENTS_ALL) + message( + FATAL_ERROR + "generated CPack model misses component '${expected_component}'" + ) + endif() +endforeach() +foreach(removed_component IN ITEMS net-un-sphy-tream mqtt-fast) + if(removed_component IN_LIST CPACK_COMPONENTS_ALL) + message( + FATAL_ERROR + "generated CPack model contains invalid component '${removed_component}'" + ) + endif() +endforeach() + +set(core_runtime_dependencies_var "CPACK_COMPONENT_CORE_DEPENDS") +set(selected_multiplexer_components) +foreach(dependency IN LISTS ${core_runtime_dependencies_var}) + if(dependency MATCHES "^mux-") + list(APPEND selected_multiplexer_components "${dependency}") + endif() +endforeach() +list(LENGTH selected_multiplexer_components selected_multiplexer_count) +if(NOT selected_multiplexer_count EQUAL 1) + message( + FATAL_ERROR + "core must depend on exactly one multiplexer component: " + "${${core_runtime_dependencies_var}}" + ) +endif() +list(GET selected_multiplexer_components 0 selected_multiplexer_component) + +set(core_development_dependencies_var "CPACK_COMPONENT_CORE-DEV_DEPENDS") +foreach(expected_dependency IN ITEMS core utils-dev) + if(NOT expected_dependency IN_LIST ${core_development_dependencies_var}) + message( + FATAL_ERROR + "core-dev misses dependency '${expected_dependency}': " + "${${core_development_dependencies_var}}" + ) + endif() +endforeach() +set(selected_multiplexer_development "${selected_multiplexer_component}-dev") +if(selected_multiplexer_development IN_LIST + ${core_development_dependencies_var} +) + message( + FATAL_ERROR + "core-dev exposes private multiplexer dependency " + "'${selected_multiplexer_development}'" + ) +endif() + +if(NOT CPACK_PACKAGING_INSTALL_PREFIX STREQUAL "/usr") + message( + FATAL_ERROR + "binary packages use unexpected installation prefix " + "'${CPACK_PACKAGING_INSTALL_PREFIX}'" + ) +endif() diff --git a/tests/ComponentRegistryValidationTest.cmake b/tests/ComponentRegistryValidationTest.cmake new file mode 100644 index 0000000000..25bf05dbd3 --- /dev/null +++ b/tests/ComponentRegistryValidationTest.cmake @@ -0,0 +1,192 @@ +# SNode.C - A Slim Toolkit for Network Communication +# Copyright (C) Volker Christian +# 2026 +# +# This file may be used under the terms of the GNU Lesser General Public +# License version 3 or later, or under the MIT License. + +cmake_minimum_required(VERSION 3.18) + +if(NOT DEFINED SNODEC_SOURCE_DIR) + message(FATAL_ERROR "SNODEC_SOURCE_DIR is required") +endif() +if(NOT DEFINED SNODEC_TEST_BINARY_DIR) + message(FATAL_ERROR "SNODEC_TEST_BINARY_DIR is required") +endif() + + +# Production components must use the central registration API. Raw install() +# rules in src/ would bypass the runtime/development split, and CPack metadata +# must never be reconstructed in the global packaging policy file. +file(GLOB_RECURSE component_cmake_files "${SNODEC_SOURCE_DIR}/src/*/CMakeLists.txt") +foreach(component_cmake_file IN LISTS component_cmake_files) + file(READ "${component_cmake_file}" component_cmake_source) + if(component_cmake_source MATCHES "(^|\n)[ \t]*install[ \t]*[(]") + message( + FATAL_ERROR + "Raw install() rule found in '${component_cmake_file}'; use the SNode.C component helpers" + ) + endif() + if(component_cmake_source MATCHES "cpack_add_component[ \t]*[(]") + message( + FATAL_ERROR + "Local CPack call found in '${component_cmake_file}'; component helpers own CPack registration" + ) + endif() +endforeach() +file(READ "${SNODEC_SOURCE_DIR}/cmake/Packing.cmake" packing_source) +if(packing_source MATCHES "cpack_add_component[ \t]*[(]") + message( + FATAL_ERROR + "Packing.cmake must contain policy only; components register in their own CMakeLists.txt files" + ) +endif() + +set(stage "${SNODEC_TEST_BINARY_DIR}/component-registry-validation") +file(REMOVE_RECURSE "${stage}") +file(MAKE_DIRECTORY "${stage}") + +function(run_registry_case case_name case_body expected_result expected_message) + set(source_dir "${stage}/${case_name}") + set(binary_dir "${source_dir}/build") + file(MAKE_DIRECTORY "${source_dir}") + file(WRITE "${source_dir}/component.cpp" "int component_value() { return 1; }\n") + file( + WRITE "${source_dir}/component.h" + "int component_value();\n" + ) + file( + WRITE "${source_dir}/CMakeLists.txt" + "cmake_minimum_required(VERSION 3.18)\n" + "project(${case_name} VERSION 1.0.0 LANGUAGES CXX)\n" + "list(APPEND CMAKE_MODULE_PATH \"${SNODEC_SOURCE_DIR}/cmake\")\n" + "include(SNodeCComponent)\n" + "${case_body}\n" + ) + + execute_process( + COMMAND "${CMAKE_COMMAND}" -S "${source_dir}" -B "${binary_dir}" + RESULT_VARIABLE configure_result + OUTPUT_VARIABLE configure_output + ERROR_VARIABLE configure_error + ) + set(configure_log "${configure_output}\n${configure_error}") + + if(expected_result STREQUAL "SUCCESS") + if(NOT configure_result EQUAL 0) + message( + FATAL_ERROR + "Registry case '${case_name}' unexpectedly failed:\n${configure_log}" + ) + endif() + elseif(expected_result STREQUAL "FAILURE") + if(configure_result EQUAL 0) + message( + FATAL_ERROR + "Registry case '${case_name}' unexpectedly succeeded" + ) + endif() + string(FIND "${configure_log}" "${expected_message}" message_position) + if(message_position EQUAL -1) + message( + FATAL_ERROR + "Registry case '${case_name}' did not report '${expected_message}':\n${configure_log}" + ) + endif() + else() + message(FATAL_ERROR "Unknown expected result '${expected_result}'") + endif() +endfunction() + +set(valid_case [=[ +add_library(a SHARED component.cpp) +snodec_add_component(TARGET a) +snodec_install_component_headers( + COMPONENT a FILES component.h DESTINATION include +) +snodec_finalize_cpack_components() +]=]) +run_registry_case(valid "${valid_case}" SUCCESS "") + +set(duplicate_case [=[ +add_library(a SHARED component.cpp) +add_library(b SHARED component.cpp) +snodec_add_component(TARGET a COMPONENT duplicate) +snodec_install_component_headers( + COMPONENT duplicate FILES component.h DESTINATION include +) +snodec_add_component(TARGET b COMPONENT duplicate) +]=]) +run_registry_case( + duplicate + "${duplicate_case}" + FAILURE + "SNode.C component 'duplicate' is registered twice" +) + +set(missing_case [=[ +add_library(a SHARED component.cpp) +snodec_add_component(TARGET a DEPENDS missing) +snodec_install_component_headers( + COMPONENT a FILES component.h DESTINATION include +) +snodec_finalize_cpack_components() +]=]) +run_registry_case( + missing + "${missing_case}" + FAILURE + "SNode.C component 'a' depends on unregistered component 'missing'" +) + +set(runtime_cycle_case [=[ +add_library(a SHARED component.cpp) +add_library(b SHARED component.cpp) +snodec_add_component(TARGET a DEPENDS b) +snodec_install_component_headers( + COMPONENT a FILES component.h DESTINATION include +) +snodec_add_component(TARGET b DEPENDS a) +snodec_install_component_headers( + COMPONENT b FILES component.h DESTINATION include +) +snodec_finalize_cpack_components() +]=]) +run_registry_case( + runtime-cycle + "${runtime_cycle_case}" + FAILURE + "Cyclic SNode.C runtime component dependency: a -> b -> a" +) + +set(development_cycle_case [=[ +add_library(a SHARED component.cpp) +add_library(b SHARED component.cpp) +snodec_add_component(TARGET a DEVELOPMENT_DEPENDS b) +snodec_install_component_headers( + COMPONENT a FILES component.h DESTINATION include +) +snodec_add_component(TARGET b DEVELOPMENT_DEPENDS a) +snodec_install_component_headers( + COMPONENT b FILES component.h DESTINATION include +) +snodec_finalize_cpack_components() +]=]) +run_registry_case( + development-cycle + "${development_cycle_case}" + FAILURE + "Cyclic SNode.C development component dependency: a -> b -> a" +) + + +set(missing_value_case [=[ +add_library(a SHARED component.cpp) +snodec_add_component(TARGET) +]=]) +run_registry_case( + missing-value + "${missing_value_case}" + FAILURE + "snodec_add_component is missing values for: TARGET" +) From 81706686c3a0b826e38e785a4f8c4fa58e6c62bc Mon Sep 17 00:00:00 2001 From: Volker Christian Date: Thu, 30 Jul 2026 19:26:07 +0200 Subject: [PATCH 2/7] Fix packaging test install directory inputs --- tests/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 89203603a0..8cfdbc8adb 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -52,6 +52,8 @@ add_test( NAME StagedInstalledConsumerTest COMMAND ${CMAKE_COMMAND} -DSNODEC_BUILD_DIR=${CMAKE_BINARY_DIR} + -DSNODEC_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR} + -DSNODEC_INSTALL_INCLUDEDIR=${CMAKE_INSTALL_INCLUDEDIR} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -P ${CMAKE_CURRENT_SOURCE_DIR}/StagedInstalledConsumerTest.cmake ) From d3a0fe84cf68a43337dcb9fbf2dc4ad15d3077d6 Mon Sep 17 00:00:00 2001 From: Volker Christian Date: Thu, 30 Jul 2026 19:26:43 +0200 Subject: [PATCH 3/7] Honor GNU install directories in consumer test --- tests/StagedInstalledConsumerTest.cmake | 73 +++++++++++++++++-------- 1 file changed, 49 insertions(+), 24 deletions(-) diff --git a/tests/StagedInstalledConsumerTest.cmake b/tests/StagedInstalledConsumerTest.cmake index 503d9102e1..d510ceb64d 100644 --- a/tests/StagedInstalledConsumerTest.cmake +++ b/tests/StagedInstalledConsumerTest.cmake @@ -1,6 +1,19 @@ +if(NOT SNODEC_BUILD_DIR) + message(FATAL_ERROR "SNODEC_BUILD_DIR is required") +endif() +if(NOT SNODEC_INSTALL_LIBDIR) + message(FATAL_ERROR "SNODEC_INSTALL_LIBDIR is required") +endif() +if(NOT SNODEC_INSTALL_INCLUDEDIR) + message(FATAL_ERROR "SNODEC_INSTALL_INCLUDEDIR is required") +endif() + set(stage "${SNODEC_BUILD_DIR}/staged-installed-consumer") set(prefix "${stage}/prefix") set(consumer "${stage}/consumer.cpp") +set(include_directory "${prefix}/${SNODEC_INSTALL_INCLUDEDIR}/snode.c") +set(library_directory "${prefix}/${SNODEC_INSTALL_LIBDIR}") +set(http_library_directory "${library_directory}/snode.c/web/http") file(REMOVE_RECURSE "${stage}") file(MAKE_DIRECTORY "${stage}") @@ -21,7 +34,7 @@ foreach(private_header IN ITEMS core/EventLoop.h core/EventMultiplexer.h core/DescriptorEventPublisher.h core/TimerEventPublisher.h ) - if(EXISTS "${prefix}/include/snode.c/${private_header}") + if(EXISTS "${include_directory}/${private_header}") message(FATAL_ERROR "private header installed: ${private_header}") endif() endforeach() @@ -31,26 +44,41 @@ file( "#include \n#include \n#include \n#include \n#include \nint main() { return 0; }\n" ) set(exe "${stage}/consumer") +set( + consumer_compile_command + "${CMAKE_CXX_COMPILER}" + -std=c++20 + "${consumer}" + "-I${include_directory}" + "-L${library_directory}" + "-L${http_library_directory}" + "-Wl,-rpath,${library_directory}" + "-Wl,-rpath,${http_library_directory}" + -lsnodec-core + -lsnodec-core-socket + -lsnodec-core-socket-stream + -lsnodec-net + -lsnodec-net-in + -lsnodec-net-in-phy + -lsnodec-net-in-phy-stream + -lsnodec-net-in-stream + -lsnodec-core-socket-stream-legacy + -lsnodec-net-in-stream-legacy + -lsnodec-http + -lsnodec-http-server + -lsnodec-http-server-express + -lsnodec-http-server-express-legacy-in + -o + "${exe}" +) execute_process( - COMMAND - "${CMAKE_CXX_COMPILER}" -std=c++20 "${consumer}" - "-I${prefix}/include/snode.c" "-L${prefix}/lib" - "-L${prefix}/lib/snode.c/web/http" "-Wl,-rpath,${prefix}/lib" - "-Wl,-rpath,${prefix}/lib/snode.c/web/http" -lsnodec-core - -lsnodec-core-socket -lsnodec-core-socket-stream -lsnodec-net - -lsnodec-net-in -lsnodec-net-in-phy -lsnodec-net-in-phy-stream - -lsnodec-net-in-stream -lsnodec-core-socket-stream-legacy - -lsnodec-net-in-stream-legacy -lsnodec-http -lsnodec-http-server - -lsnodec-http-server-express -lsnodec-http-server-express-legacy-in -o - "${exe}" + COMMAND ${consumer_compile_command} RESULT_VARIABLE compile_result OUTPUT_VARIABLE compile_output ERROR_VARIABLE compile_error ) -message( - STATUS - "Installed consumer compile command: ${CMAKE_CXX_COMPILER} -std=c++20 ${consumer} -I${prefix}/include/snode.c -L${prefix}/lib -L${prefix}/lib/snode.c/web/http -Wl,-rpath,${prefix}/lib -Wl,-rpath,${prefix}/lib/snode.c/web/http -lsnodec-core -lsnodec-core-socket -lsnodec-core-socket-stream -lsnodec-net -lsnodec-net-in -lsnodec-net-in-phy -lsnodec-net-in-phy-stream -lsnodec-net-in-stream -lsnodec-core-socket-stream-legacy -lsnodec-net-in-stream-legacy -lsnodec-http -lsnodec-http-server -lsnodec-http-server-express -lsnodec-http-server-express-legacy-in -o ${exe}" -) +string(JOIN " " consumer_compile_command_text ${consumer_compile_command}) +message(STATUS "Installed consumer compile command: ${consumer_compile_command_text}") if(NOT compile_result EQUAL 0) message( FATAL_ERROR @@ -70,19 +98,16 @@ if(NOT run_result EQUAL 0) ) endif() -file( - GLOB snodec_config_files - LIST_DIRECTORIES FALSE - "${prefix}/lib*/cmake/snodec/snodecConfig.cmake" +set( + snodec_config_file + "${library_directory}/cmake/snodec/snodecConfig.cmake" ) -list(LENGTH snodec_config_files snodec_config_file_count) -if(NOT snodec_config_file_count EQUAL 1) +if(NOT EXISTS "${snodec_config_file}") message( FATAL_ERROR - "expected one installed snodecConfig.cmake, found ${snodec_config_file_count}: ${snodec_config_files}" + "installed snodecConfig.cmake not found: ${snodec_config_file}" ) endif() -list(GET snodec_config_files 0 snodec_config_file) get_filename_component(snodec_config_dir "${snodec_config_file}" DIRECTORY) set(generic_consumer_source "${stage}/generic-cmake-consumer") From 956f9a6cc223597b43bb81a4129e7e3879bbcc46 Mon Sep 17 00:00:00 2001 From: Volker Christian Date: Thu, 30 Jul 2026 19:27:24 +0200 Subject: [PATCH 4/7] Make packaging test policy-independent --- tests/ComponentPackagingTest.cmake | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/tests/ComponentPackagingTest.cmake b/tests/ComponentPackagingTest.cmake index b9488a7eeb..1fc65a227e 100644 --- a/tests/ComponentPackagingTest.cmake +++ b/tests/ComponentPackagingTest.cmake @@ -161,7 +161,8 @@ foreach( expected_component IN ITEMS core core-dev net-un-phy-stream net-un-phy-stream-dev ) - if(NOT expected_component IN_LIST CPACK_COMPONENTS_ALL) + list(FIND CPACK_COMPONENTS_ALL "${expected_component}" component_index) + if(component_index EQUAL -1) message( FATAL_ERROR "generated CPack model misses component '${expected_component}'" @@ -169,7 +170,8 @@ foreach( endif() endforeach() foreach(removed_component IN ITEMS net-un-sphy-tream mqtt-fast) - if(removed_component IN_LIST CPACK_COMPONENTS_ALL) + list(FIND CPACK_COMPONENTS_ALL "${removed_component}" component_index) + if(NOT component_index EQUAL -1) message( FATAL_ERROR "generated CPack model contains invalid component '${removed_component}'" @@ -196,7 +198,11 @@ list(GET selected_multiplexer_components 0 selected_multiplexer_component) set(core_development_dependencies_var "CPACK_COMPONENT_CORE-DEV_DEPENDS") foreach(expected_dependency IN ITEMS core utils-dev) - if(NOT expected_dependency IN_LIST ${core_development_dependencies_var}) + list( + FIND ${core_development_dependencies_var} "${expected_dependency}" + dependency_index + ) + if(dependency_index EQUAL -1) message( FATAL_ERROR "core-dev misses dependency '${expected_dependency}': " @@ -205,9 +211,11 @@ foreach(expected_dependency IN ITEMS core utils-dev) endif() endforeach() set(selected_multiplexer_development "${selected_multiplexer_component}-dev") -if(selected_multiplexer_development IN_LIST - ${core_development_dependencies_var} +list( + FIND ${core_development_dependencies_var} + "${selected_multiplexer_development}" dependency_index ) +if(NOT dependency_index EQUAL -1) message( FATAL_ERROR "core-dev exposes private multiplexer dependency " From 80db2e753de2806d18d497407b66efb1fb30de04 Mon Sep 17 00:00:00 2001 From: Volker Christian Date: Thu, 30 Jul 2026 19:46:47 +0200 Subject: [PATCH 5/7] Match component packages by exact Debian name --- cmake/ValidateComponentPackages.cmake | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/cmake/ValidateComponentPackages.cmake b/cmake/ValidateComponentPackages.cmake index e5406c7a46..3258900407 100644 --- a/cmake/ValidateComponentPackages.cmake +++ b/cmake/ValidateComponentPackages.cmake @@ -52,10 +52,21 @@ foreach(deb_package IN LISTS deb_packages) set("DEB_PACKAGE_FILE_${package_key}" "${deb_package}") endforeach() +function(component_package_name component result) + if(DEFINED CPACK_DEBIAN_PACKAGE_NAME AND CPACK_DEBIAN_PACKAGE_NAME) + set(package_base_name "${CPACK_DEBIAN_PACKAGE_NAME}") + else() + set(package_base_name "${CPACK_PACKAGE_NAME}") + endif() + string(TOLOWER "${package_base_name}-${component}" package_name) + set(${result} "${package_name}" PARENT_SCOPE) +endfunction() + function(find_component_package component result_name result_file) + component_package_name("${component}" expected_package_name) set(matches) foreach(package_name IN LISTS component_package_names) - if(package_name MATCHES "-${component}$") + if(package_name STREQUAL expected_package_name) list(APPEND matches "${package_name}") endif() endforeach() @@ -64,7 +75,7 @@ function(find_component_package component result_name result_file) if(NOT match_count EQUAL 1) message( FATAL_ERROR - "Expected exactly one Debian package for component '${component}', found: ${matches}" + "Expected exactly one Debian package '${expected_package_name}' for component '${component}', found: ${matches}" ) endif() @@ -75,8 +86,9 @@ function(find_component_package component result_name result_file) endfunction() function(assert_no_component_package component) + component_package_name("${component}" unexpected_package_name) foreach(package_name IN LISTS component_package_names) - if(package_name MATCHES "-${component}$") + if(package_name STREQUAL unexpected_package_name) message( FATAL_ERROR "Unexpected Debian package '${package_name}' for component '${component}'" From e281cdac5303d336b9befe657475d64c49fa6b2f Mon Sep 17 00:00:00 2001 From: Volker Christian Date: Thu, 30 Jul 2026 21:32:09 +0200 Subject: [PATCH 6/7] Unify component declarations and finalization --- .cmake-format.py | 19 +- cmake/Packing.cmake | 6 +- cmake/SNodeCComponent.cmake | 831 +++++++++++++++---- src/CMakeLists.txt | 34 +- src/core/CMakeLists.txt | 38 +- src/core/socket/CMakeLists.txt | 22 +- src/core/socket/stream/CMakeLists.txt | 24 +- src/core/socket/stream/legacy/CMakeLists.txt | 16 +- src/core/socket/stream/tls/CMakeLists.txt | 20 +- src/database/mariadb/CMakeLists.txt | 16 +- src/express/CMakeLists.txt | 16 +- src/express/legacy/in/CMakeLists.txt | 16 +- src/express/legacy/in6/CMakeLists.txt | 16 +- src/express/legacy/rc/CMakeLists.txt | 16 +- src/express/legacy/un/CMakeLists.txt | 16 +- src/express/tls/in/CMakeLists.txt | 16 +- src/express/tls/in6/CMakeLists.txt | 16 +- src/express/tls/rc/CMakeLists.txt | 16 +- src/express/tls/un/CMakeLists.txt | 16 +- src/iot/mqtt/CMakeLists.txt | 42 +- src/iot/mqtt/client/CMakeLists.txt | 24 +- src/iot/mqtt/client/packets/CMakeLists.txt | 10 - src/iot/mqtt/packets/CMakeLists.txt | 10 - src/iot/mqtt/server/CMakeLists.txt | 38 +- src/iot/mqtt/server/broker/CMakeLists.txt | 10 - src/iot/mqtt/server/packets/CMakeLists.txt | 10 - src/iot/mqtt/types/CMakeLists.txt | 10 - src/log/CMakeLists.txt | 16 +- src/net/CMakeLists.txt | 28 +- src/net/in/CMakeLists.txt | 24 +- src/net/in/phy/CMakeLists.txt | 22 +- src/net/in/phy/stream/CMakeLists.txt | 22 +- src/net/in/stream/CMakeLists.txt | 22 +- src/net/in/stream/legacy/CMakeLists.txt | 16 +- src/net/in/stream/tls/CMakeLists.txt | 16 +- src/net/in6/CMakeLists.txt | 24 +- src/net/in6/phy/CMakeLists.txt | 22 +- src/net/in6/phy/stream/CMakeLists.txt | 22 +- src/net/in6/stream/CMakeLists.txt | 22 +- src/net/in6/stream/legacy/CMakeLists.txt | 16 +- src/net/in6/stream/tls/CMakeLists.txt | 16 +- src/net/l2/CMakeLists.txt | 24 +- src/net/l2/phy/CMakeLists.txt | 22 +- src/net/l2/phy/stream/CMakeLists.txt | 22 +- src/net/l2/stream/CMakeLists.txt | 22 +- src/net/l2/stream/legacy/CMakeLists.txt | 16 +- src/net/l2/stream/tls/CMakeLists.txt | 16 +- src/net/rc/CMakeLists.txt | 24 +- src/net/rc/phy/CMakeLists.txt | 22 +- src/net/rc/phy/stream/CMakeLists.txt | 22 +- src/net/rc/stream/CMakeLists.txt | 22 +- src/net/rc/stream/legacy/CMakeLists.txt | 16 +- src/net/rc/stream/tls/CMakeLists.txt | 16 +- src/net/un/CMakeLists.txt | 24 +- src/net/un/dgram/CMakeLists.txt | 16 +- src/net/un/phy/CMakeLists.txt | 22 +- src/net/un/phy/stream/CMakeLists.txt | 22 +- src/net/un/stream/CMakeLists.txt | 22 +- src/net/un/stream/legacy/CMakeLists.txt | 16 +- src/net/un/stream/tls/CMakeLists.txt | 16 +- src/utils/CMakeLists.txt | 16 +- src/web/http/CMakeLists.txt | 36 +- src/web/http/client/CMakeLists.txt | 44 +- src/web/http/server/CMakeLists.txt | 40 +- src/web/websocket/CMakeLists.txt | 34 +- src/web/websocket/client/CMakeLists.txt | 16 +- src/web/websocket/server/CMakeLists.txt | 16 +- tests/ComponentRegistryValidationTest.cmake | 120 ++- 68 files changed, 1361 insertions(+), 955 deletions(-) diff --git a/.cmake-format.py b/.cmake-format.py index dfa91bffa2..c7f291d620 100644 --- a/.cmake-format.py +++ b/.cmake-format.py @@ -5,18 +5,21 @@ # Specify structure for custom cmake functions additional_commands = { - 'snodec_install_component_development_files': { - 'kwargs': {'COMPONENT': 1, 'DESTINATION': 1, 'FILES': '*'}}, - 'snodec_install_component_headers': { - 'kwargs': {'COMPONENT': 1, 'DESTINATION': 1, 'DIRECTORY': 1, - 'EXCLUDE_PATTERNS': '*', 'FILES': '*', 'PATTERNS': '*'}}, 'snodec_add_component': { 'flags': ['PUBLIC_COMPONENT'], 'kwargs': {'ARCHIVE_DESTINATION': 1, 'COMPONENT': 1, 'DEPENDS': '*', 'DESCRIPTION': 1, 'DEVELOPMENT_DEPENDS': '*', - 'DISPLAY_NAME': 1, 'EXPORT_DESTINATION': 1, - 'LIBRARY_DESTINATION': 1, 'RUNTIME_DESTINATION': 1, - 'TARGET': 1}}, + 'DEVELOPMENT_FILES': '*', 'DIRECTORY': 1, + 'DISPLAY_NAME': 1, 'EXCLUDE_PATTERNS': '*', + 'EXPORT_DESTINATION': 1, 'FILES': '*', 'HEADERS': '*', + 'LIBRARY_DESTINATION': 1, 'PATTERNS': '*', + 'RUNTIME_DESTINATION': 1, 'TARGET': 1}}, + 'snodec_finalize_components': { + 'kwargs': {'PACKAGE_CONFIG_COMPONENT': 1, + 'PACKAGE_CONFIG_DESTINATION': 1, + 'PACKAGE_CONFIG_OUTPUT': 1, + 'PACKAGE_CONFIG_TEMPLATE': 1, + 'PACKAGE_VERSION': 1, 'PACKAGE_VERSION_OUTPUT': 1}}, 'snodec_install_runtime_targets': { 'kwargs': {'COMPONENT': 1, 'LIBRARY_DESTINATION': 1, 'RUNTIME_DESTINATION': 1, 'TARGETS': '*'}}, diff --git a/cmake/Packing.cmake b/cmake/Packing.cmake index 4b5d159575..8a721f180e 100644 --- a/cmake/Packing.cmake +++ b/cmake/Packing.cmake @@ -102,9 +102,9 @@ set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT) set(CPACK_COMPONENTS_GROUPING IGNORE) set(CPACK_DEB_COMPONENT_INSTALL YES) -# Component ownership and dependency metadata are registered next to the -# corresponding targets. This final step only validates and materializes that -# distributed component model for CPack. +# The package-format-neutral component registry is already finalized. This +# adapter maps its runtime/development components and dependencies to CPack; +# other packaging systems can consume the same registry independently. snodec_finalize_cpack_components() include(CPack) diff --git a/cmake/SNodeCComponent.cmake b/cmake/SNodeCComponent.cmake index 503ab5becf..d850ebf177 100644 --- a/cmake/SNodeCComponent.cmake +++ b/cmake/SNodeCComponent.cmake @@ -40,12 +40,14 @@ include_guard(GLOBAL) include(CMakeParseArguments) +include(CMakePackageConfigHelpers) include(CPackComponent) include(GNUInstallDirs) -# Every component is declared where its target is declared. These helpers own -# the runtime/development split, CMake exports, CPack metadata, package -# dependencies, and the public find_package() component registry. +# Every component is declared where its target is declared. The registry is +# package-format neutral: generic finalization owns install/export generation +# and resolved dependencies, while adapters such as CPack -- and a future +# OpenWrt package generator -- consume the same finalized metadata. function(_snodec_component_key component result) string(MAKE_C_IDENTIFIER "${component}" component_key) @@ -237,6 +239,9 @@ function(_snodec_register_component) _snodec_set_component_property( "${ARG_COMPONENT}" RUNTIME_ONLY "${ARG_RUNTIME_ONLY}" ) + _snodec_set_component_property( + "${ARG_COMPONENT}" PUBLIC "${ARG_PUBLIC}" + ) _snodec_set_component_property( "${ARG_COMPONENT}" EXPLICIT_RUNTIME_DEPENDS ${ARG_DEPENDS} ) @@ -496,7 +501,169 @@ function(_snodec_component_dependencies component dependency_kind result) set(${result} "${component_dependencies}" PARENT_SCOPE) endfunction() +function(_snodec_require_not_finalized command_name) + get_property( + components_finalized GLOBAL PROPERTY SNODEC_COMPONENTS_FINALIZED + ) + if(components_finalized) + message( + FATAL_ERROR + "${command_name} cannot modify the SNode.C component registry " + "after snodec_finalize_components()" + ) + endif() +endfunction() + +function(_snodec_require_finalized command_name) + get_property( + components_finalized GLOBAL PROPERTY SNODEC_COMPONENTS_FINALIZED + ) + if(NOT components_finalized) + message( + FATAL_ERROR + "${command_name} requires snodec_finalize_components() first" + ) + endif() +endfunction() + +function(_snodec_absolute_source_path source_path result) + if(IS_ABSOLUTE "${source_path}") + set(absolute_path "${source_path}") + else() + get_filename_component( + absolute_path "${source_path}" ABSOLUTE + BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" + ) + endif() + set(${result} "${absolute_path}" PARENT_SCOPE) +endfunction() + +function(_snodec_record_development_set component set_kind set_index) + set(options) + set(one_value_arguments DIRECTORY DESTINATION) + set(multi_value_arguments FILES PATTERNS EXCLUDE_PATTERNS) + cmake_parse_arguments( + SET "${options}" "${one_value_arguments}" "${multi_value_arguments}" + ${ARGN} + ) + _snodec_validate_arguments(SET "snodec_add_component ${set_kind}") + + if(NOT SET_DESTINATION) + message( + FATAL_ERROR + "${set_kind} DESTINATION is required for component '${component}'" + ) + endif() + if(SET_DIRECTORY AND SET_FILES) + message( + FATAL_ERROR + "${set_kind} for component '${component}' must use either DIRECTORY or FILES" + ) + endif() + if(NOT SET_DIRECTORY AND NOT SET_FILES) + message( + FATAL_ERROR + "${set_kind} for component '${component}' requires DIRECTORY or FILES" + ) + endif() + if(SET_FILES AND (SET_PATTERNS OR SET_EXCLUDE_PATTERNS)) + message( + FATAL_ERROR + "${set_kind} PATTERNS are only valid with DIRECTORY for component '${component}'" + ) + endif() + + if(SET_DIRECTORY) + _snodec_absolute_source_path("${SET_DIRECTORY}" source_directory) + string(REGEX REPLACE "/+$" "" source_directory "${source_directory}") + endif() + + set(source_files) + foreach(source_file IN LISTS SET_FILES) + _snodec_absolute_source_path("${source_file}" absolute_source_file) + list(APPEND source_files "${absolute_source_file}") + endforeach() + + _snodec_set_component_property( + "${component}" "${set_kind}_${set_index}_DIRECTORY" + "${source_directory}" + ) + _snodec_set_component_property( + "${component}" "${set_kind}_${set_index}_FILES" ${source_files} + ) + _snodec_set_component_property( + "${component}" "${set_kind}_${set_index}_DESTINATION" + "${SET_DESTINATION}" + ) + _snodec_set_component_property( + "${component}" "${set_kind}_${set_index}_PATTERNS" ${SET_PATTERNS} + ) + _snodec_set_component_property( + "${component}" "${set_kind}_${set_index}_EXCLUDE_PATTERNS" + ${SET_EXCLUDE_PATTERNS} + ) +endfunction() + +function(_snodec_append_development_files component destination) + set(source_files) + foreach(source_file IN LISTS ARGN) + _snodec_absolute_source_path("${source_file}" absolute_source_file) + list(APPEND source_files "${absolute_source_file}") + endforeach() + + _snodec_component_property( + "${component}" DEVELOPMENT_FILES_COUNT development_files_count + ) + if(NOT development_files_count) + set(development_files_count 0) + endif() + math(EXPR development_files_count "${development_files_count} + 1") + _snodec_set_component_property( + "${component}" DEVELOPMENT_FILES_COUNT "${development_files_count}" + ) + _snodec_record_development_set( + "${component}" DEVELOPMENT_FILES "${development_files_count}" + FILES ${source_files} + DESTINATION "${destination}" + ) +endfunction() + +# Declare one shared-library component, including all public headers and other +# development artifacts. HEADERS and DEVELOPMENT_FILES are repeatable sections; +# each section accepts FILES or DIRECTORY, DESTINATION, and (for DIRECTORY) +# PATTERNS/EXCLUDE_PATTERNS. No install rules are emitted until finalization. function(snodec_add_component) + _snodec_require_not_finalized("snodec_add_component") + + # Core component metadata precedes optional repeated HEADERS and + # DEVELOPMENT_FILES sections. Keeping all installable development content + # in this declaration gives CPack, CMake package exports, and future + # packaging adapters (notably OpenWrt) one canonical component model. + set(core_arguments) + set(current_section CORE) + set(header_set_count 0) + set(development_files_count 0) + foreach(argument IN LISTS ARGN) + if(argument STREQUAL "HEADERS") + set(current_section HEADERS) + math(EXPR header_set_count "${header_set_count} + 1") + elseif(argument STREQUAL "DEVELOPMENT_FILES") + set(current_section DEVELOPMENT_FILES) + math(EXPR development_files_count "${development_files_count} + 1") + elseif(current_section STREQUAL "CORE") + list(APPEND core_arguments "${argument}") + elseif(current_section STREQUAL "HEADERS") + list( + APPEND header_set_${header_set_count}_arguments "${argument}" + ) + else() + list( + APPEND development_files_${development_files_count}_arguments + "${argument}" + ) + endif() + endforeach() + set(options PUBLIC_COMPONENT) set( one_value_arguments @@ -512,7 +679,7 @@ function(snodec_add_component) set(multi_value_arguments DEPENDS DEVELOPMENT_DEPENDS) cmake_parse_arguments( ARG "${options}" "${one_value_arguments}" "${multi_value_arguments}" - ${ARGN} + ${core_arguments} ) _snodec_validate_arguments(ARG "snodec_add_component") @@ -574,133 +741,55 @@ function(snodec_add_component) endif() _snodec_register_component(${register_arguments}) - set(development_component "${ARG_COMPONENT}-dev") - set(export_set "snodec_${ARG_COMPONENT}_Targets") - _snodec_record_install_component("${ARG_COMPONENT}") - _snodec_record_install_component("${development_component}") - - install( - TARGETS "${real_target}" - EXPORT "${export_set}" - RUNTIME DESTINATION "${ARG_RUNTIME_DESTINATION}" - COMPONENT "${ARG_COMPONENT}" - LIBRARY DESTINATION "${ARG_LIBRARY_DESTINATION}" - COMPONENT "${ARG_COMPONENT}" - NAMELINK_COMPONENT "${development_component}" - ARCHIVE DESTINATION "${ARG_ARCHIVE_DESTINATION}" - COMPONENT "${development_component}" - BUNDLE DESTINATION "${ARG_RUNTIME_DESTINATION}" - COMPONENT "${ARG_COMPONENT}" + _snodec_set_component_property( + "${ARG_COMPONENT}" DECLARATION_SOURCE_DIR + "${CMAKE_CURRENT_SOURCE_DIR}" ) - - install( - EXPORT "${export_set}" - FILE "${export_set}.cmake" - NAMESPACE snodec:: - DESTINATION "${ARG_EXPORT_DESTINATION}" - COMPONENT "${development_component}" + _snodec_set_component_property( + "${ARG_COMPONENT}" RUNTIME_DESTINATION "${ARG_RUNTIME_DESTINATION}" ) -endfunction() - -function(snodec_install_component_headers) - set(options) - set(one_value_arguments COMPONENT DIRECTORY DESTINATION) - set(multi_value_arguments FILES PATTERNS EXCLUDE_PATTERNS) - cmake_parse_arguments( - ARG "${options}" "${one_value_arguments}" "${multi_value_arguments}" - ${ARGN} + _snodec_set_component_property( + "${ARG_COMPONENT}" LIBRARY_DESTINATION "${ARG_LIBRARY_DESTINATION}" ) - _snodec_validate_arguments(ARG "snodec_install_component_headers") - - if(NOT ARG_COMPONENT) - message(FATAL_ERROR "COMPONENT is required") - endif() - if(ARG_COMPONENT MATCHES "-dev$") - message( - FATAL_ERROR - "Use the base component name, not '${ARG_COMPONENT}', for development files" - ) - endif() - if(NOT ARG_DESTINATION) - message( - FATAL_ERROR - "DESTINATION is required for component '${ARG_COMPONENT}'" - ) - endif() - if(ARG_DIRECTORY AND ARG_FILES) - message( - FATAL_ERROR - "Use either DIRECTORY or FILES for component '${ARG_COMPONENT}'" - ) - endif() - if(NOT ARG_DIRECTORY AND NOT ARG_FILES) - message( - FATAL_ERROR - "DIRECTORY or FILES is required for component '${ARG_COMPONENT}'" - ) - endif() - - set(development_component "${ARG_COMPONENT}-dev") - _snodec_record_install_component("${development_component}") - - if(ARG_FILES) - install( - FILES ${ARG_FILES} - DESTINATION "${ARG_DESTINATION}" - COMPONENT "${development_component}" - ) - return() - endif() - - set(source_directory "${ARG_DIRECTORY}") - string(REGEX REPLACE "/+$" "" source_directory "${source_directory}") - - set(pattern_arguments) - if(ARG_PATTERNS OR ARG_EXCLUDE_PATTERNS) - list(APPEND pattern_arguments FILES_MATCHING) - endif() - foreach(pattern IN LISTS ARG_PATTERNS) - list(APPEND pattern_arguments PATTERN "${pattern}") - endforeach() - foreach(pattern IN LISTS ARG_EXCLUDE_PATTERNS) - list(APPEND pattern_arguments PATTERN "${pattern}" EXCLUDE) - endforeach() - - install( - DIRECTORY "${source_directory}/" - DESTINATION "${ARG_DESTINATION}" - COMPONENT "${development_component}" - ${pattern_arguments} + _snodec_set_component_property( + "${ARG_COMPONENT}" ARCHIVE_DESTINATION "${ARG_ARCHIVE_DESTINATION}" ) -endfunction() - -function(snodec_install_component_development_files) - set(options) - set(one_value_arguments COMPONENT DESTINATION) - set(multi_value_arguments FILES) - cmake_parse_arguments( - ARG "${options}" "${one_value_arguments}" "${multi_value_arguments}" - ${ARGN} + _snodec_set_component_property( + "${ARG_COMPONENT}" EXPORT_DESTINATION "${ARG_EXPORT_DESTINATION}" + ) + _snodec_set_component_property( + "${ARG_COMPONENT}" EXPORT_SET "snodec_${ARG_COMPONENT}_Targets" ) - _snodec_validate_arguments( - ARG "snodec_install_component_development_files" + _snodec_set_component_property( + "${ARG_COMPONENT}" HEADER_SET_COUNT "${header_set_count}" + ) + _snodec_set_component_property( + "${ARG_COMPONENT}" DEVELOPMENT_FILES_COUNT + "${development_files_count}" ) - if(NOT ARG_COMPONENT) - message(FATAL_ERROR "COMPONENT is required") + if(header_set_count GREATER 0) + foreach(header_set_index RANGE 1 ${header_set_count}) + _snodec_record_development_set( + "${ARG_COMPONENT}" HEADERS "${header_set_index}" + ${header_set_${header_set_index}_arguments} + ) + endforeach() endif() - if(NOT ARG_FILES) - message(FATAL_ERROR "FILES is required") + if(development_files_count GREATER 0) + foreach(development_files_index RANGE 1 ${development_files_count}) + _snodec_record_development_set( + "${ARG_COMPONENT}" DEVELOPMENT_FILES + "${development_files_index}" + ${development_files_${development_files_index}_arguments} + ) + endforeach() endif() - - snodec_install_component_headers( - COMPONENT "${ARG_COMPONENT}" - FILES ${ARG_FILES} - DESTINATION "${ARG_DESTINATION}" - ) endfunction() function(snodec_install_runtime_targets) + _snodec_require_not_finalized("snodec_install_runtime_targets") + set(options) set(one_value_arguments COMPONENT RUNTIME_DESTINATION LIBRARY_DESTINATION) set(multi_value_arguments TARGETS) @@ -723,6 +812,7 @@ function(snodec_install_runtime_targets) set(ARG_LIBRARY_DESTINATION "${CMAKE_INSTALL_LIBDIR}") endif() + set(real_targets) foreach(target IN LISTS ARG_TARGETS) if(NOT TARGET "${target}") message(FATAL_ERROR "Unknown SNode.C target '${target}'") @@ -730,24 +820,47 @@ function(snodec_install_runtime_targets) _snodec_real_target("${target}" real_target) _snodec_set_target_component("${real_target}" "${ARG_COMPONENT}") _snodec_record_shlibdeps_private_directory("${real_target}") + list(APPEND real_targets "${real_target}") _snodec_append_component_property( "${ARG_COMPONENT}" PENDING_TARGETS "${real_target}" ) endforeach() - _snodec_record_install_component("${ARG_COMPONENT}") - install( - TARGETS ${ARG_TARGETS} - RUNTIME DESTINATION "${ARG_RUNTIME_DESTINATION}" - COMPONENT "${ARG_COMPONENT}" - LIBRARY DESTINATION "${ARG_LIBRARY_DESTINATION}" - COMPONENT "${ARG_COMPONENT}" - BUNDLE DESTINATION "${ARG_RUNTIME_DESTINATION}" - COMPONENT "${ARG_COMPONENT}" + _snodec_component_property( + "${ARG_COMPONENT}" RUNTIME_TARGET_SET_COUNT runtime_target_set_count + ) + if(NOT runtime_target_set_count) + set(runtime_target_set_count 0) + endif() + math(EXPR runtime_target_set_count "${runtime_target_set_count} + 1") + _snodec_set_component_property( + "${ARG_COMPONENT}" RUNTIME_TARGET_SET_COUNT + "${runtime_target_set_count}" + ) + _snodec_set_component_property( + "${ARG_COMPONENT}" + "RUNTIME_TARGET_SET_${runtime_target_set_count}_TARGETS" + ${real_targets} + ) + _snodec_set_component_property( + "${ARG_COMPONENT}" + "RUNTIME_TARGET_SET_${runtime_target_set_count}_RUNTIME_DESTINATION" + "${ARG_RUNTIME_DESTINATION}" + ) + _snodec_set_component_property( + "${ARG_COMPONENT}" + "RUNTIME_TARGET_SET_${runtime_target_set_count}_LIBRARY_DESTINATION" + "${ARG_LIBRARY_DESTINATION}" + ) + set_property( + GLOBAL APPEND PROPERTY SNODEC_PENDING_RUNTIME_COMPONENTS + "${ARG_COMPONENT}" ) endfunction() function(snodec_register_runtime_component) + _snodec_require_not_finalized("snodec_register_runtime_component") + set(options) set(one_value_arguments COMPONENT DISPLAY_NAME DESCRIPTION) set(multi_value_arguments DEPENDS) @@ -767,7 +880,7 @@ function(snodec_register_runtime_component) if(NOT component_targets) message( FATAL_ERROR - "Runtime component '${ARG_COMPONENT}' has no installed targets" + "Runtime component '${ARG_COMPONENT}' has no registered targets" ) endif() @@ -789,17 +902,22 @@ function(snodec_register_runtime_component) _snodec_register_component(${register_arguments}) endfunction() -function(snodec_get_public_components result) +function(_snodec_registered_components result) + get_property(components GLOBAL PROPERTY SNODEC_BASE_COMPONENTS) + list(REMOVE_DUPLICATES components) + list(SORT components) + set(${result} "${components}" PARENT_SCOPE) +endfunction() + +function(_snodec_public_components result) get_property(public_components GLOBAL PROPERTY SNODEC_PUBLIC_COMPONENTS) list(REMOVE_DUPLICATES public_components) list(SORT public_components) set(${result} "${public_components}" PARENT_SCOPE) endfunction() -function(snodec_get_component_dependency_definitions result) - get_property(components GLOBAL PROPERTY SNODEC_BASE_COMPONENTS) - list(REMOVE_DUPLICATES components) - list(SORT components) +function(_snodec_component_dependency_definitions result) + _snodec_registered_components(components) set(dependency_definitions) foreach(component IN LISTS components) @@ -810,8 +928,8 @@ function(snodec_get_component_dependency_definitions result) continue() endif() - _snodec_component_dependencies( - "${component}" DEVELOPMENT dependencies + _snodec_component_property( + "${component}" RESOLVED_DEVELOPMENT_DEPENDS dependencies ) if(dependencies) string( @@ -828,22 +946,418 @@ function(snodec_get_component_dependency_definitions result) set(${result} "${dependency_definitions}" PARENT_SCOPE) endfunction() -macro(snodec_finalize_cpack_components) - get_property(_snodec_base_components GLOBAL PROPERTY SNODEC_BASE_COMPONENTS) - get_property( - _snodec_referenced_install_components GLOBAL - PROPERTY SNODEC_REFERENCED_INSTALL_COMPONENTS +function(_snodec_materialize_development_set component set_kind set_index) + _snodec_component_property( + "${component}" "${set_kind}_${set_index}_DIRECTORY" source_directory ) - list(REMOVE_DUPLICATES _snodec_base_components) - list(REMOVE_DUPLICATES _snodec_referenced_install_components) + _snodec_component_property( + "${component}" "${set_kind}_${set_index}_FILES" source_files + ) + _snodec_component_property( + "${component}" "${set_kind}_${set_index}_DESTINATION" destination + ) + _snodec_component_property( + "${component}" "${set_kind}_${set_index}_PATTERNS" patterns + ) + _snodec_component_property( + "${component}" "${set_kind}_${set_index}_EXCLUDE_PATTERNS" + exclude_patterns + ) + + set(development_component "${component}-dev") + _snodec_record_install_component("${development_component}") + + if(source_files) + install( + FILES ${source_files} + DESTINATION "${destination}" + COMPONENT "${development_component}" + ) + return() + endif() + + set(pattern_arguments) + if(patterns OR exclude_patterns) + list(APPEND pattern_arguments FILES_MATCHING) + endif() + foreach(pattern IN LISTS patterns) + list(APPEND pattern_arguments PATTERN "${pattern}") + endforeach() + foreach(pattern IN LISTS exclude_patterns) + list(APPEND pattern_arguments PATTERN "${pattern}" EXCLUDE) + endforeach() + + install( + DIRECTORY "${source_directory}/" + DESTINATION "${destination}" + COMPONENT "${development_component}" + ${pattern_arguments} + ) +endfunction() + +function(_snodec_materialize_library_component component) + _snodec_component_property("${component}" TARGETS component_targets) + list(LENGTH component_targets component_target_count) + if(NOT component_target_count EQUAL 1) + message( + FATAL_ERROR + "Library component '${component}' must own exactly one target" + ) + endif() + list(GET component_targets 0 component_target) + + _snodec_component_property( + "${component}" RUNTIME_DESTINATION runtime_destination + ) + _snodec_component_property( + "${component}" LIBRARY_DESTINATION library_destination + ) + _snodec_component_property( + "${component}" ARCHIVE_DESTINATION archive_destination + ) + _snodec_component_property( + "${component}" EXPORT_DESTINATION export_destination + ) + _snodec_component_property("${component}" EXPORT_SET export_set) + + set(development_component "${component}-dev") + _snodec_record_install_component("${component}") + _snodec_record_install_component("${development_component}") - if(NOT _snodec_base_components) + install( + TARGETS "${component_target}" + EXPORT "${export_set}" + RUNTIME DESTINATION "${runtime_destination}" + COMPONENT "${component}" + LIBRARY DESTINATION "${library_destination}" + COMPONENT "${component}" + NAMELINK_COMPONENT "${development_component}" + ARCHIVE DESTINATION "${archive_destination}" + COMPONENT "${development_component}" + BUNDLE DESTINATION "${runtime_destination}" + COMPONENT "${component}" + ) + install( + EXPORT "${export_set}" + FILE "${export_set}.cmake" + NAMESPACE snodec:: + DESTINATION "${export_destination}" + COMPONENT "${development_component}" + ) + + _snodec_component_property( + "${component}" HEADER_SET_COUNT header_set_count + ) + if(header_set_count GREATER 0) + foreach(header_set_index RANGE 1 ${header_set_count}) + _snodec_materialize_development_set( + "${component}" HEADERS "${header_set_index}" + ) + endforeach() + endif() + + _snodec_component_property( + "${component}" DEVELOPMENT_FILES_COUNT development_files_count + ) + if(development_files_count GREATER 0) + foreach(development_files_index RANGE 1 ${development_files_count}) + _snodec_materialize_development_set( + "${component}" DEVELOPMENT_FILES + "${development_files_index}" + ) + endforeach() + endif() +endfunction() + +function(_snodec_materialize_runtime_component component) + _snodec_component_property( + "${component}" RUNTIME_TARGET_SET_COUNT runtime_target_set_count + ) + if(NOT runtime_target_set_count + OR NOT runtime_target_set_count GREATER 0 + ) + message( + FATAL_ERROR + "Runtime component '${component}' has no target install sets" + ) + endif() + + _snodec_record_install_component("${component}") + foreach(runtime_target_set_index RANGE 1 ${runtime_target_set_count}) + _snodec_component_property( + "${component}" + "RUNTIME_TARGET_SET_${runtime_target_set_index}_TARGETS" + targets + ) + _snodec_component_property( + "${component}" + "RUNTIME_TARGET_SET_${runtime_target_set_index}_RUNTIME_DESTINATION" + runtime_destination + ) + _snodec_component_property( + "${component}" + "RUNTIME_TARGET_SET_${runtime_target_set_index}_LIBRARY_DESTINATION" + library_destination + ) + install( + TARGETS ${targets} + RUNTIME DESTINATION "${runtime_destination}" + COMPONENT "${component}" + LIBRARY DESTINATION "${library_destination}" + COMPONENT "${component}" + BUNDLE DESTINATION "${runtime_destination}" + COMPONENT "${component}" + ) + endforeach() +endfunction() + +# Complete the package-format-neutral registry exactly once after all component +# subdirectories have been processed. This resolves dependencies, optionally +# generates the installed CMake package, and materializes all install rules. +function(snodec_finalize_components) + _snodec_require_not_finalized("snodec_finalize_components") + + set(options) + set( + one_value_arguments + PACKAGE_CONFIG_TEMPLATE + PACKAGE_CONFIG_OUTPUT + PACKAGE_VERSION_OUTPUT + PACKAGE_CONFIG_DESTINATION + PACKAGE_CONFIG_COMPONENT + PACKAGE_VERSION + ) + cmake_parse_arguments( + ARG "${options}" "${one_value_arguments}" "" ${ARGN} + ) + _snodec_validate_arguments(ARG "snodec_finalize_components") + + _snodec_registered_components(components) + if(NOT components) message(FATAL_ERROR "No SNode.C components were registered") endif() + get_property( + pending_runtime_components GLOBAL PROPERTY SNODEC_PENDING_RUNTIME_COMPONENTS + ) + list(REMOVE_DUPLICATES pending_runtime_components) + foreach(pending_component IN LISTS pending_runtime_components) + if(NOT pending_component IN_LIST components) + message( + FATAL_ERROR + "Runtime targets were recorded for unregistered component '${pending_component}'" + ) + endif() + endforeach() + _snodec_validate_component_dependency_graph(RUNTIME) _snodec_validate_component_dependency_graph(DEVELOPMENT) + foreach(component IN LISTS components) + _snodec_component_dependencies( + "${component}" RUNTIME runtime_dependencies + ) + _snodec_component_dependencies( + "${component}" DEVELOPMENT development_dependencies + ) + _snodec_set_component_property( + "${component}" RESOLVED_RUNTIME_DEPENDS ${runtime_dependencies} + ) + _snodec_set_component_property( + "${component}" RESOLVED_DEVELOPMENT_DEPENDS + ${development_dependencies} + ) + endforeach() + + set(package_config_arguments_present FALSE) + foreach(package_config_argument IN ITEMS + ARG_PACKAGE_CONFIG_TEMPLATE + ARG_PACKAGE_CONFIG_OUTPUT + ARG_PACKAGE_VERSION_OUTPUT + ARG_PACKAGE_CONFIG_DESTINATION + ARG_PACKAGE_CONFIG_COMPONENT + ARG_PACKAGE_VERSION + ) + if(NOT "${${package_config_argument}}" STREQUAL "") + set(package_config_arguments_present TRUE) + endif() + endforeach() + + if(package_config_arguments_present) + foreach(required_argument IN ITEMS + PACKAGE_CONFIG_TEMPLATE + PACKAGE_CONFIG_OUTPUT + PACKAGE_VERSION_OUTPUT + PACKAGE_CONFIG_DESTINATION + PACKAGE_CONFIG_COMPONENT + PACKAGE_VERSION + ) + if(NOT ARG_${required_argument}) + message( + FATAL_ERROR + "snodec_finalize_components requires ${required_argument} " + "when generating package configuration" + ) + endif() + endforeach() + if(NOT ARG_PACKAGE_CONFIG_COMPONENT IN_LIST components) + message( + FATAL_ERROR + "Package configuration component " + "'${ARG_PACKAGE_CONFIG_COMPONENT}' is not registered" + ) + endif() + _snodec_component_property( + "${ARG_PACKAGE_CONFIG_COMPONENT}" RUNTIME_ONLY config_runtime_only + ) + if(config_runtime_only) + message( + FATAL_ERROR + "Package configuration cannot belong to runtime-only " + "component '${ARG_PACKAGE_CONFIG_COMPONENT}'" + ) + endif() + + _snodec_public_components(public_components) + string(JOIN "\n " SUPPORTED_COMPONENTS ${public_components}) + _snodec_component_dependency_definitions( + SNODEC_LIST_OF_ALL_TARGETS_DEPENDENCIES + ) + + configure_package_config_file( + "${ARG_PACKAGE_CONFIG_TEMPLATE}" + "${ARG_PACKAGE_CONFIG_OUTPUT}" + INSTALL_DESTINATION "${ARG_PACKAGE_CONFIG_DESTINATION}" + NO_SET_AND_CHECK_MACRO + ) + write_basic_package_version_file( + "${ARG_PACKAGE_VERSION_OUTPUT}" + VERSION "${ARG_PACKAGE_VERSION}" + COMPATIBILITY SameMinorVersion + ) + _snodec_append_development_files( + "${ARG_PACKAGE_CONFIG_COMPONENT}" + "${ARG_PACKAGE_CONFIG_DESTINATION}" + "${ARG_PACKAGE_CONFIG_OUTPUT}" + "${ARG_PACKAGE_VERSION_OUTPUT}" + ) + endif() + + foreach(component IN LISTS components) + _snodec_component_property( + "${component}" RUNTIME_ONLY runtime_only + ) + if(runtime_only) + _snodec_materialize_runtime_component("${component}") + else() + _snodec_materialize_library_component("${component}") + endif() + endforeach() + + set_property(GLOBAL PROPERTY SNODEC_FINALIZED_COMPONENTS ${components}) + set_property(GLOBAL PROPERTY SNODEC_COMPONENTS_FINALIZED TRUE) +endfunction() + +function(snodec_get_components result) + _snodec_require_finalized("snodec_get_components") + get_property(components GLOBAL PROPERTY SNODEC_FINALIZED_COMPONENTS) + set(${result} "${components}" PARENT_SCOPE) +endfunction() + +function(snodec_get_public_components result) + _snodec_require_finalized("snodec_get_public_components") + _snodec_public_components(public_components) + set(${result} "${public_components}" PARENT_SCOPE) +endfunction() + +function(snodec_get_component_dependency_definitions result) + _snodec_require_finalized( + "snodec_get_component_dependency_definitions" + ) + _snodec_component_dependency_definitions(dependency_definitions) + set(${result} "${dependency_definitions}" PARENT_SCOPE) +endfunction() + +# Packaging adapters can enumerate snodec_get_components() and query this +# normalized metadata. Runtime/development install component names are stable +# inputs for both CPack and external systems such as OpenWrt package recipes. +function(snodec_get_component_metadata component result_prefix) + _snodec_require_finalized("snodec_get_component_metadata") + + get_property(components GLOBAL PROPERTY SNODEC_FINALIZED_COMPONENTS) + if(NOT component IN_LIST components) + message(FATAL_ERROR "Unknown finalized SNode.C component '${component}'") + endif() + + _snodec_component_property("${component}" DISPLAY_NAME display_name) + _snodec_component_property("${component}" DESCRIPTION description) + _snodec_component_property("${component}" TARGETS targets) + _snodec_component_property("${component}" PUBLIC public_component) + _snodec_component_property("${component}" RUNTIME_ONLY runtime_only) + _snodec_component_property( + "${component}" RESOLVED_RUNTIME_DEPENDS runtime_dependencies + ) + _snodec_component_property( + "${component}" RESOLVED_DEVELOPMENT_DEPENDS + development_dependencies + ) + _snodec_component_property( + "${component}" DECLARATION_SOURCE_DIR declaration_source_dir + ) + + set("${result_prefix}_NAME" "${component}" PARENT_SCOPE) + set("${result_prefix}_DISPLAY_NAME" "${display_name}" PARENT_SCOPE) + set("${result_prefix}_DESCRIPTION" "${description}" PARENT_SCOPE) + set("${result_prefix}_TARGETS" "${targets}" PARENT_SCOPE) + set( + "${result_prefix}_PUBLIC_COMPONENT" "${public_component}" + PARENT_SCOPE + ) + set("${result_prefix}_RUNTIME_ONLY" "${runtime_only}" PARENT_SCOPE) + set( + "${result_prefix}_RUNTIME_DEPENDS" "${runtime_dependencies}" + PARENT_SCOPE + ) + set( + "${result_prefix}_DEVELOPMENT_DEPENDS" + "${development_dependencies}" + PARENT_SCOPE + ) + set( + "${result_prefix}_DECLARATION_SOURCE_DIR" + "${declaration_source_dir}" + PARENT_SCOPE + ) + set( + "${result_prefix}_RUNTIME_INSTALL_COMPONENT" "${component}" + PARENT_SCOPE + ) + if(runtime_only) + set( + "${result_prefix}_DEVELOPMENT_INSTALL_COMPONENT" "" + PARENT_SCOPE + ) + else() + set( + "${result_prefix}_DEVELOPMENT_INSTALL_COMPONENT" + "${component}-dev" + PARENT_SCOPE + ) + endif() +endfunction() + +macro(snodec_finalize_cpack_components) + _snodec_require_finalized("snodec_finalize_cpack_components") + + get_property( + _snodec_base_components GLOBAL PROPERTY SNODEC_FINALIZED_COMPONENTS + ) + get_property( + _snodec_referenced_install_components GLOBAL + PROPERTY SNODEC_REFERENCED_INSTALL_COMPONENTS + ) + list(REMOVE_DUPLICATES _snodec_referenced_install_components) + set(_snodec_cpack_components) foreach(_snodec_component IN LISTS _snodec_base_components) _snodec_component_property( @@ -855,32 +1369,17 @@ macro(snodec_finalize_cpack_components) _snodec_component_property( "${_snodec_component}" RUNTIME_ONLY _snodec_runtime_only ) - _snodec_component_dependencies( + _snodec_component_property( "${_snodec_component}" - RUNTIME + RESOLVED_RUNTIME_DEPENDS _snodec_runtime_dependencies ) - _snodec_component_dependencies( + _snodec_component_property( "${_snodec_component}" - DEVELOPMENT + RESOLVED_DEVELOPMENT_DEPENDS _snodec_development_dependencies ) - set( - _snodec_referenced_dependencies - ${_snodec_runtime_dependencies} - ${_snodec_development_dependencies} - ) - list(REMOVE_DUPLICATES _snodec_referenced_dependencies) - foreach(_snodec_dependency IN LISTS _snodec_referenced_dependencies) - if(NOT _snodec_dependency IN_LIST _snodec_base_components) - message( - FATAL_ERROR - "SNode.C component '${_snodec_component}' depends on unregistered component '${_snodec_dependency}'" - ) - endif() - endforeach() - if(NOT _snodec_component IN_LIST _snodec_referenced_install_components) message( FATAL_ERROR @@ -970,7 +1469,8 @@ macro(snodec_finalize_cpack_components) if(NOT _snodec_referenced_component IN_LIST _snodec_cpack_components) message( FATAL_ERROR - "Install rules reference unregistered SNode.C component '${_snodec_referenced_component}'" + "Install rules reference unregistered SNode.C component " + "'${_snodec_referenced_component}'" ) endif() endforeach() @@ -984,7 +1484,8 @@ macro(snodec_finalize_cpack_components) if(NOT _snodec_install_component IN_LIST _snodec_cpack_components) message( FATAL_ERROR - "CMake install component '${_snodec_install_component}' has no SNode.C CPack registration" + "CMake install component '${_snodec_install_component}' " + "has no SNode.C CPack registration" ) endif() endforeach() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 894201b307..4ea62ade7d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -147,31 +147,13 @@ endif() add_subdirectory(tools) -snodec_get_component_dependency_definitions( - SNODEC_LIST_OF_ALL_TARGETS_DEPENDENCIES -) - -snodec_get_public_components(SUPPORTED_COMPONENTS) -string(JOIN "\n " SUPPORTED_COMPONENTS ${SUPPORTED_COMPONENTS}) - -configure_package_config_file( - ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Config.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/snodecConfig.cmake - INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec - NO_SET_AND_CHECK_MACRO -) - -write_basic_package_version_file( - ${CMAKE_CURRENT_BINARY_DIR}/snodecConfigVersion.cmake - VERSION - "${SNode.C_VERSION_MAJOR}.${SNode.C_VERSION_MINOR}.${SNode.C_VERSION_PATCH}" - COMPATIBILITY SameMinorVersion -) - -snodec_install_component_development_files( - COMPONENT core - FILES - ${CMAKE_CURRENT_BINARY_DIR}/snodecConfig.cmake +snodec_finalize_components( + PACKAGE_CONFIG_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Config.cmake.in + PACKAGE_CONFIG_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/snodecConfig.cmake + PACKAGE_VERSION_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/snodecConfigVersion.cmake - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec + PACKAGE_CONFIG_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec + PACKAGE_CONFIG_COMPONENT core + PACKAGE_VERSION + "${SNode.C_VERSION_MAJOR}.${SNode.C_VERSION_MINOR}.${SNode.C_VERSION_PATCH}" ) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index ba03a3218f..576e0d7e77 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -162,27 +162,25 @@ set_target_properties( snodec_add_component( TARGET core PUBLIC_COMPONENT -) -snodec_install_component_headers( - COMPONENT core - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/core - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS - "." - EventLoop.h - EventMultiplexer.h - DescriptorEventPublisher.h - TimerEventPublisher.h - timer/IntervalTimer.h - timer/IntervalTimerStopable.h - timer/SingleshoTimer.h - cmake - multiplexer - socket + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/core + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + "." + EventLoop.h + EventMultiplexer.h + DescriptorEventPublisher.h + TimerEventPublisher.h + timer/IntervalTimer.h + timer/IntervalTimerStopable.h + timer/SingleshoTimer.h + cmake + multiplexer + socket ) add_subdirectory(socket) diff --git a/src/core/socket/CMakeLists.txt b/src/core/socket/CMakeLists.txt index 9c6205152a..7f83d3e984 100644 --- a/src/core/socket/CMakeLists.txt +++ b/src/core/socket/CMakeLists.txt @@ -62,19 +62,17 @@ set_target_properties( snodec_add_component( TARGET core-socket -) -snodec_install_component_headers( - COMPONENT core-socket - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/core/socket - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS - "." - stream - dgram + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/core/socket + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + "." + stream + dgram ) add_subdirectory(stream) diff --git a/src/core/socket/stream/CMakeLists.txt b/src/core/socket/stream/CMakeLists.txt index 5ccf5f197c..74e033b5a1 100644 --- a/src/core/socket/stream/CMakeLists.txt +++ b/src/core/socket/stream/CMakeLists.txt @@ -89,20 +89,18 @@ set_target_properties( snodec_add_component( TARGET core-socket-stream -) -snodec_install_component_headers( - COMPONENT core-socket-stream - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/core/socket/stream - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS - "." - legacy - tls - pu + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/core/socket/stream + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + "." + legacy + tls + pu ) add_subdirectory(legacy) diff --git a/src/core/socket/stream/legacy/CMakeLists.txt b/src/core/socket/stream/legacy/CMakeLists.txt index 7cfa2810b0..3ec1c981c8 100644 --- a/src/core/socket/stream/legacy/CMakeLists.txt +++ b/src/core/socket/stream/legacy/CMakeLists.txt @@ -76,14 +76,12 @@ set_target_properties( snodec_add_component( TARGET core-socket-stream-legacy PUBLIC_COMPONENT -) -snodec_install_component_headers( - COMPONENT core-socket-stream-legacy - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/core/socket/stream/legacy - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS cmake + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/core/socket/stream/legacy + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/core/socket/stream/tls/CMakeLists.txt b/src/core/socket/stream/tls/CMakeLists.txt index 0c889e4282..9d7233221c 100644 --- a/src/core/socket/stream/tls/CMakeLists.txt +++ b/src/core/socket/stream/tls/CMakeLists.txt @@ -98,18 +98,16 @@ else(NOT OpenSSL_FOUND) snodec_add_component( TARGET core-socket-stream-tls PUBLIC_COMPONENT - ) - snodec_install_component_headers( - COMPONENT core-socket-stream-tls - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/core/socket/stream/tls - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS - cmake - detail + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/core/socket/stream/tls + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + detail ) endif(NOT OpenSSL_FOUND) diff --git a/src/database/mariadb/CMakeLists.txt b/src/database/mariadb/CMakeLists.txt index 2428598d7e..624ae60462 100644 --- a/src/database/mariadb/CMakeLists.txt +++ b/src/database/mariadb/CMakeLists.txt @@ -113,16 +113,14 @@ if(LIBMARIADB_FOUND) snodec_add_component( TARGET db-mariadb PUBLIC_COMPONENT - ) - snodec_install_component_headers( - COMPONENT db-mariadb - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION include/snode.c/database/mariadb - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS cmake + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION include/snode.c/database/mariadb + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) endif(LIBMARIADB_FOUND) diff --git a/src/express/CMakeLists.txt b/src/express/CMakeLists.txt index a95814562b..7e7ce542f7 100644 --- a/src/express/CMakeLists.txt +++ b/src/express/CMakeLists.txt @@ -142,16 +142,14 @@ snodec_add_component( TARGET http-server-express LIBRARY_DESTINATION ${HTTP_INSTALL_LIBDIR} PUBLIC_COMPONENT -) -snodec_install_component_headers( - COMPONENT http-server-express - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/express - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS cmake + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/express + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) add_subdirectory(legacy) diff --git a/src/express/legacy/in/CMakeLists.txt b/src/express/legacy/in/CMakeLists.txt index 7f615fcabd..8f0fc44ad1 100644 --- a/src/express/legacy/in/CMakeLists.txt +++ b/src/express/legacy/in/CMakeLists.txt @@ -79,14 +79,12 @@ snodec_add_component( TARGET http-server-express-legacy-in LIBRARY_DESTINATION ${HTTP_INSTALL_LIBDIR} PUBLIC_COMPONENT -) -snodec_install_component_headers( - COMPONENT http-server-express-legacy-in - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/express/legacy/in - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS cmake + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/express/legacy/in + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/express/legacy/in6/CMakeLists.txt b/src/express/legacy/in6/CMakeLists.txt index 444b74f10b..3d3b44e022 100644 --- a/src/express/legacy/in6/CMakeLists.txt +++ b/src/express/legacy/in6/CMakeLists.txt @@ -79,14 +79,12 @@ snodec_add_component( TARGET http-server-express-legacy-in6 LIBRARY_DESTINATION ${HTTP_INSTALL_LIBDIR} PUBLIC_COMPONENT -) -snodec_install_component_headers( - COMPONENT http-server-express-legacy-in6 - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/express/legacy/in6 - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS cmake + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/express/legacy/in6 + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/express/legacy/rc/CMakeLists.txt b/src/express/legacy/rc/CMakeLists.txt index 06e941ce97..fd2c8419a2 100644 --- a/src/express/legacy/rc/CMakeLists.txt +++ b/src/express/legacy/rc/CMakeLists.txt @@ -81,16 +81,14 @@ if(BLUEZ_FOUND) TARGET http-server-express-legacy-rc LIBRARY_DESTINATION ${HTTP_INSTALL_LIBDIR} PUBLIC_COMPONENT - ) - snodec_install_component_headers( - COMPONENT http-server-express-legacy-rc - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/express/legacy/rc - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS cmake + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/express/legacy/rc + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) endif(BLUEZ_FOUND) diff --git a/src/express/legacy/un/CMakeLists.txt b/src/express/legacy/un/CMakeLists.txt index 8090b12f8f..5b16a01e6d 100644 --- a/src/express/legacy/un/CMakeLists.txt +++ b/src/express/legacy/un/CMakeLists.txt @@ -79,14 +79,12 @@ snodec_add_component( TARGET http-server-express-legacy-un LIBRARY_DESTINATION ${HTTP_INSTALL_LIBDIR} PUBLIC_COMPONENT -) -snodec_install_component_headers( - COMPONENT http-server-express-legacy-un - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/express/legacy/un - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS cmake + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/express/legacy/un + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/express/tls/in/CMakeLists.txt b/src/express/tls/in/CMakeLists.txt index 7fb78a5fda..51e7a27918 100644 --- a/src/express/tls/in/CMakeLists.txt +++ b/src/express/tls/in/CMakeLists.txt @@ -76,14 +76,12 @@ snodec_add_component( TARGET http-server-express-tls-in LIBRARY_DESTINATION ${HTTP_INSTALL_LIBDIR} PUBLIC_COMPONENT -) -snodec_install_component_headers( - COMPONENT http-server-express-tls-in - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/express/tls/in - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS cmake + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/express/tls/in + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/express/tls/in6/CMakeLists.txt b/src/express/tls/in6/CMakeLists.txt index bcfa10d13b..d26521adb9 100644 --- a/src/express/tls/in6/CMakeLists.txt +++ b/src/express/tls/in6/CMakeLists.txt @@ -79,14 +79,12 @@ snodec_add_component( TARGET http-server-express-tls-in6 LIBRARY_DESTINATION ${HTTP_INSTALL_LIBDIR} PUBLIC_COMPONENT -) -snodec_install_component_headers( - COMPONENT http-server-express-tls-in6 - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/express/tls/in6 - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS cmake + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/express/tls/in6 + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/express/tls/rc/CMakeLists.txt b/src/express/tls/rc/CMakeLists.txt index 05db643e14..8680feba1c 100644 --- a/src/express/tls/rc/CMakeLists.txt +++ b/src/express/tls/rc/CMakeLists.txt @@ -80,16 +80,14 @@ if(BLUEZ_FOUND) TARGET http-server-express-tls-rc LIBRARY_DESTINATION ${HTTP_INSTALL_LIBDIR} PUBLIC_COMPONENT - ) - snodec_install_component_headers( - COMPONENT http-server-express-tls-rc - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/express/tls/rc - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS cmake + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/express/tls/rc + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) endif(BLUEZ_FOUND) diff --git a/src/express/tls/un/CMakeLists.txt b/src/express/tls/un/CMakeLists.txt index 1b8d32fbfe..624cc11f4f 100644 --- a/src/express/tls/un/CMakeLists.txt +++ b/src/express/tls/un/CMakeLists.txt @@ -76,14 +76,12 @@ snodec_add_component( TARGET http-server-express-tls-un LIBRARY_DESTINATION ${HTTP_INSTALL_LIBDIR} PUBLIC_COMPONENT -) -snodec_install_component_headers( - COMPONENT http-server-express-tls-un - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/express/tls/un - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS cmake + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/express/tls/un + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/iot/mqtt/CMakeLists.txt b/src/iot/mqtt/CMakeLists.txt index ad43aed03a..1b642de178 100644 --- a/src/iot/mqtt/CMakeLists.txt +++ b/src/iot/mqtt/CMakeLists.txt @@ -102,21 +102,35 @@ if(NLOHMANN_JSON_FOUND) TARGET mqtt LIBRARY_DESTINATION ${CMAKE_INSTALL_LIBDIR}/${MQTT_INSTALL_DIR} PUBLIC_COMPONENT - ) - snodec_install_component_headers( - COMPONENT mqtt - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${MQTT_INSTALL_INCLUDEDIR} - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS - cmake - server - client - types - packets + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${MQTT_INSTALL_INCLUDEDIR} + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + server + client + types + packets + + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/packets/ + DESTINATION ${MQTT_INSTALL_INCLUDEDIR}/packets + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake + + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/types/ + DESTINATION ${MQTT_INSTALL_INCLUDEDIR}/types + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) add_subdirectory(server) diff --git a/src/iot/mqtt/client/CMakeLists.txt b/src/iot/mqtt/client/CMakeLists.txt index 1c618ef9fb..b0840941b0 100644 --- a/src/iot/mqtt/client/CMakeLists.txt +++ b/src/iot/mqtt/client/CMakeLists.txt @@ -73,12 +73,18 @@ snodec_add_component( TARGET mqtt-client LIBRARY_DESTINATION ${CMAKE_INSTALL_LIBDIR}/${MQTT_INSTALL_DIR} PUBLIC_COMPONENT -) -snodec_install_component_development_files( - COMPONENT mqtt-client - FILES Mqtt.h - DESTINATION ${MQTT_INSTALL_INCLUDEDIR}/client + HEADERS + FILES Mqtt.h + DESTINATION ${MQTT_INSTALL_INCLUDEDIR}/client + + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/packets/ + DESTINATION ${MQTT_INSTALL_INCLUDEDIR}/client/packets + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) set(MQTT_CLIENT_WEBSOCKET_CPP SubProtocol.cpp) @@ -114,10 +120,8 @@ snodec_add_component( TARGET mqtt-client-websocket LIBRARY_DESTINATION ${CMAKE_INSTALL_LIBDIR}/${MQTT_INSTALL_DIR} PUBLIC_COMPONENT -) -snodec_install_component_development_files( - COMPONENT mqtt-client-websocket - FILES SubProtocol.h - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${MQTT_INSTALL_DIR}/client + HEADERS + FILES SubProtocol.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${MQTT_INSTALL_DIR}/client ) diff --git a/src/iot/mqtt/client/packets/CMakeLists.txt b/src/iot/mqtt/client/packets/CMakeLists.txt index 72dffe117d..ef8328599f 100644 --- a/src/iot/mqtt/client/packets/CMakeLists.txt +++ b/src/iot/mqtt/client/packets/CMakeLists.txt @@ -75,13 +75,3 @@ set_property(TARGET mqtt-client-packets PROPERTY POSITION_INDEPENDENT_CODE ON) target_include_directories( mqtt-client-packets PUBLIC "$" ) - -snodec_install_component_headers( - COMPONENT mqtt-client - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${MQTT_INSTALL_INCLUDEDIR}/client/packets - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS cmake -) diff --git a/src/iot/mqtt/packets/CMakeLists.txt b/src/iot/mqtt/packets/CMakeLists.txt index 43b493af3d..5c7f657b21 100644 --- a/src/iot/mqtt/packets/CMakeLists.txt +++ b/src/iot/mqtt/packets/CMakeLists.txt @@ -82,13 +82,3 @@ set_property(TARGET mqtt-packets PROPERTY POSITION_INDEPENDENT_CODE ON) target_include_directories( mqtt-packets PUBLIC "$" ) - -snodec_install_component_headers( - COMPONENT mqtt - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${MQTT_INSTALL_INCLUDEDIR}/packets - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS cmake -) diff --git a/src/iot/mqtt/server/CMakeLists.txt b/src/iot/mqtt/server/CMakeLists.txt index e69ba6d1f7..3a82c235b4 100644 --- a/src/iot/mqtt/server/CMakeLists.txt +++ b/src/iot/mqtt/server/CMakeLists.txt @@ -78,15 +78,29 @@ snodec_add_component( TARGET mqtt-server LIBRARY_DESTINATION ${CMAKE_INSTALL_LIBDIR}/${MQTT_INSTALL_DIR} PUBLIC_COMPONENT -) -snodec_install_component_development_files( - COMPONENT mqtt-server - FILES - Mqtt.h - SharedSocketContextFactory.h - SocketContextFactory.h - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${MQTT_INSTALL_DIR}/server + HEADERS + FILES + Mqtt.h + SharedSocketContextFactory.h + SocketContextFactory.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${MQTT_INSTALL_DIR}/server + + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/packets/ + DESTINATION ${MQTT_INSTALL_INCLUDEDIR}/server/packets + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake + + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/broker/ + DESTINATION ${MQTT_INSTALL_INCLUDEDIR}/server/broker + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) set(MQTT_SERVER_WEBSOCKET_CPP SubProtocol.cpp) @@ -122,10 +136,8 @@ snodec_add_component( TARGET mqtt-server-websocket LIBRARY_DESTINATION ${CMAKE_INSTALL_LIBDIR}/${MQTT_INSTALL_DIR} PUBLIC_COMPONENT -) -snodec_install_component_development_files( - COMPONENT mqtt-server-websocket - FILES SubProtocol.h - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${MQTT_INSTALL_DIR}/server + HEADERS + FILES SubProtocol.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${MQTT_INSTALL_DIR}/server ) diff --git a/src/iot/mqtt/server/broker/CMakeLists.txt b/src/iot/mqtt/server/broker/CMakeLists.txt index 5e02580b47..730fb54277 100644 --- a/src/iot/mqtt/server/broker/CMakeLists.txt +++ b/src/iot/mqtt/server/broker/CMakeLists.txt @@ -57,13 +57,3 @@ set_property(TARGET mqtt-broker PROPERTY POSITION_INDEPENDENT_CODE ON) target_include_directories( mqtt-broker PUBLIC "$" ) - -snodec_install_component_headers( - COMPONENT mqtt-server - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${MQTT_INSTALL_INCLUDEDIR}/server/broker - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS cmake -) diff --git a/src/iot/mqtt/server/packets/CMakeLists.txt b/src/iot/mqtt/server/packets/CMakeLists.txt index ead31184fa..c8ba7e13ad 100644 --- a/src/iot/mqtt/server/packets/CMakeLists.txt +++ b/src/iot/mqtt/server/packets/CMakeLists.txt @@ -77,13 +77,3 @@ set_property(TARGET mqtt-server-packets PROPERTY POSITION_INDEPENDENT_CODE ON) target_include_directories( mqtt-server-packets PUBLIC "$" ) - -snodec_install_component_headers( - COMPONENT mqtt-server - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${MQTT_INSTALL_INCLUDEDIR}/server/packets - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS cmake -) diff --git a/src/iot/mqtt/types/CMakeLists.txt b/src/iot/mqtt/types/CMakeLists.txt index 8651215a4e..b0001a66ce 100644 --- a/src/iot/mqtt/types/CMakeLists.txt +++ b/src/iot/mqtt/types/CMakeLists.txt @@ -62,13 +62,3 @@ set_target_properties(mqtt-types PROPERTIES POSITION_INDEPENDENT_CODE ON) target_include_directories( mqtt-types PUBLIC "$" ) - -snodec_install_component_headers( - COMPONENT mqtt - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${MQTT_INSTALL_INCLUDEDIR}/types - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS cmake -) diff --git a/src/log/CMakeLists.txt b/src/log/CMakeLists.txt index fa140844e1..bc7df1a4a4 100644 --- a/src/log/CMakeLists.txt +++ b/src/log/CMakeLists.txt @@ -91,14 +91,12 @@ set_target_properties( snodec_add_component( TARGET logger -) -snodec_install_component_headers( - COMPONENT logger - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION include/snode.c/log - PATTERNS *.h - EXCLUDE_PATTERNS - cmake - detail + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION include/snode.c/log + PATTERNS *.h + EXCLUDE_PATTERNS + cmake + detail ) diff --git a/src/net/CMakeLists.txt b/src/net/CMakeLists.txt index 045ea90ea0..5dd8e5a66b 100644 --- a/src/net/CMakeLists.txt +++ b/src/net/CMakeLists.txt @@ -218,22 +218,20 @@ set_target_properties( snodec_add_component( TARGET net PUBLIC_COMPONENT -) -snodec_install_component_headers( - COMPONENT net - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS - cmake - in - in6 - l2 - rc - un + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + in + in6 + l2 + rc + un ) add_subdirectory(in) diff --git a/src/net/in/CMakeLists.txt b/src/net/in/CMakeLists.txt index aea1e28be1..9d6cea2704 100644 --- a/src/net/in/CMakeLists.txt +++ b/src/net/in/CMakeLists.txt @@ -71,20 +71,18 @@ set_target_properties( snodec_add_component( TARGET net-in -) -snodec_install_component_headers( - COMPONENT net-in - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/in - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS - cmake - stream - dgram - phy + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/in + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + stream + dgram + phy ) add_subdirectory(phy) diff --git a/src/net/in/phy/CMakeLists.txt b/src/net/in/phy/CMakeLists.txt index 44f387c673..24050e7b3e 100644 --- a/src/net/in/phy/CMakeLists.txt +++ b/src/net/in/phy/CMakeLists.txt @@ -62,19 +62,17 @@ set_target_properties( snodec_add_component( TARGET net-in-phy -) -snodec_install_component_headers( - COMPONENT net-in-phy - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/in/phy - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS - cmake - stream - dgram + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/in/phy + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + stream + dgram ) add_subdirectory(stream) diff --git a/src/net/in/phy/stream/CMakeLists.txt b/src/net/in/phy/stream/CMakeLists.txt index e1ec569179..c2d947197b 100644 --- a/src/net/in/phy/stream/CMakeLists.txt +++ b/src/net/in/phy/stream/CMakeLists.txt @@ -68,17 +68,15 @@ set_target_properties( snodec_add_component( TARGET net-in-phy-stream -) -snodec_install_component_headers( - COMPONENT net-in-phy-stream - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/in/phy/stream - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS - cmake - legacy - tls + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/in/phy/stream + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + legacy + tls ) diff --git a/src/net/in/stream/CMakeLists.txt b/src/net/in/stream/CMakeLists.txt index 67391f660e..831d32d98a 100644 --- a/src/net/in/stream/CMakeLists.txt +++ b/src/net/in/stream/CMakeLists.txt @@ -82,19 +82,17 @@ set_target_properties( snodec_add_component( TARGET net-in-stream -) -snodec_install_component_headers( - COMPONENT net-in-stream - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/in/stream - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS - cmake - legacy - tls + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/in/stream + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + legacy + tls ) add_subdirectory(legacy) diff --git a/src/net/in/stream/legacy/CMakeLists.txt b/src/net/in/stream/legacy/CMakeLists.txt index 5273e0f597..e817fb6c4e 100644 --- a/src/net/in/stream/legacy/CMakeLists.txt +++ b/src/net/in/stream/legacy/CMakeLists.txt @@ -74,14 +74,12 @@ set_target_properties( snodec_add_component( TARGET net-in-stream-legacy PUBLIC_COMPONENT -) -snodec_install_component_headers( - COMPONENT net-in-stream-legacy - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/in/stream/legacy - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS cmake + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/in/stream/legacy + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/net/in/stream/tls/CMakeLists.txt b/src/net/in/stream/tls/CMakeLists.txt index 5f101c99b5..6ab583e4c4 100644 --- a/src/net/in/stream/tls/CMakeLists.txt +++ b/src/net/in/stream/tls/CMakeLists.txt @@ -72,14 +72,12 @@ set_target_properties( snodec_add_component( TARGET net-in-stream-tls PUBLIC_COMPONENT -) -snodec_install_component_headers( - COMPONENT net-in-stream-tls - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/in/stream/tls - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS cmake + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/in/stream/tls + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/net/in6/CMakeLists.txt b/src/net/in6/CMakeLists.txt index 6fc956a852..1ac1bd76cd 100644 --- a/src/net/in6/CMakeLists.txt +++ b/src/net/in6/CMakeLists.txt @@ -75,20 +75,18 @@ set_target_properties( snodec_add_component( TARGET net-in6 -) -snodec_install_component_headers( - COMPONENT net-in6 - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/in6 - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS - cmake - stream - dgram - phy + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/in6 + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + stream + dgram + phy ) add_subdirectory(phy) diff --git a/src/net/in6/phy/CMakeLists.txt b/src/net/in6/phy/CMakeLists.txt index 55f6769f2e..d4e93385cb 100644 --- a/src/net/in6/phy/CMakeLists.txt +++ b/src/net/in6/phy/CMakeLists.txt @@ -62,19 +62,17 @@ set_target_properties( snodec_add_component( TARGET net-in6-phy -) -snodec_install_component_headers( - COMPONENT net-in6-phy - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/in6/phy - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS - cmake - stream - dgram + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/in6/phy + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + stream + dgram ) add_subdirectory(stream) diff --git a/src/net/in6/phy/stream/CMakeLists.txt b/src/net/in6/phy/stream/CMakeLists.txt index 484a20b4aa..32e1ee4ee5 100644 --- a/src/net/in6/phy/stream/CMakeLists.txt +++ b/src/net/in6/phy/stream/CMakeLists.txt @@ -68,17 +68,15 @@ set_target_properties( snodec_add_component( TARGET net-in6-phy-stream -) -snodec_install_component_headers( - COMPONENT net-in6-phy-stream - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/in6/phy/stream - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS - cmake - legacy - tls + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/in6/phy/stream + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + legacy + tls ) diff --git a/src/net/in6/stream/CMakeLists.txt b/src/net/in6/stream/CMakeLists.txt index fab87bfb56..f089faebcc 100644 --- a/src/net/in6/stream/CMakeLists.txt +++ b/src/net/in6/stream/CMakeLists.txt @@ -85,19 +85,17 @@ set_target_properties( snodec_add_component( TARGET net-in6-stream -) -snodec_install_component_headers( - COMPONENT net-in6-stream - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/in6/stream - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS - cmake - legacy - tls + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/in6/stream + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + legacy + tls ) add_subdirectory(legacy) diff --git a/src/net/in6/stream/legacy/CMakeLists.txt b/src/net/in6/stream/legacy/CMakeLists.txt index e60a571e5f..464f82b724 100644 --- a/src/net/in6/stream/legacy/CMakeLists.txt +++ b/src/net/in6/stream/legacy/CMakeLists.txt @@ -74,14 +74,12 @@ set_target_properties( snodec_add_component( TARGET net-in6-stream-legacy PUBLIC_COMPONENT -) -snodec_install_component_headers( - COMPONENT net-in6-stream-legacy - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/in6/stream/legacy - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS cmake + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/in6/stream/legacy + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/net/in6/stream/tls/CMakeLists.txt b/src/net/in6/stream/tls/CMakeLists.txt index 01282ad19d..5f0b603dab 100644 --- a/src/net/in6/stream/tls/CMakeLists.txt +++ b/src/net/in6/stream/tls/CMakeLists.txt @@ -73,14 +73,12 @@ set_target_properties( snodec_add_component( TARGET net-in6-stream-tls PUBLIC_COMPONENT -) -snodec_install_component_headers( - COMPONENT net-in6-stream-tls - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/in6/stream/tls - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS cmake + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/in6/stream/tls + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/net/l2/CMakeLists.txt b/src/net/l2/CMakeLists.txt index c25d156ce5..2e51a55929 100644 --- a/src/net/l2/CMakeLists.txt +++ b/src/net/l2/CMakeLists.txt @@ -67,20 +67,18 @@ if(BLUEZ_FOUND) snodec_add_component( TARGET net-l2 - ) - snodec_install_component_headers( - COMPONENT net-l2 - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/l2 - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS - cmake - stream - dgram - phy + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/l2 + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + stream + dgram + phy ) add_subdirectory(phy) diff --git a/src/net/l2/phy/CMakeLists.txt b/src/net/l2/phy/CMakeLists.txt index 92fb0300db..46ae9256b5 100644 --- a/src/net/l2/phy/CMakeLists.txt +++ b/src/net/l2/phy/CMakeLists.txt @@ -62,19 +62,17 @@ set_target_properties( snodec_add_component( TARGET net-l2-phy -) -snodec_install_component_headers( - COMPONENT net-l2-phy - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/l2/phy - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS - cmake - stream - dgram + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/l2/phy + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + stream + dgram ) add_subdirectory(stream) diff --git a/src/net/l2/phy/stream/CMakeLists.txt b/src/net/l2/phy/stream/CMakeLists.txt index 47d1a8f9a4..92f92026a4 100644 --- a/src/net/l2/phy/stream/CMakeLists.txt +++ b/src/net/l2/phy/stream/CMakeLists.txt @@ -68,17 +68,15 @@ set_target_properties( snodec_add_component( TARGET net-l2-phy-stream -) -snodec_install_component_headers( - COMPONENT net-l2-phy-stream - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/l2/phy/stream - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS - cmake - legacy - tls + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/l2/phy/stream + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + legacy + tls ) diff --git a/src/net/l2/stream/CMakeLists.txt b/src/net/l2/stream/CMakeLists.txt index c29f77e157..8feaa06e6f 100644 --- a/src/net/l2/stream/CMakeLists.txt +++ b/src/net/l2/stream/CMakeLists.txt @@ -66,19 +66,17 @@ set_target_properties( snodec_add_component( TARGET net-l2-stream -) -snodec_install_component_headers( - COMPONENT net-l2-stream - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/l2/stream - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS - cmake - legacy - tls + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/l2/stream + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + legacy + tls ) add_subdirectory(legacy) diff --git a/src/net/l2/stream/legacy/CMakeLists.txt b/src/net/l2/stream/legacy/CMakeLists.txt index 7f7f88caa2..7791f6dca9 100644 --- a/src/net/l2/stream/legacy/CMakeLists.txt +++ b/src/net/l2/stream/legacy/CMakeLists.txt @@ -79,14 +79,12 @@ set(NET-L2-STREAM-LEGACY snodec_add_component( TARGET net-l2-stream-legacy PUBLIC_COMPONENT -) -snodec_install_component_headers( - COMPONENT net-l2-stream-legacy - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/l2/stream/legacy - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS cmake + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/l2/stream/legacy + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/net/l2/stream/tls/CMakeLists.txt b/src/net/l2/stream/tls/CMakeLists.txt index c5094ee2a7..6b1945e4ac 100644 --- a/src/net/l2/stream/tls/CMakeLists.txt +++ b/src/net/l2/stream/tls/CMakeLists.txt @@ -77,14 +77,12 @@ set(NET-L2-STREAM-TLS snodec_add_component( TARGET net-l2-stream-tls PUBLIC_COMPONENT -) -snodec_install_component_headers( - COMPONENT net-l2-stream-tls - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/l2/stream/tls - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS cmake + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/l2/stream/tls + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/net/rc/CMakeLists.txt b/src/net/rc/CMakeLists.txt index e862b17cdd..c7962d73af 100644 --- a/src/net/rc/CMakeLists.txt +++ b/src/net/rc/CMakeLists.txt @@ -67,20 +67,18 @@ if(BLUEZ_FOUND) snodec_add_component( TARGET net-rc - ) - snodec_install_component_headers( - COMPONENT net-rc - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/rc - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS - cmake - stream - dgram - phy + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/rc + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + stream + dgram + phy ) add_subdirectory(phy) diff --git a/src/net/rc/phy/CMakeLists.txt b/src/net/rc/phy/CMakeLists.txt index 965823dd9c..64e081d788 100644 --- a/src/net/rc/phy/CMakeLists.txt +++ b/src/net/rc/phy/CMakeLists.txt @@ -62,19 +62,17 @@ set_target_properties( snodec_add_component( TARGET net-rc-phy -) -snodec_install_component_headers( - COMPONENT net-rc-phy - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/rc/phy - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS - cmake - stream - dgram + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/rc/phy + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + stream + dgram ) add_subdirectory(stream) diff --git a/src/net/rc/phy/stream/CMakeLists.txt b/src/net/rc/phy/stream/CMakeLists.txt index 9f7847154e..b3b5613ac9 100644 --- a/src/net/rc/phy/stream/CMakeLists.txt +++ b/src/net/rc/phy/stream/CMakeLists.txt @@ -68,17 +68,15 @@ set_target_properties( snodec_add_component( TARGET net-rc-phy-stream -) -snodec_install_component_headers( - COMPONENT net-rc-phy-stream - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/rc/phy/stream - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS - cmake - legacy - tls + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/rc/phy/stream + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + legacy + tls ) diff --git a/src/net/rc/stream/CMakeLists.txt b/src/net/rc/stream/CMakeLists.txt index fa1fccd56b..01ddfa3417 100644 --- a/src/net/rc/stream/CMakeLists.txt +++ b/src/net/rc/stream/CMakeLists.txt @@ -66,19 +66,17 @@ set_target_properties( snodec_add_component( TARGET net-rc-stream -) -snodec_install_component_headers( - COMPONENT net-rc-stream - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/rc/stream - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS - cmake - legacy - tls + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/rc/stream + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + legacy + tls ) add_subdirectory(legacy) diff --git a/src/net/rc/stream/legacy/CMakeLists.txt b/src/net/rc/stream/legacy/CMakeLists.txt index c283f8ddf1..0773f80380 100644 --- a/src/net/rc/stream/legacy/CMakeLists.txt +++ b/src/net/rc/stream/legacy/CMakeLists.txt @@ -79,14 +79,12 @@ set(NET-RC-STREAM-LEGACY snodec_add_component( TARGET net-rc-stream-legacy PUBLIC_COMPONENT -) -snodec_install_component_headers( - COMPONENT net-rc-stream-legacy - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/rc/stream/legacy - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS cmake + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/rc/stream/legacy + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/net/rc/stream/tls/CMakeLists.txt b/src/net/rc/stream/tls/CMakeLists.txt index b107f299cb..86cb2c104b 100644 --- a/src/net/rc/stream/tls/CMakeLists.txt +++ b/src/net/rc/stream/tls/CMakeLists.txt @@ -77,14 +77,12 @@ set(NET-RC-STREAM-TLS snodec_add_component( TARGET net-rc-stream-tls PUBLIC_COMPONENT -) -snodec_install_component_headers( - COMPONENT net-rc-stream-tls - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/rc/stream/tls - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS cmake + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/rc/stream/tls + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/net/un/CMakeLists.txt b/src/net/un/CMakeLists.txt index 8382904dd5..42068e112d 100644 --- a/src/net/un/CMakeLists.txt +++ b/src/net/un/CMakeLists.txt @@ -62,20 +62,18 @@ set_target_properties( snodec_add_component( TARGET net-un -) -snodec_install_component_headers( - COMPONENT net-un - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/un - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS - cmake - stream - dgram - phy + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/un + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + stream + dgram + phy ) add_subdirectory(phy) diff --git a/src/net/un/dgram/CMakeLists.txt b/src/net/un/dgram/CMakeLists.txt index a300cb1d41..52309b37ce 100644 --- a/src/net/un/dgram/CMakeLists.txt +++ b/src/net/un/dgram/CMakeLists.txt @@ -63,14 +63,12 @@ set_target_properties( snodec_add_component( TARGET net-un-dgram PUBLIC_COMPONENT -) -snodec_install_component_headers( - COMPONENT net-un-dgram - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/un/dgram - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS cmake + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/un/dgram + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/net/un/phy/CMakeLists.txt b/src/net/un/phy/CMakeLists.txt index 1d90f8ff92..3e1fb546cc 100644 --- a/src/net/un/phy/CMakeLists.txt +++ b/src/net/un/phy/CMakeLists.txt @@ -62,19 +62,17 @@ set_target_properties( snodec_add_component( TARGET net-un-phy -) -snodec_install_component_headers( - COMPONENT net-un-phy - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/un/phy - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS - cmake - stream - dgram + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/un/phy + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + stream + dgram ) add_subdirectory(stream) diff --git a/src/net/un/phy/stream/CMakeLists.txt b/src/net/un/phy/stream/CMakeLists.txt index 08c6bafdaa..ae413d0203 100644 --- a/src/net/un/phy/stream/CMakeLists.txt +++ b/src/net/un/phy/stream/CMakeLists.txt @@ -68,17 +68,15 @@ set_target_properties( snodec_add_component( TARGET net-un-phy-stream -) -snodec_install_component_headers( - COMPONENT net-un-phy-stream - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/un/phy/stream - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS - cmake - legacy - tls + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/un/phy/stream + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + legacy + tls ) diff --git a/src/net/un/stream/CMakeLists.txt b/src/net/un/stream/CMakeLists.txt index af2e24c896..ef01196f6e 100644 --- a/src/net/un/stream/CMakeLists.txt +++ b/src/net/un/stream/CMakeLists.txt @@ -66,19 +66,17 @@ set_target_properties( snodec_add_component( TARGET net-un-stream -) -snodec_install_component_headers( - COMPONENT net-un-stream - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/un/stream - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS - cmake - legacy - tls + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/un/stream + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + legacy + tls ) add_subdirectory(legacy) diff --git a/src/net/un/stream/legacy/CMakeLists.txt b/src/net/un/stream/legacy/CMakeLists.txt index 4f17f6e7a4..922a78b867 100644 --- a/src/net/un/stream/legacy/CMakeLists.txt +++ b/src/net/un/stream/legacy/CMakeLists.txt @@ -74,14 +74,12 @@ set_target_properties( snodec_add_component( TARGET net-un-stream-legacy PUBLIC_COMPONENT -) -snodec_install_component_headers( - COMPONENT net-un-stream-legacy - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/un/stream/legacy - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS cmake + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/un/stream/legacy + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/net/un/stream/tls/CMakeLists.txt b/src/net/un/stream/tls/CMakeLists.txt index e661cfe11d..3f3a9807fa 100644 --- a/src/net/un/stream/tls/CMakeLists.txt +++ b/src/net/un/stream/tls/CMakeLists.txt @@ -72,14 +72,12 @@ set_target_properties( snodec_add_component( TARGET net-un-stream-tls PUBLIC_COMPONENT -) -snodec_install_component_headers( - COMPONENT net-un-stream-tls - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/un/stream/tls - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS cmake + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/net/un/stream/tls + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/utils/CMakeLists.txt b/src/utils/CMakeLists.txt index 9dd7cfff36..53b8cfc379 100644 --- a/src/utils/CMakeLists.txt +++ b/src/utils/CMakeLists.txt @@ -103,14 +103,12 @@ set_target_properties( snodec_add_component( TARGET utils -) -snodec_install_component_headers( - COMPONENT utils - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/utils - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS cmake + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snode.c/utils + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/web/http/CMakeLists.txt b/src/web/http/CMakeLists.txt index 2f84ea7a76..e380ce23a8 100644 --- a/src/web/http/CMakeLists.txt +++ b/src/web/http/CMakeLists.txt @@ -151,21 +151,23 @@ snodec_add_component( TARGET http LIBRARY_DESTINATION ${HTTP_INSTALL_LIBDIR} PUBLIC_COMPONENT -) -snodec_install_component_headers( - COMPONENT http - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${HTTP_INSTALL_INCLUDEDIR} - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS - cmake - server - client - legacy - tls + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${HTTP_INSTALL_INCLUDEDIR} + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + server + client + legacy + tls + + DEVELOPMENT_FILES + FILES ${CMAKE_CURRENT_BINARY_DIR}/snodec_http_Targets_Config.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec ) add_subdirectory(server) @@ -175,9 +177,3 @@ configure_file( cmake/snodec_http_Targets_Config.cmake.in snodec_http_Targets_Config.cmake @ONLY ) - -snodec_install_component_development_files( - COMPONENT http - FILES ${CMAKE_CURRENT_BINARY_DIR}/snodec_http_Targets_Config.cmake - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec -) diff --git a/src/web/http/client/CMakeLists.txt b/src/web/http/client/CMakeLists.txt index dbc0124485..9f9f5a70e5 100644 --- a/src/web/http/client/CMakeLists.txt +++ b/src/web/http/client/CMakeLists.txt @@ -113,32 +113,26 @@ snodec_add_component( TARGET http-client LIBRARY_DESTINATION ${HTTP_INSTALL_LIBDIR} PUBLIC_COMPONENT -) -snodec_install_component_headers( - COMPONENT http-client - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${HTTP_INSTALL_INCLUDEDIR}/client - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS cmake -) + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${HTTP_INSTALL_INCLUDEDIR}/client + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake -snodec_install_component_headers( - COMPONENT http-client - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../legacy/ - DESTINATION ${HTTP_INSTALL_INCLUDEDIR}/legacy - PATTERNS - Client.h - EventSource.h -) + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../legacy/ + DESTINATION ${HTTP_INSTALL_INCLUDEDIR}/legacy + PATTERNS + Client.h + EventSource.h -snodec_install_component_headers( - COMPONENT http-client - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../tls/ - DESTINATION ${HTTP_INSTALL_INCLUDEDIR}/tls - PATTERNS - Client.h - EventSource.h + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../tls/ + DESTINATION ${HTTP_INSTALL_INCLUDEDIR}/tls + PATTERNS + Client.h + EventSource.h ) diff --git a/src/web/http/server/CMakeLists.txt b/src/web/http/server/CMakeLists.txt index 6ba358a3bf..28c0a9df5d 100644 --- a/src/web/http/server/CMakeLists.txt +++ b/src/web/http/server/CMakeLists.txt @@ -97,30 +97,24 @@ snodec_add_component( TARGET http-server LIBRARY_DESTINATION ${HTTP_INSTALL_LIBDIR} PUBLIC_COMPONENT -) -snodec_install_component_headers( - COMPONENT http-server - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${HTTP_INSTALL_INCLUDEDIR}/server - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS - cmake - pu -) + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${HTTP_INSTALL_INCLUDEDIR}/server + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + pu -snodec_install_component_headers( - COMPONENT http-server - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../legacy/ - DESTINATION ${HTTP_INSTALL_INCLUDEDIR}/legacy - PATTERNS Server.h -) + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../legacy/ + DESTINATION ${HTTP_INSTALL_INCLUDEDIR}/legacy + PATTERNS Server.h -snodec_install_component_headers( - COMPONENT http-server - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../tls/ - DESTINATION ${HTTP_INSTALL_INCLUDEDIR}/tls - PATTERNS Server.h + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../tls/ + DESTINATION ${HTTP_INSTALL_INCLUDEDIR}/tls + PATTERNS Server.h ) diff --git a/src/web/websocket/CMakeLists.txt b/src/web/websocket/CMakeLists.txt index b81d15ee8f..58f6653e4e 100644 --- a/src/web/websocket/CMakeLists.txt +++ b/src/web/websocket/CMakeLists.txt @@ -95,20 +95,22 @@ set_target_properties( snodec_add_component( TARGET websocket LIBRARY_DESTINATION ${HTTP_UPGRADE_INSTALL_LIBDIR} -) -snodec_install_component_headers( - COMPONENT websocket - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${WEBSOCKET_INSTALL_INCLUDEDIR} - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS - cmake - client - server - subprotocol + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${WEBSOCKET_INSTALL_INCLUDEDIR} + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS + cmake + client + server + subprotocol + + DEVELOPMENT_FILES + FILES ${CMAKE_CURRENT_BINARY_DIR}/snodec_websocket_Targets_Config.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec ) add_subdirectory(server) @@ -118,9 +120,3 @@ configure_file( cmake/snodec_websocket_Targets_Config.cmake.in snodec_websocket_Targets_Config.cmake @ONLY ) - -snodec_install_component_development_files( - COMPONENT websocket - FILES ${CMAKE_CURRENT_BINARY_DIR}/snodec_websocket_Targets_Config.cmake - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/snodec -) diff --git a/src/web/websocket/client/CMakeLists.txt b/src/web/websocket/client/CMakeLists.txt index f8f565b2de..75ba2373af 100644 --- a/src/web/websocket/client/CMakeLists.txt +++ b/src/web/websocket/client/CMakeLists.txt @@ -110,14 +110,12 @@ snodec_add_component( TARGET websocket-client LIBRARY_DESTINATION ${HTTP_UPGRADE_INSTALL_LIBDIR} PUBLIC_COMPONENT -) -snodec_install_component_headers( - COMPONENT websocket-client - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${WEBSOCKET_INSTALL_INCLUDEDIR}/client - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS cmake + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${WEBSOCKET_INSTALL_INCLUDEDIR}/client + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/src/web/websocket/server/CMakeLists.txt b/src/web/websocket/server/CMakeLists.txt index 102a79db68..64aafdd28d 100644 --- a/src/web/websocket/server/CMakeLists.txt +++ b/src/web/websocket/server/CMakeLists.txt @@ -92,14 +92,12 @@ snodec_add_component( TARGET websocket-server LIBRARY_DESTINATION ${HTTP_UPGRADE_INSTALL_LIBDIR} PUBLIC_COMPONENT -) -snodec_install_component_headers( - COMPONENT websocket-server - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${WEBSOCKET_INSTALL_INCLUDEDIR}/server - PATTERNS - "*.h" - "*.hpp" - EXCLUDE_PATTERNS cmake + HEADERS + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${WEBSOCKET_INSTALL_INCLUDEDIR}/server + PATTERNS + "*.h" + "*.hpp" + EXCLUDE_PATTERNS cmake ) diff --git a/tests/ComponentRegistryValidationTest.cmake b/tests/ComponentRegistryValidationTest.cmake index 25bf05dbd3..7bc7256011 100644 --- a/tests/ComponentRegistryValidationTest.cmake +++ b/tests/ComponentRegistryValidationTest.cmake @@ -14,7 +14,6 @@ if(NOT DEFINED SNODEC_TEST_BINARY_DIR) message(FATAL_ERROR "SNODEC_TEST_BINARY_DIR is required") endif() - # Production components must use the central registration API. Raw install() # rules in src/ would bypass the runtime/development split, and CPack metadata # must never be reconstructed in the global packaging policy file. @@ -24,13 +23,25 @@ foreach(component_cmake_file IN LISTS component_cmake_files) if(component_cmake_source MATCHES "(^|\n)[ \t]*install[ \t]*[(]") message( FATAL_ERROR - "Raw install() rule found in '${component_cmake_file}'; use the SNode.C component helpers" + "Raw install() rule found in '${component_cmake_file}'; " + "use the SNode.C component helpers" ) endif() if(component_cmake_source MATCHES "cpack_add_component[ \t]*[(]") message( FATAL_ERROR - "Local CPack call found in '${component_cmake_file}'; component helpers own CPack registration" + "Local CPack call found in '${component_cmake_file}'; " + "component helpers own CPack registration" + ) + endif() + if(component_cmake_source MATCHES + "snodec_install_component_(headers|development_files)[ \t]*[(]" + ) + message( + FATAL_ERROR + "Legacy split component declaration found in " + "'${component_cmake_file}'; put development content in " + "snodec_add_component()" ) endif() endforeach() @@ -38,9 +49,22 @@ file(READ "${SNODEC_SOURCE_DIR}/cmake/Packing.cmake" packing_source) if(packing_source MATCHES "cpack_add_component[ \t]*[(]") message( FATAL_ERROR - "Packing.cmake must contain policy only; components register in their own CMakeLists.txt files" + "Packing.cmake must contain policy only; components register " + "in their own CMakeLists.txt files" ) endif() +file(READ "${SNODEC_SOURCE_DIR}/cmake/SNodeCComponent.cmake" component_api_source) +foreach(removed_command IN ITEMS + snodec_install_component_headers + snodec_install_component_development_files +) + if(component_api_source MATCHES "function[ \t]*[(]${removed_command}") + message( + FATAL_ERROR + "Removed component API '${removed_command}' is still defined" + ) + endif() +endforeach() set(stage "${SNODEC_TEST_BINARY_DIR}/component-registry-validation") file(REMOVE_RECURSE "${stage}") @@ -99,11 +123,44 @@ function(run_registry_case case_name case_body expected_result expected_message) endfunction() set(valid_case [=[ +add_library(b SHARED component.cpp) +snodec_add_component( + TARGET b + HEADERS FILES component.h DESTINATION include/b +) add_library(a SHARED component.cpp) -snodec_add_component(TARGET a) -snodec_install_component_headers( - COMPONENT a FILES component.h DESTINATION include +target_link_libraries(a PUBLIC b) +snodec_add_component( + TARGET a + PUBLIC_COMPONENT + HEADERS FILES component.h DESTINATION include/a + HEADERS + DIRECTORY . + DESTINATION include/a/detail + PATTERNS component.h + DEVELOPMENT_FILES FILES component.cpp DESTINATION share/a ) +snodec_finalize_components() +snodec_get_components(components) +snodec_get_component_metadata(a A) +if(NOT components STREQUAL "a;b") + message(FATAL_ERROR "unexpected finalized component list: ${components}") +endif() +if(NOT A_RUNTIME_INSTALL_COMPONENT STREQUAL "a") + message(FATAL_ERROR "unexpected runtime component metadata") +endif() +if(NOT A_DEVELOPMENT_INSTALL_COMPONENT STREQUAL "a-dev") + message(FATAL_ERROR "unexpected development component metadata") +endif() +if(NOT A_PUBLIC_COMPONENT) + message(FATAL_ERROR "public component metadata was not preserved") +endif() +if(NOT A_RUNTIME_DEPENDS STREQUAL "b") + message(FATAL_ERROR "unexpected runtime metadata: ${A_RUNTIME_DEPENDS}") +endif() +if(NOT A_DEVELOPMENT_DEPENDS STREQUAL "b") + message(FATAL_ERROR "unexpected development metadata: ${A_DEVELOPMENT_DEPENDS}") +endif() snodec_finalize_cpack_components() ]=]) run_registry_case(valid "${valid_case}" SUCCESS "") @@ -111,9 +168,10 @@ run_registry_case(valid "${valid_case}" SUCCESS "") set(duplicate_case [=[ add_library(a SHARED component.cpp) add_library(b SHARED component.cpp) -snodec_add_component(TARGET a COMPONENT duplicate) -snodec_install_component_headers( - COMPONENT duplicate FILES component.h DESTINATION include +snodec_add_component( + TARGET a + COMPONENT duplicate + HEADERS FILES component.h DESTINATION include ) snodec_add_component(TARGET b COMPONENT duplicate) ]=]) @@ -126,11 +184,12 @@ run_registry_case( set(missing_case [=[ add_library(a SHARED component.cpp) -snodec_add_component(TARGET a DEPENDS missing) -snodec_install_component_headers( - COMPONENT a FILES component.h DESTINATION include +snodec_add_component( + TARGET a + DEPENDS missing + HEADERS FILES component.h DESTINATION include ) -snodec_finalize_cpack_components() +snodec_finalize_components() ]=]) run_registry_case( missing @@ -142,15 +201,17 @@ run_registry_case( set(runtime_cycle_case [=[ add_library(a SHARED component.cpp) add_library(b SHARED component.cpp) -snodec_add_component(TARGET a DEPENDS b) -snodec_install_component_headers( - COMPONENT a FILES component.h DESTINATION include +snodec_add_component( + TARGET a + DEPENDS b + HEADERS FILES component.h DESTINATION include ) -snodec_add_component(TARGET b DEPENDS a) -snodec_install_component_headers( - COMPONENT b FILES component.h DESTINATION include +snodec_add_component( + TARGET b + DEPENDS a + HEADERS FILES component.h DESTINATION include ) -snodec_finalize_cpack_components() +snodec_finalize_components() ]=]) run_registry_case( runtime-cycle @@ -162,15 +223,17 @@ run_registry_case( set(development_cycle_case [=[ add_library(a SHARED component.cpp) add_library(b SHARED component.cpp) -snodec_add_component(TARGET a DEVELOPMENT_DEPENDS b) -snodec_install_component_headers( - COMPONENT a FILES component.h DESTINATION include +snodec_add_component( + TARGET a + DEVELOPMENT_DEPENDS b + HEADERS FILES component.h DESTINATION include ) -snodec_add_component(TARGET b DEVELOPMENT_DEPENDS a) -snodec_install_component_headers( - COMPONENT b FILES component.h DESTINATION include +snodec_add_component( + TARGET b + DEVELOPMENT_DEPENDS a + HEADERS FILES component.h DESTINATION include ) -snodec_finalize_cpack_components() +snodec_finalize_components() ]=]) run_registry_case( development-cycle @@ -179,7 +242,6 @@ run_registry_case( "Cyclic SNode.C development component dependency: a -> b -> a" ) - set(missing_value_case [=[ add_library(a SHARED component.cpp) snodec_add_component(TARGET) From e3ae863d91b732eaedec227dbc99b71c0e3cd443 Mon Sep 17 00:00:00 2001 From: Volker Christian Date: Mon, 31 Aug 2026 23:23:16 +0200 Subject: [PATCH 7/7] refactor(logging): remove legacy logging macros --- README.md | 166 ++++++++++-------- src/CMakeLists.txt | 6 + .../0001-add-express-compat-server.patch | 10 +- src/log/Logger.cpp | 19 -- src/log/Logger.h | 49 ------ tests/unit/log/CMakeLists.txt | 4 - tests/unit/log/SemanticEndToEndOutputTest.cpp | 28 +-- tests/unit/log/SemanticLoggerBackendTest.cpp | 6 +- .../log/SemanticLoggerCompatibilityTest.cpp | 117 ------------ .../unit/log/SemanticLoggerFilteringTest.cpp | 6 - 10 files changed, 119 insertions(+), 292 deletions(-) delete mode 100644 tests/unit/log/SemanticLoggerCompatibilityTest.cpp diff --git a/README.md b/README.md index 6076404338..ac00f974b6 100644 --- a/README.md +++ b/README.md @@ -299,7 +299,7 @@ Sending data to the client is done using the method `sendToPeer()`, which is als #include #include #include -#include +#include // #include #include @@ -310,15 +310,15 @@ public: private: void onConnected() override { // Called in case a connection has been established successfully. - VLOG(1) << "Echo connected to " << getSocketConnection()->getRemoteAddress().toString(); + snode::semantic::appLog().info() << "Echo connected to " << getSocketConnection()->getRemoteAddress().toString(); } void onDisconnected() override { // Called in case the connection has been closed. - VLOG(1) << "Echo disconnected from " << getSocketConnection()->getRemoteAddress().toString(); + snode::semantic::appLog().info() << "Echo disconnected from " << getSocketConnection()->getRemoteAddress().toString(); } bool onSignal(int signum) override { // Called in case a signal has been received - VLOG(1) << "Echo disconnected due to signal=" << signum; + snode::semantic::appLog().info() << "Echo disconnected due to signal=" << signum; return true; // Close the connection } @@ -333,7 +333,7 @@ private: // onReceivedFromPeer will be called again. // No error can occure here. if (chunkLen > 0) { - VLOG(1) << "Data to reflect: " << std::string(chunk, chunkLen); + snode::semantic::appLog().debug() << "Data to reflect: " << std::string(chunk, chunkLen); sendToPeer(chunk, chunkLen); // Reflect the received data back to the client. // Out of memory is the only error which can occure here. } @@ -353,7 +353,7 @@ And like in the `EchoServerContext`, `readFromPeer()` and `sendToPeer()` is used #include #include #include -#include +#include // #include #include @@ -364,18 +364,18 @@ public: private: void onConnected() override { // Called in case a connection has been established successfully. - VLOG(1) << "Echo connected to " << getSocketConnection()->getRemoteAddress().toString(); + snode::semantic::appLog().info() << "Echo connected to " << getSocketConnection()->getRemoteAddress().toString(); - VLOG(1) << "Initiating data exchange"; + snode::semantic::appLog().debug() << "Initiating data exchange"; sendToPeer("Hello peer! It's nice talking to you\n"); // Initiate the ping-pong data exchange. } void onDisconnected() override { // Called in case the connection has been closed. - VLOG(1) << "Echo disconnected from " << getSocketConnection()->getRemoteAddress().toString(); + snode::semantic::appLog().info() << "Echo disconnected from " << getSocketConnection()->getRemoteAddress().toString(); } bool onSignal(int signum) override { // Called in case a signal has been received - VLOG(1) << "Echo disconnected due to signal=" << signum; + snode::semantic::appLog().info() << "Echo disconnected due to signal=" << signum; return true; // Close the connection } @@ -390,7 +390,7 @@ private: // onReceivedFromPeer will be called again. // No error can occure here. if (chunkLen > 0) { - VLOG(1) << "Data to reflect: " << std::string(chunk, chunkLen); + snode::semantic::appLog().debug() << "Data to reflect: " << std::string(chunk, chunkLen); sendToPeer(chunk, chunkLen); // Reflect the received data back to the server. // Out of memory is the only error which can occure here. } @@ -429,6 +429,7 @@ Here we use IPv4 and the `listen()` method which expects a port number, here `80 ```cpp #include "EchoServerContextFactory.h" +#include #include #include // @@ -451,16 +452,16 @@ int main(int argc, char* argv[]) { echoServer.listen(8001, 5, [](const SocketAddress& socketAddress, const core::socket::State& state) -> void { switch (state) { case core::socket::State::OK: - VLOG(1) << "EchoServer: connected to '" << socketAddress.toString() << "'"; + snode::semantic::appLog().info() << "EchoServer: connected to '" << socketAddress.toString() << "'"; break; case core::socket::State::DISABLED: - VLOG(1) << "EchoServer: disabled"; + snode::semantic::appLog().info() << "EchoServer: disabled"; break; case core::socket::State::ERROR: - VLOG(1) << "EchoServer: " << socketAddress.toString() << ": " << state.what(); + snode::semantic::appLog().error() << "EchoServer: " << socketAddress.toString() << ": " << state.what(); break; case core::socket::State::FATAL: - VLOG(1) << "EchoServer: " << socketAddress.toString() << ": " << state.what(); + snode::semantic::appLog().critical() << "EchoServer: " << socketAddress.toString() << ": " << state.what(); break; } }); @@ -482,6 +483,7 @@ Here it is assumed that we talk to an IPv4 server which runs on the same machine ```cpp #include "EchoClientContextFactory.h" +#include #include #include // @@ -504,16 +506,16 @@ int main(int argc, char* argv[]) { echoClient.connect("localhost", 8001, [](const SocketAddress& socketAddress, const core::socket::State& state) -> void { switch (state) { case core::socket::State::OK: - VLOG(1) << "EchoClient: connected to '" << socketAddress.toString() << "'"; + snode::semantic::appLog().info() << "EchoClient: connected to '" << socketAddress.toString() << "'"; break; case core::socket::State::DISABLED: - VLOG(1) << "EchoClient: disabled"; + snode::semantic::appLog().info() << "EchoClient: disabled"; break; case core::socket::State::ERROR: - LOG(ERROR) << "EchoClient: " << socketAddress.toString() << ": " << state.what(); + snode::semantic::appLog().error() << "EchoClient: " << socketAddress.toString() << ": " << state.what(); break; case core::socket::State::FATAL: - LOG(FATAL) << "EchoClient: " << socketAddress.toString() << ": " << state.what(); + snode::semantic::appLog().critical() << "EchoClient: " << socketAddress.toString() << ": " << state.what(); break; } }); @@ -1146,18 +1148,20 @@ As the name suggests this callback is executed after a connection to the peer ha For a concrete `SocketServer` instance (here an anonymous instance) the constructors expecting callbacks can be used like ```cpp +#include + using EchoServer = net::in::stream::legacy::SocketServer; using SocketAddress = EchoServer::SocketAddress; using SocketConnection = EchoServer::SocketConnection; EchoServer echoServer([] (SocketConnection* socketConnection) -> void { - VLOG(1) << "Connection to peer estableshed"; + snode::semantic::appLog().debug() << "Connection to peer estableshed"; }, [] (SocketConnection* socketConnection) -> void { - VLOG(1) << "Connection to peer ready to be used"; + snode::semantic::appLog().debug() << "Connection to peer ready to be used"; }, [] (SocketConnection* socketConnection) -> void { - VLOG(1) << "Connection to peer closed"; + snode::semantic::appLog().debug() << "Connection to peer closed"; }); echoServer.listen(...); @@ -1166,18 +1170,20 @@ echoServer.listen(...); and for a concrete `SocketClient` class like ```cpp +#include + using EchoClient = net::in::stream::legacy::SocketServer; using SocketAddress = EchoClient::SocketAddress; using SocketConnection = EchoClient::SocketConnection; EchoClient echoClient([] (SocketConnection* socketConnection) -> void { - VLOG(1) << "Connection to peer estableshed"; + snode::semantic::appLog().debug() << "Connection to peer estableshed"; }, [] (SocketConnection* socketConnection) -> void { - VLOG(1) << "Connection to peer ready to be used"; + snode::semantic::appLog().debug() << "Connection to peer ready to be used"; }, [] (SocketConnection* socketConnection) -> void { - VLOG(1) << "Connection to peer closed"; + snode::semantic::appLog().debug() << "Connection to peer closed"; }); echoClient.connect(...); @@ -1194,6 +1200,8 @@ In case `SocketServer` and `SocketClient` instances have been created using a co like for example ```cpp +#include + using EchoServer = net::in::stream::legacy::SocketServer; using SocketAddress = EchoServer::SocketAddress; using SocketConnection = EchoServer::SocketConnection; @@ -1201,15 +1209,15 @@ using SocketConnection = EchoServer::SocketConnection; EchoServer echoServer; echoServer.setOnConnect([] (SocketConnection* socketConnection) -> void { - VLOG(1) << "Connection to peer established"; + snode::semantic::appLog().debug() << "Connection to peer established"; }); echoServer.setOnConnected([] (SocketConnection* socketConnection) -> void { - VLOG(1) << "Connection to peer ready to be used"; + snode::semantic::appLog().debug() << "Connection to peer ready to be used"; }); echoServer.setOnDisconnected([] (SocketConnection* socketConnection) -> void { - VLOG(1) << "Connection to peer closed"; + snode::semantic::appLog().debug() << "Connection to peer closed"; }); echoServer.listen(...); @@ -1218,6 +1226,8 @@ echoServer.listen(...); and ```cpp +#include + using EchoClient = net::in::stream::legacy::SocketServer; using SocketAddress = EchoClient::SocketAddress; using SocketConnection = EchoClient::SocketConnection; @@ -1225,15 +1235,15 @@ using SocketConnection = EchoClient::SocketConnection; EchoClient echoClient; echoClient.setOnConnect([] (SocketConnection* socketConnection) -> void { - VLOG(1) << "Connection to peer established"; + snode::semantic::appLog().debug() << "Connection to peer established"; }); echoClient.setOnConnected([] (SocketConnection* socketConnection) -> void { - VLOG(1) << "Connection to peer ready to be used"; + snode::semantic::appLog().debug() << "Connection to peer ready to be used"; }); echoClient.setOnDisconnected([] (SocketConnection* socketConnection) -> void { - VLOG(1) << "Connection to peer closed"; + snode::semantic::appLog().debug() << "Connection to peer closed"; }); echoClient.connect(...); @@ -2430,7 +2440,9 @@ For instance, if the echo server shall also communicate via e.g. Unix-Domain soc In that case the Main-Application would look like ```cpp - int main(int argc, char* argv[]) { +#include + +int main(int argc, char* argv[]) { core::SNodeC::init(argc, argv); using EchoServerIn = net::in::stream::legacy::SocketServer; @@ -2442,16 +2454,16 @@ In that case the Main-Application would look like const core::socket::State& state) -> void { switch (state) { case core::socket::State::OK: - VLOG(1) << "EchoServerIn: listening on '" << socketAddress.toString() << "'"; + snode::semantic::appLog().info() << "EchoServerIn: listening on '" << socketAddress.toString() << "'"; break; case core::socket::State::DISABLED: - VLOG(1) << "EchoServerIn: disabled"; + snode::semantic::appLog().info() << "EchoServerIn: disabled"; break; case core::socket::State::ERROR: - LOG(ERROR) << "EchoServerIn: " << socketAddress.toString() << ": " << state.what(); + snode::semantic::appLog().error() << "EchoServerIn: " << socketAddress.toString() << ": " << state.what(); break; case core::socket::State::FATAL: - LOG(FATAL) << "EchoServerIn: " << socketAddress.toString() << ": " << state.what(); + snode::semantic::appLog().critical() << "EchoServerIn: " << socketAddress.toString() << ": " << state.what(); break; } }); @@ -2465,16 +2477,16 @@ In that case the Main-Application would look like const core::socket::State& state) -> void { switch (state) { case core::socket::State::OK: - VLOG(1) << "EchoServerUn: listening on '" << socketAddress.toString() << "'"; + snode::semantic::appLog().info() << "EchoServerUn: listening on '" << socketAddress.toString() << "'"; break; case core::socket::State::DISABLED: - VLOG(1) << "EchoServerUn: disabled"; + snode::semantic::appLog().info() << "EchoServerUn: disabled"; break; case core::socket::State::ERROR: - LOG(ERROR) << "EchoServerUn: " << socketAddress.toString() << ": " << state.what(); + snode::semantic::appLog().error() << "EchoServerUn: " << socketAddress.toString() << ": " << state.what(); break; case core::socket::State::FATAL: - LOG(FATAL) << "EchoServerUn: " << socketAddress.toString() << ": " << state.what(); + snode::semantic::appLog().critical() << "EchoServerUn: " << socketAddress.toString() << ": " << state.what(); break; } }); @@ -2493,16 +2505,16 @@ In that case the Main-Application would look like const core::socket::State& state) -> void { switch (state) { case core::socket::State::OK: - VLOG(1) << "EchoServerRc: listening on '" << socketAddress.toString() << "'"; + snode::semantic::appLog().info() << "EchoServerRc: listening on '" << socketAddress.toString() << "'"; break; case core::socket::State::DISABLED: - VLOG(1) << "EchoServerRc: disabled"; + snode::semantic::appLog().info() << "EchoServerRc: disabled"; break; case core::socket::State::ERROR: - LOG(ERROR) << "EchoServerRc: " << socketAddress.toString() << ": " << state.what(); + snode::semantic::appLog().error() << "EchoServerRc: " << socketAddress.toString() << ": " << state.what(); break; case core::socket::State::FATAL: - LOG(FATAL) << "EchoServerRc: " << socketAddress.toString() << ": " << state.what(); + snode::semantic::appLog().critical() << "EchoServerRc: " << socketAddress.toString() << ": " << state.what(); break; } }); @@ -2514,6 +2526,8 @@ In that case the Main-Application would look like and the client application with an additional Unix-Domain socket instance look like ```cpp +#include + int main(int argc, char* argv[]) { core::SNodeC::init(argc, argv); @@ -2528,16 +2542,16 @@ int main(int argc, char* argv[]) { const core::socket::State& state) -> void { switch (state) { case core::socket::State::OK: - VLOG(1) << "EchoClientIn: connected to '" << socketAddress.toString() << "'"; + snode::semantic::appLog().info() << "EchoClientIn: connected to '" << socketAddress.toString() << "'"; break; case core::socket::State::DISABLED: - VLOG(1) << "EchoClientIn: disabled"; + snode::semantic::appLog().info() << "EchoClientIn: disabled"; break; case core::socket::State::ERROR: - LOG(ERROR) << "EchoClientIn: " << socketAddress.toString() << ": " << state.what(); + snode::semantic::appLog().error() << "EchoClientIn: " << socketAddress.toString() << ": " << state.what(); break; case core::socket::State::FATAL: - LOG(FATAL) << "EchoClientIn: " << socketAddress.toString() << ": " << state.what(); + snode::semantic::appLog().critical() << "EchoClientIn: " << socketAddress.toString() << ": " << state.what(); break; } }); @@ -2552,16 +2566,16 @@ int main(int argc, char* argv[]) { const core::socket::State& state) -> void { switch (state) { case core::socket::State::OK: - VLOG(1) << "EchoClientUn: connected to '" << socketAddress.toString() << "'"; + snode::semantic::appLog().info() << "EchoClientUn: connected to '" << socketAddress.toString() << "'"; break; case core::socket::State::DISABLED: - VLOG(1) << "EchoClientUn: disabled"; + snode::semantic::appLog().info() << "EchoClientUn: disabled"; break; case core::socket::State::ERROR: - LOG(ERROR) << "EchoClientUn: " << socketAddress.toString() << ": " << state.what(); + snode::semantic::appLog().error() << "EchoClientUn: " << socketAddress.toString() << ": " << state.what(); break; case core::socket::State::FATAL: - LOG(FATAL) << "EchoClientUn: " << socketAddress.toString() << ": " << state.what(); + snode::semantic::appLog().critical() << "EchoClientUn: " << socketAddress.toString() << ": " << state.what(); break; } }); @@ -2582,16 +2596,16 @@ int main(int argc, char* argv[]) { const core::socket::State& state) -> void { switch (state) { case core::socket::State::OK: - VLOG(1) << "EchoClientRc: connected to '" << socketAddress.toString() << "'"; + snode::semantic::appLog().info() << "EchoClientRc: connected to '" << socketAddress.toString() << "'"; break; case core::socket::State::DISABLED: - VLOG(1) << "EchoClientRc: disabled"; + snode::semantic::appLog().info() << "EchoClientRc: disabled"; break; case core::socket::State::ERROR: - LOG(ERROR) << "EchoClientRc: " << socketAddress.toString() << ": " << state.what(); + snode::semantic::appLog().error() << "EchoClientRc: " << socketAddress.toString() << ": " << state.what(); break; case core::socket::State::FATAL: - LOG(FATAL) << "EchoClientRc: " << socketAddress.toString() << ": " << state.what(); + snode::semantic::appLog().critical() << "EchoClientRc: " << socketAddress.toString() << ": " << state.what(); break; } }); @@ -2642,7 +2656,7 @@ The use of X.509 certificates for encrypted communication is demonstrated also. #include #include #include -#include +#include #include int main(int argc, char* argv[]) { @@ -2662,23 +2676,23 @@ int main(int argc, char* argv[]) { configLegacyApp.required(legacyHtmlRoot); legacyApp.setOnConnected([legacyApp, legacyHtmlRoot](SocketConnection* socketConnection) -> void { // onConnect - LOG(INFO) << "OnConnected " << legacyApp.getConfig().getInstanceName(); + snode::semantic::appLog().info() << "OnConnected " << legacyApp.getConfig().getInstanceName(); legacyApp.use(express::middleware::StaticMiddleware(legacyHtmlRoot->as())); }); legacyApp.listen(8080, [](const SocketAddressRc& socketAddress, const core::socket::State& state) -> void { switch (state) { case core::socket::State::OK: - VLOG(1) << "LegacyWebApp: listening on '" << socketAddress.toString() << "'"; + snode::semantic::appLog().info() << "LegacyWebApp: listening on '" << socketAddress.toString() << "'"; break; case core::socket::State::DISABLED: - VLOG(1) << "LegacyWebApp: disabled"; + snode::semantic::appLog().info() << "LegacyWebApp: disabled"; break; case core::socket::State::ERROR: - VLOG(1) << "LegacyWebApp: non critical error occurred"; + snode::semantic::appLog().warn() << "LegacyWebApp: non critical error occurred"; break; case core::socket::State::FATAL: - VLOG(1) << "LegacyWebApp: critical error occurred"; + snode::semantic::appLog().error() << "LegacyWebApp: critical error occurred"; break; } }); @@ -2695,7 +2709,7 @@ int main(int argc, char* argv[]) { configTlsApp.required(tlsHtmlRoot); tlsApp.setOnConnected([tlsApp, tlsHtmlRoot](SocketConnection* socketConnection) -> void { // onConnect - LOG(INFO) << "OnConnected " << tlsApp.getConfig().getInstanceName(); + snode::semantic::appLog().info() << "OnConnected " << tlsApp.getConfig().getInstanceName(); tlsApp.use(express::middleware::StaticMiddleware(tlsHtmlRoot->as())); }); @@ -2706,16 +2720,16 @@ int main(int argc, char* argv[]) { tlsApp.listen(8088, [](const SocketAddressRc& socketAddress, const core::socket::State& state) -> void { switch (state) { case core::socket::State::OK: - VLOG(1) << "TLSWebApp: listening on '" << socketAddress.toString() << "'"; + snode::semantic::appLog().info() << "TLSWebApp: listening on '" << socketAddress.toString() << "'"; break; case core::socket::State::DISABLED: - VLOG(1) << "TLSWebApp: disabled"; + snode::semantic::appLog().info() << "TLSWebApp: disabled"; break; case core::socket::State::ERROR: - VLOG(1) << "TLSWebApp: non critical error occurred"; + snode::semantic::appLog().warn() << "TLSWebApp: non critical error occurred"; break; case core::socket::State::FATAL: - VLOG(1) << "TLSWebApp: critical error occurred"; + snode::semantic::appLog().error() << "TLSWebApp: critical error occurred"; break; } }); @@ -2731,7 +2745,7 @@ The high-level web API provides the methods `get()`, `post()`, `put()`, etc like ```cpp #include #include -#include +#include int main(int argc, char* argv[]) { express::WebApp::init(argc, argv); @@ -2792,16 +2806,16 @@ int main(int argc, char* argv[]) { legacyApp.listen(8080, [](const SocketAddressRc& socketAddress, const core::socket::State& state) -> void { switch (state) { case core::socket::State::OK: - VLOG(1) << "LegacyWebApp: listening on '" << socketAddress.toString() << "'"; + snode::semantic::appLog().info() << "LegacyWebApp: listening on '" << socketAddress.toString() << "'"; break; case core::socket::State::DISABLED: - VLOG(1) << "LegacyWebApp: disabled"; + snode::semantic::appLog().info() << "LegacyWebApp: disabled"; break; case core::socket::State::ERROR: - VLOG(1) << "LegacyWebApp: non critical error occurred"; + snode::semantic::appLog().warn() << "LegacyWebApp: non critical error occurred"; break; case core::socket::State::FATAL: - VLOG(1) << "LegacyWebApp: critical error occurred"; + snode::semantic::appLog().error() << "LegacyWebApp: critical error occurred"; break; } }); @@ -2820,16 +2834,16 @@ int main(int argc, char* argv[]) { tlsApp.listen(8088, [](const SocketAddressRc& socketAddress, const core::socket::State& state) -> void { switch (state) { case core::socket::State::OK: - VLOG(1) << "TLSWebApp: listening on '" << socketAddress.toString() << "'"; + snode::semantic::appLog().info() << "TLSWebApp: listening on '" << socketAddress.toString() << "'"; break; case core::socket::State::DISABLED: - VLOG(1) << "TLSWebApp: disabled"; + snode::semantic::appLog().info() << "TLSWebApp: disabled"; break; case core::socket::State::ERROR: - VLOG(1) << "TLSWebApp: non critical error occurred"; + snode::semantic::appLog().warn() << "TLSWebApp: non critical error occurred"; break; case core::socket::State::FATAL: - VLOG(1) << "TLSWebApp: critical error occurred"; + snode::semantic::appLog().error() << "TLSWebApp: critical error occurred"; break; } }); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4ea62ade7d..b7a4818b55 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -157,3 +157,9 @@ snodec_finalize_components( PACKAGE_VERSION "${SNode.C_VERSION_MAJOR}.${SNode.C_VERSION_MINOR}.${SNode.C_VERSION_PATCH}" ) + +install( + FILES "${CMAKE_CURRENT_SOURCE_DIR}/SemanticLog.h" + DESTINATION include/snode.c + COMPONENT "logger" +) diff --git a/src/express/express-compat-suite/snodec/0001-add-express-compat-server.patch b/src/express/express-compat-suite/snodec/0001-add-express-compat-server.patch index 8a99401b3b..37b8f303e3 100644 --- a/src/express/express-compat-suite/snodec/0001-add-express-compat-server.patch +++ b/src/express/express-compat-suite/snodec/0001-add-express-compat-server.patch @@ -27,7 +27,7 @@ new file mode 100644 +#include "express/Response.h" +#include "express/Router.h" +#include "express/legacy/in/WebApp.h" -+#include "log/Logger.h" ++#include "SemanticLog.h" + +#include + @@ -263,16 +263,16 @@ new file mode 100644 + [](const express::legacy::in::WebApp::SocketAddress& socketAddress, const core::socket::State& state) { + switch (state) { + case core::socket::State::OK: -+ VLOG(1) << "express-compat listening on '" << socketAddress.toString() << "'"; ++ snode::semantic::appLog().info() << "express-compat listening on '" << socketAddress.toString() << "'"; + break; + case core::socket::State::DISABLED: -+ VLOG(1) << "express-compat disabled"; ++ snode::semantic::appLog().info() << "express-compat disabled"; + break; + case core::socket::State::ERROR: -+ LOG(ERROR) << "express-compat " << socketAddress.toString() << ": " << state.what(); ++ snode::semantic::appLog().error() << "express-compat " << socketAddress.toString() << ": " << state.what(); + break; + case core::socket::State::FATAL: -+ LOG(FATAL) << "express-compat " << socketAddress.toString() << ": " << state.what(); ++ snode::semantic::appLog().critical() << "express-compat " << socketAddress.toString() << ": " << state.what(); + break; + } + }); diff --git a/src/log/Logger.cpp b/src/log/Logger.cpp index 38bce567c5..bcfd5128c0 100644 --- a/src/log/Logger.cpp +++ b/src/log/Logger.cpp @@ -46,7 +46,6 @@ #include "log/SemanticLogger.h" #include "log/detail/SpdlogBackend.h" -#include #include #endif /* DOXYGEN_SHOULD_SKIP_THIS */ @@ -127,24 +126,6 @@ namespace logger { bool Logger::disableColorLog = false; - LogMessage::LogMessage(const Level level, const int verboseLevel, const bool withErrno) - : level(level) - , verboseLevel(verboseLevel) - , withErrno(withErrno) - , enabled(true) - , errnoValue(errno) { - } - - LogMessage::~LogMessage() { - if (enabled) { - backend.emitLegacy(level, message.str(), withErrno, errnoValue); - } - } - - std::ostringstream& LogMessage::stream() { - return message; - } - } // namespace logger std::ostream& Color::operator<<(std::ostream& os, const Code& code) { diff --git a/src/log/Logger.h b/src/log/Logger.h index 9a0d5412d5..f0eeafccc0 100644 --- a/src/log/Logger.h +++ b/src/log/Logger.h @@ -49,7 +49,6 @@ #include #include #include // IWYU pragma: export -#include #include #endif /* DOXYGEN_SHOULD_SKIP_THIS */ @@ -122,54 +121,6 @@ namespace logger { friend std::string Color::operator+(const Color::Code& code, const std::string& string); }; - class LogMessage { - public: - LogMessage(Level level, int verboseLevel = -1, bool withErrno = false); - ~LogMessage(); - - std::ostringstream& stream(); - - private: - Level level; - int verboseLevel; - bool withErrno; - bool enabled; - int errnoValue; - std::ostringstream message; - }; - } // namespace logger -#ifdef SNODEC_DISABLE_LOGLEVEL_LOGGING -#define LOG(level) \ - if (true) { \ - } else \ - ::logger::LogMessage(::logger::Level::level).stream() -#define PLOG(level) \ - if (true) { \ - } else \ - ::logger::LogMessage(::logger::Level::level, -1, true).stream() -#else -#define LOG(level) \ - if (!::logger::Logger::shouldLog(::logger::Level::level)) { \ - } else \ - ::logger::LogMessage(::logger::Level::level).stream() -#define PLOG(level) \ - if (!::logger::Logger::shouldLog(::logger::Level::level)) { \ - } else \ - ::logger::LogMessage(::logger::Level::level, -1, true).stream() -#endif - -#ifdef SNODEC_DISABLE_VERBOSE_LOGGING -#define VLOG(level) \ - if (true) { \ - } else \ - ::logger::LogMessage(::logger::Level::VERBOSE, level).stream() -#else -#define VLOG(level) \ - if (!::logger::Logger::shouldVerbose(level)) { \ - } else \ - ::logger::LogMessage(::logger::Level::VERBOSE, level).stream() -#endif - #endif // LOGGER_LOGGER_H diff --git a/tests/unit/log/CMakeLists.txt b/tests/unit/log/CMakeLists.txt index 1d03ae3a21..942447912d 100644 --- a/tests/unit/log/CMakeLists.txt +++ b/tests/unit/log/CMakeLists.txt @@ -25,10 +25,6 @@ snodec_add_log_test(SemanticLoggerFilteringTest) target_link_libraries(SemanticLoggerFilteringTest PRIVATE snodec-test-support snodec::net snodec::core-socket-stream) set_property(TEST SemanticLoggerFilteringTest APPEND PROPERTY LABELS "filter") -snodec_add_log_test(SemanticLoggerCompatibilityTest) -target_link_libraries(SemanticLoggerCompatibilityTest PRIVATE snodec-test-support snodec::logger) -set_property(TEST SemanticLoggerCompatibilityTest APPEND PROPERTY LABELS "compatibility;legacy") - snodec_add_log_test(SemanticLoggerDisabledPathTest) target_link_libraries(SemanticLoggerDisabledPathTest PRIVATE snodec-test-support snodec::net snodec::core-socket-stream) set_property(TEST SemanticLoggerDisabledPathTest APPEND PROPERTY LABELS "overhead") diff --git a/tests/unit/log/SemanticEndToEndOutputTest.cpp b/tests/unit/log/SemanticEndToEndOutputTest.cpp index 8eba22a88f..52bcb42470 100644 --- a/tests/unit/log/SemanticEndToEndOutputTest.cpp +++ b/tests/unit/log/SemanticEndToEndOutputTest.cpp @@ -132,23 +132,23 @@ int main() { } } - const auto legacyPath = tempLogPath("snodec-semantic-e2e-legacy.log"); + const auto helperPath = tempLogPath("snodec-semantic-e2e-helper.log"); { - LoggerStateGuard guard(legacyPath); - LOG(INFO) << "legacy info still works"; - errno = EACCES; - PLOG(ERROR) << "legacy plog still works"; + LoggerStateGuard guard(helperPath); + snode::semantic::appLog().info() << "semantic info works"; + snode::semantic::sysError(snode::semantic::appLog(), logger::LogLevel::Error, EACCES) + << "semantic system error works"; } - const auto legacyLines = readLines(legacyPath); - std::ostringstream legacyLog; - for (const auto& line : legacyLines) { - legacyLog << line << '\n'; + const auto helperLines = readLines(helperPath); + std::ostringstream helperLog; + for (const auto& line : helperLines) { + helperLog << line << '\n'; } - result.expectTrue(contains(legacyLog.str(), "INFO") && contains(legacyLog.str(), "legacy info still works"), - "legacy LOG still emits through the legacy path"); - result.expectTrue(contains(legacyLog.str(), "ERROR") && contains(legacyLog.str(), "legacy plog still works") && - contains(legacyLog.str(), "Permission denied"), - "legacy PLOG still appends errno text through the legacy path"); + result.expectTrue(contains(helperLog.str(), "INFO") && contains(helperLog.str(), "semantic info works"), + "semantic application helper emits through the backend"); + result.expectTrue(contains(helperLog.str(), "ERROR") && contains(helperLog.str(), "semantic system error works") && + contains(helperLog.str(), "Permission denied"), + "semantic sysError appends explicit error text"); std::vector identityRecords; auto identityLog = snode::semantic::coreSocketLog( diff --git a/tests/unit/log/SemanticLoggerBackendTest.cpp b/tests/unit/log/SemanticLoggerBackendTest.cpp index adcc639ef0..b51f355694 100644 --- a/tests/unit/log/SemanticLoggerBackendTest.cpp +++ b/tests/unit/log/SemanticLoggerBackendTest.cpp @@ -1,3 +1,4 @@ +#include "SemanticLog.h" #include "core/socket/SocketAddress.h" #include "core/socket/stream/SocketConnection.h" #include "core/socket/stream/SocketContext.h" @@ -166,14 +167,15 @@ int main() { LoggerStateGuard guard(semanticPath.string()); logger::Logger::emitSemantic(record(logger::LogLevel::Info, "semantic info emitted")); logger::Logger::emitSemantic(record(logger::LogLevel::Off, "semantic off hidden")); - LOG(INFO) << "legacy macro emitted"; + snode::semantic::appLog().info() << "semantic helper emitted"; } const auto semanticLog = readFile(semanticPath); result.expectTrue(semanticLog.find("INFO") != std::string::npos, "semantic info maps to legacy INFO label"); result.expectTrue(semanticLog.find("semantic info emitted") != std::string::npos, "semantic info emits through file backend"); result.expectTrue(semanticLog.find("semantic off hidden") == std::string::npos, "semantic off emits nothing"); result.expectTrue(semanticLog.find("BACKENDTICK000") != std::string::npos, "semantic emission uses legacy tick resolver pattern"); - result.expectTrue(semanticLog.find("legacy macro emitted") != std::string::npos, "legacy LOG macro still emits through backend"); + result.expectTrue(semanticLog.find("semantic helper emitted") != std::string::npos, + "semantic application helper emits through backend"); const auto filteredPath = tempLogPath("snodec-backend-filtered.log"); { diff --git a/tests/unit/log/SemanticLoggerCompatibilityTest.cpp b/tests/unit/log/SemanticLoggerCompatibilityTest.cpp deleted file mode 100644 index c35faab4a0..0000000000 --- a/tests/unit/log/SemanticLoggerCompatibilityTest.cpp +++ /dev/null @@ -1,117 +0,0 @@ -#include "log/Logger.h" -#include "log/SemanticLogger.h" -#include "tests/support/TestResult.h" - -#include -#include -#include -#include -#include -#include - -namespace { - class StateGuard { - public: - explicit StateGuard(const std::string& logFile) - : savedErrno(errno) { - logger::Logger::init(); - logger::LogManager::init(); - logger::Logger::setLogLevel(6); - logger::Logger::setVerboseLevel(0); - logger::Logger::setQuiet(true); - logger::Logger::setDisableColor(true); - logger::Logger::logToFile(logFile); - } - - ~StateGuard() { - logger::Logger::disableLogToFile(); - logger::Logger::init(); - logger::LogManager::init(); - errno = savedErrno; - } - - private: - int savedErrno; - }; - - std::filesystem::path tempLogPath(const std::string& name) { - auto path = std::filesystem::temp_directory_path() / name; - std::error_code error; - std::filesystem::remove(path, error); - std::filesystem::remove(path.string() + ".1", error); - return path; - } - - std::string readFile(const std::filesystem::path& path) { - std::ifstream input(path); - return std::string(std::istreambuf_iterator(input), std::istreambuf_iterator()); - } - - logger::LogScope scope() { - return {logger::LogOrigin::Framework, - logger::LogBoundary::System, - "compatibility.component", - "compatibility-instance", - logger::LogRole::Server, - "compatibility-connection"}; - } - - std::chrono::system_clock::time_point fixedTimestamp() { - return std::chrono::system_clock::time_point{std::chrono::seconds{1783254896}}; - } -} // namespace - -int main() { - tests::support::TestResult result; - - const auto legacyPath = tempLogPath("snodec-semantic-compatibility-legacy.log"); - { - StateGuard guard(legacyPath.string()); - LOG(INFO) << "legacy info"; - errno = EACCES; - PLOG(ERROR) << "legacy plog"; - logger::Logger::setVerboseLevel(1); - logger::Logger::setLogLevel(3); - LOG(INFO) << "numeric info hidden"; - LOG(WARNING) << "numeric warning visible"; - } - const std::string legacyLog = readFile(legacyPath); - result.expectTrue(legacyLog.find("legacy info") != std::string::npos, "legacy LOG remains functional"); - result.expectTrue(legacyLog.find("legacy plog") != std::string::npos && - legacyLog.find("Permission denied") != std::string::npos, - "legacy PLOG remains functional and preserves errno text"); - result.expectTrue(legacyLog.find("numeric info hidden") == std::string::npos && - legacyLog.find("numeric warning visible") != std::string::npos, - "legacy numeric thresholds retain their behavior"); - - const auto semanticOffPath = tempLogPath("snodec-semantic-compatibility-off.log"); - { - StateGuard guard(semanticOffPath.string()); - logger::LogManager::setGlobalLevel(logger::LogLevel::Off); - logger::LogManager::freeze(); - LOG(ERROR) << "legacy unaffected by semantic off"; - logger::BoundaryLogger::createForTest(scope(), logger::Logger::semanticSink(), logger::LogLevel::Off, fixedTimestamp) - .error("semantic filtered by off"); - } - const std::string semanticOffLog = readFile(semanticOffPath); - result.expectTrue(semanticOffLog.find("legacy unaffected by semantic off") != std::string::npos && - semanticOffLog.find("semantic filtered by off") == std::string::npos, - "semantic Off does not disable legacy output"); - - const auto coexistencePath = tempLogPath("snodec-semantic-compatibility-coexistence.log"); - { - StateGuard guard(coexistencePath.string()); - logger::LogManager::setGlobalLevel(logger::LogLevel::Trace); - logger::LogManager::freeze(); - logger::Logger::setLogLevel(2); - LOG(INFO) << "legacy info remains filtered"; - logger::BoundaryLogger::createForTest(scope(), logger::Logger::semanticSink(), logger::LogLevel::Trace, fixedTimestamp) - .info("accepted semantic info"); - } - const std::string coexistenceLog = readFile(coexistencePath); - result.expectTrue(coexistenceLog.find("legacy info remains filtered") == std::string::npos && - coexistenceLog.find("accepted semantic info") != std::string::npos, - "legacy thresholds do not re-filter accepted semantic records"); - - return result.processResult(); -} diff --git a/tests/unit/log/SemanticLoggerFilteringTest.cpp b/tests/unit/log/SemanticLoggerFilteringTest.cpp index 1c45c50b3e..0d9c00f186 100644 --- a/tests/unit/log/SemanticLoggerFilteringTest.cpp +++ b/tests/unit/log/SemanticLoggerFilteringTest.cpp @@ -178,17 +178,11 @@ int main() { logger::Logger::setLogLevel(3); logger::Logger::emitSemantic(record(logger::LogLevel::Info, "backend info hidden")); logger::Logger::emitSemantic(record(logger::LogLevel::Warn, "backend warn visible")); - LOG(INFO) << "legacy info hidden"; - LOG(WARNING) << "legacy warning visible"; } const auto gateLog = readFile(gatePath); result.expectTrue(gateLog.find("backend info hidden") != std::string::npos, "semantic records accepted by LogManager are not double-gated by Logger::setLogLevel"); result.expectTrue(gateLog.find("backend warn visible") != std::string::npos, "semantic warning still emits after semantic filtering"); - result.expectTrue(gateLog.find("legacy info hidden") == std::string::npos && - gateLog.find("legacy warning visible") != std::string::npos, - "legacy LOG macro behavior remains unchanged"); - const auto jsonPath = tempLogPath("snodec-filtering-json-format.log"); { LoggerStateGuard guard(jsonPath.string());