Skip to content

Commit

Permalink
- sequant::revision -> sequant::git_revision
Browse files Browse the repository at this point in the history
- introduced sequant::git_description
  • Loading branch information
evaleev committed Oct 17, 2022
1 parent a990e8c commit a623b8d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
26 changes: 8 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,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 @@ -81,7 +72,6 @@ include(FetchContent)
include(AddCustomTargetSubproject)
include(FeatureSummary)
include(CMakePackageConfigHelpers)
include(external/versions.cmake)

##########################
# Standard build variables
Expand Down Expand Up @@ -261,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

0 comments on commit a623b8d

Please sign in to comment.