Skip to content

build: single-source the ALPS version, add ALPSConfigVersion.cmake - #114

Merged
Ooolab merged 2 commits into
cleanup/root-layoutfrom
build/version-single-source
Aug 1, 2026
Merged

build: single-source the ALPS version, add ALPSConfigVersion.cmake#114
Ooolab merged 2 commits into
cleanup/root-layoutfrom
build/version-single-source

Conversation

@skilledwolf

Copy link
Copy Markdown
Collaborator

Refs #95. Targets cleanup/root-layout (#112) — it restructures the same files, so this continues it and must merge after. Also carries the commit from #113, which is closed in favour of this PR.

The version was hardcoded in CMakeLists.txt and had already drifted three ways: CMake said 2.3.3, the newest tag is v2.3.4, pyalps/pyproject.toml says 2.3.4b1.

  • ALPS_VERSION.txt holds the release, read by cmake/ALPSVersion.cmake before project(); ALPS_VERSION_MAJOR/MINOR/PATCH now derive from PROJECT_VERSION_*. Numeric core only — project(VERSION) rejects non-numeric input, and neither SOVERSION nor find_package() matching has a notion of prerelease ordering. A malformed file fails with a message naming the file instead of CMake's bare VERSION format invalid. Corrects the version to 2.3.4.

  • ALPS_VERSION_PRERELEASE replaces the always-empty ALPS_VERSION_BUILD. Carries beta.2 into display strings while the numeric version stays clean. Named "prerelease" because a follow-up adds real build metadata (a git hash) and two similar slots would confuse.

  • ALPSConfigVersion.cmake is generated and installed. Without it, find_package(ALPS <version>) accepted anything and silently discarded the constraint. Verified against an installed 2.3.4:

    request before after
    2.3.4 accepted accepted
    2.3.0 accepted accepted
    2.3.9 accepted rejected
    2.4.0 accepted rejected
    2.2.0 accepted rejected

    SameMinorVersion because a patch release within 2.3.x is drop-in and a minor bump is not guaranteed to be. Note that is stricter than the SOVERSION of MAJOR alone advertises — reconciling the soname is packaging-visible and deliberately not touched here.

  • ALPS_YEAR comes from string(TIMESTAMP), which honours SOURCE_DATE_EPOCH, so distro and conda reproducible builds keep a stable year.

  • ALPS_SRCDIR leaves the installed header. Two tests use it to find reference .h5 inputs, so those two targets get a private compile definition — a build-tree path belongs there, not in an installed public header.

Verified by configuring real ALPS (version, version.h, both generated config files correct), the find_package matrix above, malformed-version-file rejection, and building and running the two affected tests — both pass.

skilledwolf and others added 2 commits July 24, 2026 19:23
version.h.in declared ALPS_VERSION_MAJOR/MINOR/PATCH with cmakedefine,
which emits "/* #undef NAME */" when the substituted value is false-y.
CMake counts 0 as false-y, so any x.y.0 release generated a header with
that component silently missing. 2.4.0 would have tripped it.

Use a plain #define for every macro the build unconditionally sets.
Keep cmakedefine only for ALPS_XML_ALTERNATE_DIR, which the build never
sets and parser/xslt_path.C guards with #ifdef.

Also add ALPS_VERSION_NUMBER/ALPS_VERSION_NUM() for preprocessor version
comparisons (BOOST_VERSION packing), and drop two macros: ALPS_SVN_REVISION,
which expanded a variable unset since the SVN migration and was always
#undef, and ALPS_SRCDIR, which baked the build machine's source path into
an installed header for one line of pconfig output.

Refs #95

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The version was hardcoded in CMakeLists.txt and had already drifted: CMake
said 2.3.3, the newest tag is v2.3.4, and pyalps' pyproject.toml says 2.3.4b1.

Put the numeric release in ALPS_VERSION.txt, read it in cmake/ALPSVersion.cmake
before project(), and derive ALPS_VERSION_MAJOR/MINOR/PATCH from
PROJECT_VERSION_*. The file holds MAJOR.MINOR.PATCH and nothing else, because
project(VERSION) rejects non-numeric input and neither SOVERSION nor
find_package() matching has any notion of prerelease ordering. A malformed
file is rejected with a message naming the file, rather than CMake's bare
"VERSION format invalid". Corrects the version to 2.3.4 in passing.

ALPS_VERSION_BUILD, which was always empty, becomes the ALPS_VERSION_PRERELEASE
cache variable: it carries "beta.2" into display strings while the numeric
version stays clean. "Prerelease" because a later change adds real build
metadata (a git hash), and two similarly-named slots would confuse.

Generate and install ALPSConfigVersion.cmake. Without it find_package(ALPS
<version>) accepted any version it found and silently discarded the
constraint. SameMinorVersion: within 2.3.x a patch release is drop-in, a minor
bump is not guaranteed to be. Note this is stricter than the SOVERSION of
MAJOR alone advertises; reconciling the soname is a packaging-visible change
and is left alone here.

Derive ALPS_YEAR with string(TIMESTAMP), which honours SOURCE_DATE_EPOCH, so
distro and conda reproducible builds still get a stable year.

ALPS_SRCDIR is dropped from the installed header by the preceding commit, but
two tests use it to locate reference .h5 inputs. Give those two targets a
private compile definition instead: a build-tree path belongs there, not in an
installed public header.

Refs #95

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@Ooolab
Ooolab merged commit 123e676 into cleanup/root-layout Aug 1, 2026
78 checks passed
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.

3 participants