Skip to content

feature, add CMake find_package and add_custom_command integration #23

@steven-varga

Description

@steven-varga

Context

The compiler currently requires manual CLI invocation. This is the #1 usability blocker. Users live in CMake; a pre-build codegen step that is not a first-class citizen in the build graph is pure friction.

Goals

  1. find_package support: find_package(h5cpp-compiler) or find_package(h5cpp COMPONENTS compiler) should work.
  2. add_custom_command integration: A CMake function that runs the compiler automatically when a struct header changes.
  3. Check / dry-run mode: h5cpp-compiler --check to verify generated descriptors are current without overwriting. This belongs in CI.
  4. Deterministic output: Generated headers should be diff-friendly (already done: #pragma once instead of random include guards).

Proposed API

find_package(h5cpp-compiler REQUIRED)

h5cpp_compiler_generate(
    TARGET my_target
    INPUTS particle.hpp simulation.hpp
    OUTPUTS particle_h5.hpp simulation_h5.hpp
    STUB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/stub
)

The function should:

  • Register add_custom_command so output is regenerated when inputs change
  • Fail the build if compilation fails (struct not POD, missing includes, etc.)
  • Optionally support --check mode for CI gating

Acceptance criteria

  • cmake/FindH5CPPCompiler.cmake or config-file package
  • h5cpp_compiler_generate() function documented in README
  • Example project in examples/cmake-integration/
  • CI job that tests the CMake integration path
  • Does not break existing manual CLI usage

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions