diff --git a/CMakeLists.txt b/CMakeLists.txt index b5158b622..a5b311999 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.15.0) # need list(PREPEND for toolchains ############################################################################### # Bring ValeevGroup cmake toolkit ############################################################################### +include(external/versions.cmake) include(FetchContent) if (DEFINED PROJECT_BINARY_DIR) set(VG_CMAKE_KIT_PREFIX_DIR PROJECT_BINARY_DIR) @@ -13,6 +14,7 @@ FetchContent_Declare( vg_cmake_kit QUIET GIT_REPOSITORY https://github.com/ValeevGroup/kit-cmake.git + GIT_TAG ${SEQUANT_TRACKED_VGCMAKEKIT_TAG} SOURCE_DIR ${${VG_CMAKE_KIT_PREFIX_DIR}}/cmake/vg BINARY_DIR ${${VG_CMAKE_KIT_PREFIX_DIR}}/cmake/vg-build SUBBUILD_DIR ${${VG_CMAKE_KIT_PREFIX_DIR}}/cmake/vg-subbuild @@ -32,18 +34,9 @@ else (SEQUANT_PRERELEASE_ID) set(SEQUANT_EXT_VERSION "${SEQUANT_VERSION}") endif (SEQUANT_PRERELEASE_ID) -# extract git revision -if (EXISTS ${PROJECT_SOURCE_DIR}/.git) - find_package(Git REQUIRED) - execute_process( - COMMAND ${GIT_EXECUTABLE} rev-parse -q HEAD - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - OUTPUT_VARIABLE SEQUANT_REVISION) - string(REGEX MATCH "[0-9a-f]*" - SEQUANT_REVISION "${SEQUANT_REVISION}") -else () - set(SEQUANT_REVISION "unknown") -endif () +# extract git metadata +include(GetGitMetadata) +vgkit_cmake_git_metadata() # make SeQuant project project(SeQuant LANGUAGES CXX VERSION "${SEQUANT_VERSION}" DESCRIPTION "SEcond QUANTization toolkit") @@ -79,7 +72,6 @@ include(FetchContent) include(AddCustomTargetSubproject) include(FeatureSummary) include(CMakePackageConfigHelpers) -include(external/versions.cmake) ########################## # Standard build variables @@ -259,11 +251,11 @@ add_library(SeQuant SeQuant/domain/mbpt/antisymmetrizer.hpp SeQuant/domain/mbpt/rdm.hpp ) -# feed SEQUANT_REVISION to SeQuant/version.cpp only to avoid recompiling everything -set_property( - SOURCE SeQuant/version.cpp - PROPERTY COMPILE_DEFINITIONS - SEQUANT_REVISION=\"${SEQUANT_REVISION}\" +# feed SEQUANT_GIT_REVISION and SEQUANT_GIT_DESCRIPTION to SeQuant/version.cpp only to avoid recompiling everything +set_source_files_properties( + SeQuant/version.cpp + PROPERTIES COMPILE_DEFINITIONS + "SEQUANT_GIT_REVISION=\"${SEQUANT_GIT_REVISION}\";SEQUANT_GIT_DESCRIPTION=\"${SEQUANT_GIT_DESCRIPTION}\"" ) target_link_libraries(SeQuant PUBLIC range-v3::range-v3 Boost::regex Boost::boost SeQuant-bliss Threads::Threads) diff --git a/SeQuant/version.cpp b/SeQuant/version.cpp index c412c8007..742ff4502 100644 --- a/SeQuant/version.cpp +++ b/SeQuant/version.cpp @@ -7,8 +7,13 @@ namespace sequant { const char* revision() noexcept { - static const char revision[] = SEQUANT_REVISION; + static const char revision[] = SEQUANT_GIT_REVISION; return revision; } +const char* git_description() noexcept { + static const char description[] = SEQUANT_GIT_DESCRIPTION; + return description; +} + } // namespace sequant diff --git a/SeQuant/version.hpp.in b/SeQuant/version.hpp.in index 189bf238a..e52962ee5 100644 --- a/SeQuant/version.hpp.in +++ b/SeQuant/version.hpp.in @@ -21,8 +21,17 @@ #define SEQUANT_PRERELEASE_ID "@SEQUANT_PRERELEASE_ID@" namespace sequant { + /** \return a string with the Git SHA1 revision hash tag of SeQuant */ -const char* revision() noexcept; +const char* git_revision() noexcept; + +/** + * \return a string with the human-readable description of the current source + * tree of SeQuant + * \note see `git describe --dirty` for the format description + * */ +const char* git_description() noexcept; + } // namespace sequant #endif // SEQUANT_SRC_SEQUANT_VERSION_H_IN_H diff --git a/bin/admin/dependency-versions-update-hook.py b/bin/admin/dependency-versions-update-hook.py index 5904443d7..f381ccc11 100755 --- a/bin/admin/dependency-versions-update-hook.py +++ b/bin/admin/dependency-versions-update-hook.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 from __future__ import print_function import sys diff --git a/external/versions.cmake b/external/versions.cmake index 5224a7b94..b53e14b02 100644 --- a/external/versions.cmake +++ b/external/versions.cmake @@ -1,6 +1,8 @@ # for each dependency track both current and previous id (the variable for the latter must contain PREVIOUS) # to be able to auto-update them +set(SEQUANT_TRACKED_VGCMAKEKIT_TAG 3091737b0a536616f1d12f0128b88de7bd1119cb) + set(SEQUANT_TRACKED_BOOST_VERSION 1.67) set(SEQUANT_TRACKED_BOOST_PREVIOUS_VERSION 1.67)