Skip to content

Commit

Permalink
Merge pull request #79 from ValeevGroup/evaleev/fix/git-revision
Browse files Browse the repository at this point in the history
introduce git_description + pin to specific VG kit version
  • Loading branch information
evaleev authored Oct 17, 2022
2 parents 8cf6e58 + a623b8d commit 1a3fea3
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 21 deletions.
28 changes: 10 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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")
Expand Down Expand Up @@ -79,7 +72,6 @@ include(FetchContent)
include(AddCustomTargetSubproject)
include(FeatureSummary)
include(CMakePackageConfigHelpers)
include(external/versions.cmake)

##########################
# Standard build variables
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 6 additions & 1 deletion SeQuant/version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 10 additions & 1 deletion SeQuant/version.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion bin/admin/dependency-versions-update-hook.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

from __future__ import print_function
import sys
Expand Down
2 changes: 2 additions & 0 deletions external/versions.cmake
Original file line number Diff line number Diff line change
@@ -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)

Expand Down

0 comments on commit 1a3fea3

Please sign in to comment.