Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ALPS_VERSION.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.3.4
53 changes: 38 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,17 @@ if(ALPS_BUILD_LIBS_ONLY)
set(ALPS_BUILD_APPLICATIONS OFF)
endif()

# Sets ALPS_VERSION_CORE from ALPS_VERSION.txt. Included by full path because
# CMAKE_MODULE_PATH is not set up until after project().
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/ALPSVersion.cmake)

if(ALPS_BUILD_FORTRAN)
project(alps C CXX Fortran)
project(alps VERSION ${ALPS_VERSION_CORE} LANGUAGES C CXX Fortran)
if (APPLE)
set (CMAKE_Fortran_RUNTIME_LIBRARIES "-lgcc_s.1")
endif(APPLE)
else(ALPS_BUILD_FORTRAN)
project(alps C CXX)
project(alps VERSION ${ALPS_VERSION_CORE} LANGUAGES C CXX)
endif(ALPS_BUILD_FORTRAN)

set(CMAKE_CXX_STANDARD 14)
Expand Down Expand Up @@ -118,25 +122,35 @@ list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
######################################################################
# Version information
######################################################################
set(ALPS_YEAR 2026)
set(ALPS_VERSION_MAJOR 2)
set(ALPS_VERSION_MINOR 3)
set(ALPS_VERSION_PATCH 3)
set(ALPS_VERSION_BUILD "")

if(ALPS_VERSION_BUILD)
set(ALPS_VERSION "${ALPS_VERSION_MAJOR}.${ALPS_VERSION_MINOR}.${ALPS_VERSION_PATCH}-${ALPS_VERSION_BUILD}")
else(ALPS_VERSION_BUILD)
set(ALPS_VERSION "${ALPS_VERSION_MAJOR}.${ALPS_VERSION_MINOR}.${ALPS_VERSION_PATCH}")
endif(ALPS_VERSION_BUILD)
# The numeric components come from project() above, which took its version from
# ALPS_VERSION.txt. Do not hardcode them here.
set(ALPS_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(ALPS_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(ALPS_VERSION_PATCH ${PROJECT_VERSION_PATCH})

# Prerelease label, e.g. "beta.2" for the v2.3.4-beta.2 tag. Display only: it is
# deliberately kept out of the numeric version that drives SOVERSION and
# find_package() matching. Set by the release process, not checked in.
set(ALPS_VERSION_PRERELEASE "" CACHE STRING
"Prerelease label for this build, e.g. beta.2 (affects version strings only)")
mark_as_advanced(ALPS_VERSION_PRERELEASE)

if(ALPS_VERSION_PRERELEASE)
set(ALPS_VERSION "${ALPS_VERSION_CORE}-${ALPS_VERSION_PRERELEASE}")
else()
set(ALPS_VERSION "${ALPS_VERSION_CORE}")
endif()
set(ALPS_VERSION_STRING "ALPS Libraries version ${ALPS_VERSION}")
MESSAGE(STATUS "ALPS version: ${ALPS_VERSION}")
message(STATUS "ALPS version: ${ALPS_VERSION}")

# Derived, never hardcoded. string(TIMESTAMP) honours SOURCE_DATE_EPOCH, so
# distro and conda reproducible builds still get a stable year.
string(TIMESTAMP ALPS_YEAR "%Y" UTC)

set(ALPS_CONFIG_HOST unknown)
set(ALPS_CONFIG_USER unknown)

set(ALPS_PREFIX "${CMAKE_INSTALL_PREFIX}")
set(ALPS_SRCDIR "${CMAKE_SOURCE_DIR}")
set(libdir "${CMAKE_INSTALL_PREFIX}/lib")
set(bindir "${CMAKE_INSTALL_PREFIX}/bin")

Expand Down Expand Up @@ -396,6 +410,14 @@ endif(HDF5_LIBRARIES)
configure_file(cmake/ALPSConfig.cmake.in ${PROJECT_BINARY_DIR}/cmake/ALPSConfig.cmake @ONLY)
configure_file(cmake/include.mk.in ${PROJECT_BINARY_DIR}/cmake/include.mk)

# Without this file find_package(ALPS <version>) accepts any version it finds
# and silently discards the constraint. SameMinorVersion: patch releases within
# a minor series are drop-in, a minor bump is not guaranteed to be.
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
${PROJECT_BINARY_DIR}/cmake/ALPSConfigVersion.cmake
COMPATIBILITY SameMinorVersion)


# installation
######################################################################
Expand Down Expand Up @@ -429,6 +451,7 @@ add_subdirectory(cmake)

install(FILES cmake/UseALPS.cmake
${PROJECT_BINARY_DIR}/cmake/ALPSConfig.cmake
${PROJECT_BINARY_DIR}/cmake/ALPSConfigVersion.cmake
${PROJECT_BINARY_DIR}/cmake/include.mk
cmake/run_test.cmake
cmake/run_test_mpi.cmake
Expand Down
7 changes: 5 additions & 2 deletions cmake/ALPSConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ set(ALPS_LIBRARY_DIRS "@ALPS_LIBRARY_DIRS_CONFIG@")
# of runtime binaries for each configuration type.
set(ALPS_RUNTIME_LIBRARY_DIRS "@ALPS_RUNTIME_LIBRARY_DIRS_CONFIG@")

# The ALPS version number.
# The ALPS version number. ALPS_VERSION carries the prerelease label when there
# is one; ALPS_VERSION_CORE is always plain MAJOR.MINOR.PATCH and is what
# ALPSConfigVersion.cmake compares against.
SET(ALPS_VERSION_MAJOR "@ALPS_VERSION_MAJOR@")
SET(ALPS_VERSION_MINOR "@ALPS_VERSION_MINOR@")
SET(ALPS_VERSION_PATCH "@ALPS_VERSION_PATCH@")
SET(ALPS_VERSION_BUILD "@ALPS_VERSION_BUILD@")
SET(ALPS_VERSION_PRERELEASE "@ALPS_VERSION_PRERELEASE@")
SET(ALPS_VERSION_CORE "@ALPS_VERSION_CORE@")
SET(ALPS_VERSION "@ALPS_VERSION@")

# The location of the UseALPS.cmake file.
Expand Down
41 changes: 41 additions & 0 deletions cmake/ALPSVersion.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright ALPS collaboration 2026.
# Distributed under the MIT licence; see LICENSE.txt.
#
# Single source of truth for the ALPS release version.
#
# ALPS_VERSION.txt holds the numeric release core (MAJOR.MINOR.PATCH) and
# nothing else. Two constraints force that:
#
# * project(VERSION ...) rejects anything non-numeric, so "2.4.0-beta.1"
# fails to configure.
# * find_package() version matching and the library SOVERSION have no notion
# of prerelease ordering.
#
# A prerelease label such as "beta.2" therefore lives in ALPS_VERSION_PRERELEASE
# (see the version block in the top-level CMakeLists.txt), where it affects the
# display string only -- never the numeric version used for ABI and
# find_package() decisions.
#
# This file is included by full path before project(), so it cannot rely on
# CMAKE_MODULE_PATH or PROJECT_SOURCE_DIR.

set(_alps_version_file "${CMAKE_CURRENT_LIST_DIR}/../ALPS_VERSION.txt")

if(NOT EXISTS "${_alps_version_file}")
message(FATAL_ERROR "Cannot read the ALPS version file: ${_alps_version_file}")
endif()

file(STRINGS "${_alps_version_file}" ALPS_VERSION_CORE LIMIT_COUNT 1)
string(STRIP "${ALPS_VERSION_CORE}" ALPS_VERSION_CORE)

# Fail loudly here rather than letting project() emit "VERSION format invalid",
# which gives no hint about which file is at fault.
if(NOT ALPS_VERSION_CORE MATCHES "^[0-9]+\\.[0-9]+\\.[0-9]+$")
message(FATAL_ERROR
"${_alps_version_file} must contain exactly MAJOR.MINOR.PATCH, but reads "
"'${ALPS_VERSION_CORE}'. Prerelease labels belong in "
"ALPS_VERSION_PRERELEASE, and the leading 'v' of a release tag is not "
"part of the version.")
endif()

unset(_alps_version_file)
40 changes: 26 additions & 14 deletions src/alps/version.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -30,34 +30,46 @@
#ifndef ALPS_VERSION_H
#define ALPS_VERSION_H

// Plain #define for everything the build always sets: the cmakedefine directive
// emits an "undef" when its value is false-y, and CMake counts 0 as false-y, so
// a zero component (2.4.0) would vanish. It is used below only where the macro
// is genuinely optional. (configure_file matches that directive even inside a
// comment, hence no leading '#' on it here.)

// ALPS version
#cmakedefine ALPS_VERSION "@ALPS_VERSION@"
#define ALPS_VERSION "@ALPS_VERSION@"

#define ALPS_VERSION_MAJOR @ALPS_VERSION_MAJOR@
#define ALPS_VERSION_MINOR @ALPS_VERSION_MINOR@
#define ALPS_VERSION_PATCH @ALPS_VERSION_PATCH@

#cmakedefine ALPS_VERSION_MAJOR @ALPS_VERSION_MAJOR@
#cmakedefine ALPS_VERSION_MINOR @ALPS_VERSION_MINOR@
#cmakedefine ALPS_VERSION_PATCH @ALPS_VERSION_PATCH@
#cmakedefine ALPS_SVN_REVISION @ALPS_WC_REVISION@
// ALPS version as a single integer, for preprocessor comparisons:
// #if ALPS_VERSION_NUMBER >= ALPS_VERSION_NUM(2, 3, 4)
#define ALPS_VERSION_NUM(major, minor, patch) \
((major) * 100000 + (minor) * 100 + (patch))
#define ALPS_VERSION_NUMBER \
ALPS_VERSION_NUM(ALPS_VERSION_MAJOR, ALPS_VERSION_MINOR, ALPS_VERSION_PATCH)

// ALPS version (full string)
#cmakedefine ALPS_VERSION_STRING "@ALPS_VERSION_STRING@"
#define ALPS_VERSION_STRING "@ALPS_VERSION_STRING@"

// latest publish year of ALPS
#cmakedefine ALPS_YEAR "@ALPS_YEAR@"
#define ALPS_YEAR "@ALPS_YEAR@"

// install path of ALPS
#cmakedefine ALPS_PREFIX "@ALPS_PREFIX@"

// source directory of ALPS
#cmakedefine ALPS_SRCDIR "@ALPS_SRCDIR@"
#define ALPS_PREFIX "@ALPS_PREFIX@"

// XSLT PATH
#cmakedefine ALPS_XML_DIR "@ALPS_XML_DIR@"
#define ALPS_XML_DIR "@ALPS_XML_DIR@"

// Optional Windows fallback for the 32/64-bit "Program Files" split. Never set
// by the build, and guarded by #ifdef in parser/xslt_path.C.
#cmakedefine ALPS_XML_ALTERNATE_DIR "@ALPS_XML_ALTERNATE_DIR@"

// hostname where configure script was executed
#cmakedefine ALPS_CONFIG_HOST "@ALPS_CONFIG_HOST@"
#define ALPS_CONFIG_HOST "@ALPS_CONFIG_HOST@"

// username who executed configure script
#cmakedefine ALPS_CONFIG_USER "@ALPS_CONFIG_USER@"
#define ALPS_CONFIG_USER "@ALPS_CONFIG_USER@"

#endif // ALPS_VERSION_H
5 changes: 5 additions & 0 deletions test/hdf5/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ FOREACH (name hdf5_complex hdf5_copy hdf5_real_complex_vec hdf5_real_complex_mat
set_property(TEST ${name} PROPERTY LABELS hdf5)
ENDFOREACH(name)

# Reads a reference .h5 file from the source tree; see the note in
# test/numeric/CMakeLists.txt.
target_compile_definitions(hdf5_fortran_string
PRIVATE ALPS_SRCDIR="${PROJECT_SOURCE_DIR}")

IF (ALPS_ENABLE_OPENMP AND OPENMP_FOUND)
add_executable(hdf5_omp hdf5_omp.cpp)
add_dependencies(hdf5_omp alps)
Expand Down
7 changes: 7 additions & 0 deletions test/numeric/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,12 @@ if(LAPACK_FOUND)
add_alps_test(${name})
set_property(TEST ${name} PROPERTY LABELS numeric)
ENDFOREACH(name)

# This test reads a reference .h5 file from the source tree. That path is a
# property of this build, not of the installed library, so it is a private
# definition on the one target that needs it rather than a macro in the
# installed alps/version.h.
target_compile_definitions(matrix_deprecated_hdf5_format_test
PRIVATE ALPS_SRCDIR="${PROJECT_SOURCE_DIR}")
endif(LAPACK_FOUND)

1 change: 0 additions & 1 deletion tool/pconfig.C
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
int main() {
std::cout << "ALPS version: " << alps::version() << std::endl
<< "Boost version: " << BOOST_LIB_VERSION << std::endl
<< "source directory: " << ALPS_SRCDIR << std::endl
<< "installed at: " << ALPS_PREFIX << std::endl
<< "configured on: " << alps::config_host() << std::endl
<< "configured by: " << alps::config_user() << std::endl
Expand Down
Loading