Skip to content

Commit

Permalink
Print gitversion
Browse files Browse the repository at this point in the history
  • Loading branch information
peterrum authored and blaisb committed Aug 23, 2024
1 parent 2a7462b commit 11d4ecb
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ find_package(deal.II 9.5.0 QUIET REQUIRED
HINTS "${deal.II_DIR}" "${DEAL_II_DIR}" "$ENV{DEAL_II_DIR}")
deal_ii_initialize_cached_variables()

deal_ii_query_git_information(LETHE)

CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/include/core/revision.h.in
${CMAKE_CURRENT_BINARY_DIR}/include/core/revision.h
)

project(lethe VERSION 0.1 LANGUAGES CXX)

# Check for deal.II features after the PROJECT call — but still as close
Expand Down Expand Up @@ -131,6 +138,8 @@ endif()


add_subdirectory(source)
target_include_directories(lethe-solvers PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/include)

add_subdirectory(applications)

if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
Expand Down
28 changes: 28 additions & 0 deletions applications/lethe-fluid-matrix-free/fluid_dynamics_matrix_free.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@

#include "solvers/fluid_dynamics_matrix_free.h"

#include <core/revision.h>

#include <deal.II/base/revision.h>

std::string
concatenate_strings(const int argc, char **argv)
{
std::string result = std::string(argv[0]);

for (int i = 1; i < argc; ++i)
result = result + " " + std::string(argv[i]);

return result;
}

int
main(int argc, char *argv[])
{
Expand Down Expand Up @@ -42,6 +57,19 @@ main(int argc, char *argv[])
MPI_COMM_WORLD) == 0) &&
print_parameters);

if (print_parameters)
{
pcout << "Running: " << concatenate_strings(argc, argv) << std::endl;
pcout << " - deal.II (branch: " << DEAL_II_GIT_BRANCH
<< "; revision: " << DEAL_II_GIT_REVISION
<< "; short: " << DEAL_II_GIT_SHORTREV << ")" << std::endl;
pcout << " - Lethe (branch: " << LETHE_GIT_BRANCH
<< "; revision: " << LETHE_GIT_REVISION
<< "; short: " << LETHE_GIT_SHORTREV << ")" << std::endl;
pcout << std::endl;
pcout << std::endl;
}

if (dim == 2)
{
ParameterHandler prm;
Expand Down
31 changes: 31 additions & 0 deletions include/core/revision.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* ---------------------------------------------------------------------
*
* Copyright (C) 2024 - by the Lethe authors
*
* This file is part of the Lethe library
*
* The Lethe library is free software; you can use it, redistribute
* it, and/or modify it under the terms of the GNU Lesser General
* Public License as published by the Free Software Foundation; either
* version 3.1 of the License, or (at your option) any later version.
* The full text of the license can be found in the file LICENSE at
* the top level of the Lethe distribution.
*
---------------------------------------------------------------------*/

#pragma once

/**
* Name of the local git branch of the source directory.
*/
#define LETHE_GIT_BRANCH "@LETHE_GIT_BRANCH@"

/**
* Full sha1 revision of the current git HEAD.
*/
#define LETHE_GIT_REVISION "@LETHE_GIT_REVISION@"

/**
* Short sha1 revision of the current git HEAD.
*/
#define LETHE_GIT_SHORTREV "@LETHE_GIT_SHORTREV@"

0 comments on commit 11d4ecb

Please sign in to comment.