From 11e14106c9fd064e6597b25ccdf338a352fa92f4 Mon Sep 17 00:00:00 2001 From: Ben Deane Date: Thu, 5 Sep 2024 15:11:40 -0600 Subject: [PATCH 1/2] :construction_worker: Use `target_sources` for CIB FILE_SETs --- CMakeLists.txt | 173 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 172 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7174d6a7..1cd68ff4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,10 +30,181 @@ add_versioned_package("gh:intel/cpp-baremetal-senders-and-receivers#113eeff") add_library(cib INTERFACE) target_compile_features(cib INTERFACE cxx_std_20) -target_include_directories(cib INTERFACE include) target_link_libraries_system(cib INTERFACE async concurrency fmt::fmt-header-only stdx) +target_sources( + cib + INTERFACE FILE_SET + cib + TYPE + HEADERS + BASE_DIRS + include + FILES + include/cib/builder_meta.hpp + include/cib/built.hpp + include/cib/callback.hpp + include/cib/cib.hpp + include/cib/config.hpp + include/cib/detail/components.hpp + include/cib/detail/conditional.hpp + include/cib/detail/config_details.hpp + include/cib/detail/config_item.hpp + include/cib/detail/exports.hpp + include/cib/detail/extend.hpp + include/cib/detail/nexus_details.hpp + include/cib/func_decl.hpp + include/cib/nexus.hpp + include/cib/top.hpp) + +target_sources( + cib + INTERFACE FILE_SET + flow + TYPE + HEADERS + BASE_DIRS + include + FILES + include/flow/builder.hpp + include/flow/common.hpp + include/flow/detail/par.hpp + include/flow/detail/seq.hpp + include/flow/detail/walk.hpp + include/flow/flow.hpp + include/flow/graph_builder.hpp + include/flow/graphviz_builder.hpp + include/flow/impl.hpp + include/flow/run.hpp + include/flow/step.hpp) + +target_sources( + cib + INTERFACE FILE_SET + interrupt + TYPE + HEADERS + BASE_DIRS + include + FILES + include/interrupt/concepts.hpp + include/interrupt/config.hpp + include/interrupt/dynamic_controller.hpp + include/interrupt/fwd.hpp + include/interrupt/hal.hpp + include/interrupt/impl.hpp + include/interrupt/manager.hpp + include/interrupt/policies.hpp) + +target_sources( + cib + INTERFACE FILE_SET + log + TYPE + HEADERS + BASE_DIRS + include + FILES + include/log/catalog/catalog.hpp + include/log/catalog/mipi_encoder.hpp + include/log/fmt/logger.hpp + include/log/level.hpp + include/log/log.hpp) + +target_sources( + cib + INTERFACE FILE_SET + lookup + TYPE + HEADERS + BASE_DIRS + include + FILES + include/lookup/detail/select.hpp + include/lookup/entry.hpp + include/lookup/input.hpp + include/lookup/linear_search_lookup.hpp + include/lookup/lookup.hpp + include/lookup/pseudo_pext_lookup.hpp + include/lookup/strategies.hpp + include/lookup/strategy_failed.hpp) + +target_sources( + cib + INTERFACE FILE_SET + match + TYPE + HEADERS + BASE_DIRS + include + FILES + include/match/and.hpp + include/match/bin_op.hpp + include/match/concepts.hpp + include/match/constant.hpp + include/match/cost.hpp + include/match/implies.hpp + include/match/negate.hpp + include/match/not.hpp + include/match/ops.hpp + include/match/or.hpp + include/match/predicate.hpp + include/match/simplify.hpp + include/match/sum_of_products.hpp) + +target_sources( + cib + INTERFACE FILE_SET + msg + TYPE + HEADERS + BASE_DIRS + include + FILES + include/msg/callback.hpp + include/msg/detail/indexed_builder_common.hpp + include/msg/detail/indexed_handler_common.hpp + include/msg/detail/separate_sum_terms.hpp + include/msg/field.hpp + include/msg/field_matchers.hpp + include/msg/handler_builder.hpp + include/msg/handler.hpp + include/msg/handler_interface.hpp + include/msg/indexed_builder.hpp + include/msg/indexed_handler.hpp + include/msg/indexed_service.hpp + include/msg/message.hpp + include/msg/send.hpp + include/msg/service.hpp) + +target_sources( + cib + INTERFACE FILE_SET + sc + TYPE + HEADERS + BASE_DIRS + include + FILES + include/sc/format.hpp + include/sc/fwd.hpp + include/sc/lazy_string_format.hpp + include/sc/string_constant.hpp) + +target_sources( + cib + INTERFACE FILE_SET + seq + TYPE + HEADERS + BASE_DIRS + include + FILES + include/seq/builder.hpp + include/seq/impl.hpp + include/seq/step.hpp) + target_compile_options( cib INTERFACE From 1220284a5159a1ce1848449800e1735cc8993b22 Mon Sep 17 00:00:00 2001 From: Ben Deane Date: Thu, 5 Sep 2024 15:12:17 -0600 Subject: [PATCH 2/2] :construction_worker: Move release header creation to a function --- CMakeLists.txt | 52 +++++++++++++++++++-------------------- cmake/single_header.cmake | 17 +++++++++++++ 2 files changed, 43 insertions(+), 26 deletions(-) create mode 100644 cmake/single_header.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 1cd68ff4..0e36ed04 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -221,32 +221,32 @@ if(PROJECT_IS_TOP_LEVEL) add_subdirectory(tools) # Build single-header release. - file(GLOB_RECURSE include_files - "${CMAKE_CURRENT_SOURCE_DIR}/include/cib/*.hpp") - add_custom_command( - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/tools/gen_release_header.py - ${include_files} - COMMAND ${CMAKE_COMMAND} -E make_directory - ${CMAKE_CURRENT_BINARY_DIR}/include/cib - COMMAND - ${Python3_EXECUTABLE} - ${CMAKE_CURRENT_SOURCE_DIR}/tools/gen_release_header.py - ${CMAKE_CURRENT_SOURCE_DIR}/include/cib/cib.hpp > - ${CMAKE_CURRENT_BINARY_DIR}/include/cib/cib.hpp - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/include/cib/cib.hpp) - - add_custom_target(release_header - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/include/cib/cib.hpp) -endif() - -if(DEFINED ENV{SINGLE_HEADER}) - add_dependencies(cib release_header) - - target_include_directories( - cib INTERFACE $ + include(cmake/single_header.cmake) + gen_single_header( + TARGET + release_header + GEN_HEADER + ${CMAKE_SOURCE_DIR}/tools/gen_release_header.py + SOURCE_TARGET + cib + SOURCE_FILESET + cib + INPUT_HEADER + ${CMAKE_SOURCE_DIR}/include/cib/cib.hpp + OUTPUT_HEADER + ${CMAKE_BINARY_DIR}/include/cib/cib.hpp) + + if(DEFINED ENV{SINGLE_HEADER}) + add_dependencies(cib release_header) + + target_include_directories( + cib + INTERFACE $ $) -else() - target_include_directories( - cib INTERFACE $ + else() + target_include_directories( + cib + INTERFACE $ $) + endif() endif() diff --git a/cmake/single_header.cmake b/cmake/single_header.cmake new file mode 100644 index 00000000..115835bc --- /dev/null +++ b/cmake/single_header.cmake @@ -0,0 +1,17 @@ +function(gen_single_header) + set(oneValueArgs TARGET GEN_HEADER SOURCE_TARGET SOURCE_FILESET + INPUT_HEADER OUTPUT_HEADER) + cmake_parse_arguments(SH "" "${oneValueArgs}" "" ${ARGN}) + + get_target_property(HEADERS ${SH_SOURCE_TARGET} + HEADER_SET_${SH_SOURCE_FILESET}) + get_filename_component(OUTPUT_DIR ${SH_OUTPUT_HEADER} DIRECTORY) + add_custom_command( + DEPENDS ${SH_GEN_HEADER} ${HEADERS} + COMMAND ${CMAKE_COMMAND} -E make_directory ${OUTPUT_DIR} + COMMAND ${Python3_EXECUTABLE} ${SH_GEN_HEADER} ${SH_INPUT_HEADER} > + ${SH_OUTPUT_HEADER} + OUTPUT ${SH_OUTPUT_HEADER}) + + add_custom_target(${SH_TARGET} DEPENDS ${SH_OUTPUT_HEADER}) +endfunction()