Skip to content

feat: install version header algorithms/version.h - #43

Merged
wdconinc merged 1 commit into
mainfrom
claude/algorithms-issue-24-8b8437
Oct 29, 2026
Merged

wdconinc merged 1 commit into
mainfrom
claude/algorithms-issue-24-8b8437

Conversation

@wdconinc

Copy link
Copy Markdown
Contributor

Briefly, what does this PR introduce?

Closes #24. Generates algorithms/version.h from version_number at configure time and installs it alongside the other headers, so downstream code can depend on the algorithms version.

  • Preprocessor macros for conditional compilation: ALGORITHMS_VERSION_MAJOR, _MINOR, _PATCH, ALGORITHMS_VERSION_STRING, ALGORITHMS_VERSION, and ALGORITHMS_VERSION_CODE(major, minor, patch), e.g.
    #if ALGORITHMS_VERSION >= ALGORITHMS_VERSION_CODE(2, 1, 0)
  • constexpr values in namespace algorithms: versionMajor, versionMinor, versionPatch, versionString, and versionAtLeast(major, minor = 0, patch = 0).

ALGORITHMS_VERSION_CODE encodes major × 10⁶ + minor × 10³ + patch, so it orders correctly while minor and patch stay below 1000.

The template lives at core/version.h.in (outside include/, so the directory install doesn't pick it up); the generated header goes to the build tree, which is added to the build-interface include path.

What kind of change does this PR introduce?

  • Bug fix
  • New feature
  • Documentation update
  • Other

Testing

  • New core/tests/version.cpp: macros and constants agree, version codes are ordered, versionAtLeast boundaries, and the macros are usable in #if.
  • Locally in eic_xl-nightly with clang++ Debug (-Werror): all 98 tests pass, and cmake --install places include/algorithms/version.h. A downstream-style file including only the installed header compiles with g++ -std=c++17 -Wall -Wextra -Wpedantic -Werror.

🤖 Generated with Claude Code

Generate algorithms/version.h from version_number at configure time and
install it with the other headers. It provides preprocessor macros
(ALGORITHMS_VERSION_MAJOR/MINOR/PATCH/STRING, ALGORITHMS_VERSION and
ALGORITHMS_VERSION_CODE) for conditional compilation, and constexpr
versionMajor/Minor/Patch, versionString and versionAtLeast() in the
algorithms namespace.

Closes #24

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 29, 2026 02:28
@wdconinc
wdconinc enabled auto-merge (squash) October 29, 2026 02:31
@wdconinc
wdconinc disabled auto-merge October 29, 2026 02:32
@wdconinc
wdconinc merged commit ed798d3 into main Oct 29, 2026
9 checks passed
@wdconinc
wdconinc deleted the claude/algorithms-issue-24-8b8437 branch October 29, 2026 02:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The review surfaced no outstanding issues or comments requiring changes, leaving nothing to block approval.

No open issues 🎉

What changed in this PR

This PR resolves issue #24 by generating and installing a public algorithms/version.h header so downstream code can depend on the algorithms library version. The header is produced at configure time from the existing version_number source of truth (via configure_file) into the build tree, exposed on the build-interface include path, and installed alongside the other algorithms/ headers. It provides both preprocessor macros (for #if conditional compilation) and constexpr values/versionAtLeast(...) in namespace algorithms.

Changes:

  • Added core/version.h.in template defining ALGORITHMS_VERSION_* macros, ALGORITHMS_VERSION_CODE(...), and constexpr versionMajor/Minor/Patch/String plus versionAtLeast(...).
  • Wired configure_file, the build-interface include dir, and an install(FILES ...) rule into core/CMakeLists.txt; documented the header in README.md.
  • Added core/tests/version.cpp (auto-registered via the test GLOB) covering macro/constant agreement, version-code ordering, versionAtLeast boundaries, and #if usability.
File Description
core/​version.h.in New template for the generated version header; macros + constexpr values and versionAtLeast with correct lexicographic comparison.
core/​CMakeLists.txt Generates the header into the build tree, adds it to the build-interface include path, and installs it to include/algorithms.
core/​tests/​version.cpp Catch2 tests validating macro/constant consistency, version-code ordering, and versionAtLeast boundaries.
README.md Documents the new algorithms/version.h header in the feature list.

I reviewed the version-encoding math (major×10⁶ + minor×10³ + patch, documented to require minor/patch < 1000), the versionAtLeast logic (verified correct for all test cases against the current 2.1.0), the CMake configure/install wiring (build-tree generation avoids the source-dir install(DIRECTORY ...) and does not double-install), and convention consistency (#pragma once, SPDX header, STATIC_CHECK/fmt usage, auto test registration). The changes are self-contained, well-tested, and -Werror/C++17/C++20 clean. I found no issues requiring a comment.

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Install version header

2 participants