Skip to content

Commit

Permalink
#1692: cmake: make version consistent and only modified in one place …
Browse files Browse the repository at this point in the history
…(the VERSION file). This also allows us to print out the version in the banner, which is useful if not git info is available
  • Loading branch information
nmm0 committed Mar 3, 2022
1 parent 139c126 commit 144de3b
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 28 deletions.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
cmake_minimum_required(VERSION 3.17 FATAL_ERROR)
project(vt VERSION 1.1.0)

file(READ "VERSION" _vt_version_str)
string(STRIP "${_vt_version_str}" _vt_version_str)
project(vt VERSION ${_vt_version_str})

# To generate output file with compilation errors and warnings
# CMake generator needs to be known
Expand Down
6 changes: 3 additions & 3 deletions cmake/load_doxygen.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ if (${vt_doxygen_enabled})
set(doxygen_out ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)

set(DOXYGEN_PROJECT_NAME "vt")
set(VERSION_MAJOR "1")
set(VERSION_MINOR "0")
set(VERSION_PATCH "0")
set(VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
set(VERSION_MINOR "${PROJECT_VERSION_MINOR}")
set(VERSION_PATCH "${PROJECT_VERSION_PATCH}")
set(DOXYGEN_INPUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/")
set(DOXYGEN_CHECKPOINT_SHARED_DOCS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lib/checkpoint/docs/shared")
set(DOXYGEN_CHECKPOINT_EXAMPLE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lib/checkpoint/examples")
Expand Down
3 changes: 3 additions & 0 deletions src/vt/configs/generated/vt_git_revision.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@

#include <string>

extern int const vt_version_major;
extern int const vt_version_minor;
extern int const vt_version_patch;
extern std::string const vt_git_sha1;
extern std::string const vt_git_exact_tag;
extern std::string const vt_git_refspec;
Expand Down
48 changes: 24 additions & 24 deletions src/vt/runtime/runtime_banner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ void Runtime::printStartupBanner() {
#endif

std::string dirty = "";
if (strncmp(vt_git_clean_status.c_str(), "DIRTY", 5) == 0) {
if (vt_git_clean_status == "DIRTY") {
dirty = red + std::string("*dirty*") + reset;
}

Expand All @@ -174,29 +174,29 @@ void Runtime::printStartupBanner() {
auto const version = std::to_string(std::get<0>(version_tuple));
auto const subversion = std::to_string(std::get<1>(version_tuple));

auto f1 = fmt::format("{} {}{}\n", reg(init), reg(mode), emph(mode_type + thd));
auto f2a = fmt::format("{}Program: {} ({})\n", green,
emph(getAppConfig()->prog_name), emph(getAppConfig()->argv_prog_name));
auto f2b = fmt::format("{}Running on: {}\n", green, emph(all_node));
auto f3 = fmt::format("{}Machine Hostname: {}\n", green, emph(hostname));
auto f3a = fmt::format("{}MPI Version: {}.{}\n", green, emph(version), emph(subversion));
auto f3b = fmt::format("{}MPI Max tag: {}\n", green, emph(max_tag_str));

auto f4 = fmt::format("{}Build SHA: {}\n", green, emph(vt_git_sha1));
auto f5 = fmt::format("{}Build Ref: {}\n", green, emph(vt_git_refspec));
auto f6 = fmt::format("{}Description: {} {}\n", green, emph(vt_git_description), dirty);
auto f7 = fmt::format("{}Compile-time Features Enabled:{}\n", green, reset);

fmt::print("{}{}{}", vt_pre, f1, reset);
fmt::print("{}{}{}", vt_pre, f2a, reset);
fmt::print("{}{}{}", vt_pre, f2b, reset);
fmt::print("{}{}{}", vt_pre, f3, reset);
fmt::print("{}{}{}", vt_pre, f3a, reset);
fmt::print("{}{}{}", vt_pre, f3b, reset);
fmt::print("{}{}{}", vt_pre, f4, reset);
fmt::print("{}{}{}", vt_pre, f5, reset);
fmt::print("{}{}{}", vt_pre, f6, reset);
fmt::print("{}{}{}", vt_pre, f7, reset);
auto vt_version_string = fmt::format("{}.{}.{}", vt_version_major, vt_version_minor, vt_version_patch);
std::array< std::string, 11 > info_lines = {
fmt::format("{}Version: {}\n", green, emph(vt_version_string)),

fmt::format("{} {}{}\n", reg(init), reg(mode), emph(mode_type + thd)),
fmt::format("{}Program: {} ({})\n", green,
emph(getAppConfig()->prog_name), emph(getAppConfig()->argv_prog_name)),
fmt::format("{}Running on: {}\n", green, emph(all_node)),
fmt::format("{}Machine Hostname: {}\n", green, emph(hostname)),
fmt::format("{}MPI Version: {}.{}\n", green, emph(version), emph(subversion)),
fmt::format("{}MPI Max tag: {}\n", green, emph(max_tag_str)),

fmt::format("{}Build SHA: {}\n", green, emph(vt_git_sha1)),
fmt::format("{}Build Ref: {}\n", green, emph(vt_git_refspec)),
fmt::format("{}Description: {} {}\n", green, emph(vt_git_description), dirty),
fmt::format("{}Compile-time Features Enabled:{}\n", green, reset)
};

for (auto &&line: info_lines)
{
fmt::print("{}{}{}", vt_pre, line, reset);
}

for (size_t i = 0; i < features.size(); i++) {
fmt::print("{}\t{}\n", vt_pre, emph(features.at(i)));
}
Expand Down
6 changes: 6 additions & 0 deletions vt_git_revision.cc.in
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,18 @@

#include <string>

#define VT_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
#define VT_VERSION_MINOR @PROJECT_VERSION_MINOR@
#define VT_VERSION_PATCH @PROJECT_VERSION_PATCH@
#define VT_GIT_SHA1 "@GIT_SHA1@"
#define VT_GIT_EXACT_TAG "@GIT_EXACT_TAG@"
#define VT_GIT_REFSPEC "@GIT_REFSPEC@"
#define VT_GIT_DESCRIPTION "@GIT_DESCRIPTION@"
#define VT_GIT_CLEAN_STATUS "@GIT_CLEAN_STATUS@"

int const vt_version_major = VT_VERSION_MAJOR;
int const vt_version_minor = VT_VERSION_MINOR;
int const vt_version_patch = VT_VERSION_PATCH;
std::string const vt_git_sha1 = VT_GIT_SHA1;
std::string const vt_git_exact_tag = VT_GIT_EXACT_TAG;
std::string const vt_git_refspec = VT_GIT_REFSPEC;
Expand Down

0 comments on commit 144de3b

Please sign in to comment.