Repository navigation
feat: install version header algorithms/version.h - #43
Conversation
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>
There was a problem hiding this comment.
🟢 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.intemplate definingALGORITHMS_VERSION_*macros,ALGORITHMS_VERSION_CODE(...), andconstexprversionMajor/Minor/Patch/StringplusversionAtLeast(...). - Wired
configure_file, the build-interface include dir, and aninstall(FILES ...)rule intocore/CMakeLists.txt; documented the header inREADME.md. - Added
core/tests/version.cpp(auto-registered via the testGLOB) covering macro/constant agreement, version-code ordering,versionAtLeastboundaries, and#ifusability.
| 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
Briefly, what does this PR introduce?
Closes #24. Generates
algorithms/version.hfromversion_numberat configure time and installs it alongside the other headers, so downstream code can depend on the algorithms version.ALGORITHMS_VERSION_MAJOR,_MINOR,_PATCH,ALGORITHMS_VERSION_STRING,ALGORITHMS_VERSION, andALGORITHMS_VERSION_CODE(major, minor, patch), e.g.#if ALGORITHMS_VERSION >= ALGORITHMS_VERSION_CODE(2, 1, 0)namespace algorithms:versionMajor,versionMinor,versionPatch,versionString, andversionAtLeast(major, minor = 0, patch = 0).ALGORITHMS_VERSION_CODEencodes major × 10⁶ + minor × 10³ + patch, so it orders correctly while minor and patch stay below 1000.The template lives at
core/version.h.in(outsideinclude/, 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?
Testing
core/tests/version.cpp: macros and constants agree, version codes are ordered,versionAtLeastboundaries, and the macros are usable in#if.eic_xl-nightlywith clang++ Debug (-Werror): all 98 tests pass, andcmake --installplacesinclude/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