Skip to content

cmake/template: add include-dir convenience helper for BUILD_INTERFACE only #667

Description

@kcenon

What

Add a new helper to cmake/template/targets.cmake that wraps the common pattern of attaching one or more $<BUILD_INTERFACE:...>-only include directories to a target.

Proposed signature:

kcenon_template_add_build_interface_includes(<target> <visibility> <dir>...)
    Attach BUILD_INTERFACE include directories to <target> for each <dir>.

Why

pacs_system defines an inline equivalent (pacs_add_build_interface_include_dirs) at cmake/options.cmake because the existing template helper kcenon_template_setup_target_includes always pairs BUILD_INTERFACE with INSTALL_INTERFACE. There are real cases (build-only test fixtures, generated code that should not be installed) where only BUILD_INTERFACE is desired.

Promoting the helper to the template would let pacs_system delete the local copy and align other systems on the same name.

Where

  • cmake/template/targets.cmake
  • Template VERSION bump: 1.0.0 -> 1.1.0 (MINOR per template versioning policy: new helper added).

How

Acceptance Criteria

  • Helper added to targets.cmake with documentation in the file header
  • VERSION bumped to 1.1.0
  • Template README example updated if appropriate

Source Reference

The pacs_system inline implementation can be used as the starting point: https://github.com/kcenon/pacs_system/blob/develop/cmake/options.cmake#L97-L105 (function pacs_add_build_interface_include_dirs).

Context

Discovered during the cmake-template alignment of pacs_system (kcenon/pacs_system#1140, part of kcenon/pacs_system#1137).

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions