Archetype: cmake_service_src.mustache

Table of Contents

Library + executable split like the service flavour, but with no sibling core dependency — the pre-regroup standalone-service shape. Referenced by no profile and no code; retained pending the facet-catalogue staleness audit (see the facet_catalogue.org stale-outputs capture). If the audit confirms it is dead, delete this section and the artefact together. CMake target declaration for this component. Wires sources, include paths, link dependencies, and the export macro.

See the Template variable reference for the complete list of available variables and their semantics.

Template

The full template source. Edit here and re-tangle with compass build --direct tangle_codegen_templates to regenerate library/templates/cmake_service_src.mustache.

{{! GENERATED FILE — tangled from projects/ores.codegen/library/templates/cmake.org. Edit the org source. }}
{{{cmake_license}}}
{{#component}}
set(name "{{full_name}}")
set(lib_binary_name ${name})
set(lib_target_name ${name}.lib)

set(files "")
file(GLOB_RECURSE files RELATIVE
    "${CMAKE_CURRENT_SOURCE_DIR}/"
    "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")

set(lib_files ${files})
list(FILTER lib_files EXCLUDE REGEX "main.cpp")

add_library(${lib_target_name} ${lib_files})
target_compile_definitions(${lib_target_name} PRIVATE {{full_name_upper}}_LIBRARY)
set_target_properties(${lib_target_name} PROPERTIES
    OUTPUT_NAME ${lib_binary_name})
set_target_properties(${lib_target_name}
    PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR})

target_include_directories(${lib_target_name} PUBLIC
    ${CMAKE_SOURCE_DIR}/projects/${name}/include)

target_link_libraries(${lib_target_name}
    PUBLIC
        ores.nats.lib
        ores.database.lib
        ores.utility.lib
        ores.telemetry.lib)

install(TARGETS ${lib_target_name} LIBRARY DESTINATION lib)

set(exe_binary_name ${name})
set(exe_target_name ${name}.exe)

set(exe_files ${files})
list(FILTER exe_files INCLUDE REGEX "main.cpp")

add_executable(${exe_target_name} ${exe_files})
set_target_properties(${exe_target_name} PROPERTIES
    OUTPUT_NAME ${exe_binary_name})

target_link_libraries(${exe_target_name}
    PRIVATE
        ${lib_target_name}
        ores.openssl_cleanup
        ${CMAKE_THREAD_LIBS_INIT})

install(TARGETS ${exe_target_name} RUNTIME DESTINATION bin)
{{/component}}

See also

Emacs 29.1 (Org mode 9.6.6)