make sure that git repo info is only added if the musrfit project source is indeed a git repo, and not e.g. a download.

This commit is contained in:
2021-07-12 15:34:07 +02:00
parent edeff3563c
commit d3d55f8719
31 changed files with 279 additions and 70 deletions

View File

@@ -61,11 +61,19 @@ else (APPLE)
add_executable(mupp ${GENERATED_HEADER_FILES} ${MUPP_SOURCE_FILES} qrc_mupp.cpp)
endif (APPLE)
#--- check if project source is repo ------------------------------------------
if (IS_GIT_REPO)
set(HAVE_GIT_REV_H "-DHAVE_GIT_REV_H")
else (IS_GIT_REPO)
set(HAVE_GIT_REV_H "")
endif (IS_GIT_REPO)
#--- compiler option to workaround a little cast problem for some
#--- boost/compiler combinations ----------------------------------------------
target_compile_options(mupp
PRIVATE
"-fpermissive"
"-fpermissive"
"${HAVE_GIT_REV_H}"
)
#--- add the variable related sources -----------------------------------------
@@ -75,6 +83,7 @@ add_subdirectory(var)
target_include_directories(mupp
BEFORE PRIVATE
$<BUILD_INTERFACE:${Boost_INCLUDE_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/../..>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/var/include>
)

View File

@@ -58,6 +58,9 @@
#include <QtDebug>
#include "mupp_version.h"
#ifdef HAVE_GIT_REV_H
#include "git-revision.h"
#endif
#include "PmuppGui.h"
//----------------------------------------------------------------------------------------------------
@@ -779,7 +782,11 @@ void PmuppGui::helpCmds()
*/
void PmuppGui::helpAbout()
{
QMessageBox::information(this, "about", QString("mupp: created by Andreas Suter.\nVersion: %1\nBranch: %2\nHash: %3").arg(MUPP_VERSION).arg(GIT_BRANCH).arg(GIT_COMMIT_HASH));
#ifdef HAVE_GIT_REV_H
QMessageBox::information(this, "about", QString("mupp: created by Andreas Suter.\nVersion: %1\nBranch: %2\nHash: %3").arg(MUPP_VERSION).arg(GIT_BRANCH).arg(GIT_CURRENT_SHA1));
#else
QMessageBox::information(this, "about", QString("mupp: created by Andreas Suter.\nVersion: %1").arg(MUPP_VERSION));
#endif
}
//-----------------------------------------------------------------------------

View File

@@ -6,22 +6,6 @@ set(BIN_DIR "@CMAKE_CURRENT_BINARY_DIR@")
set(CMAKE_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@")
set(MUPP_VERSION "@mupp_VERSION@")
# Get the current working branch
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# Get the latest abbreviated commit hash of the working branch
execute_process(
COMMAND git log -1 --pretty="%h, %ci"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
configure_file(
${SRC_DIR}/cmake/mupp_version.h.in
${BIN_DIR}/mupp_version.h

View File

@@ -4,8 +4,5 @@
#define MUPP_PREFIX "@CMAKE_INSTALL_PREFIX@"
#define MUPP_VERSION "@MUPP_VERSION@"
#define GIT_BRANCH "@GIT_BRANCH@"
#define GIT_COMMIT_HASH @GIT_COMMIT_HASH@
#endif

View File

@@ -41,6 +41,9 @@
#include <QTimer>
#include "mupp_version.h"
#ifdef HAVE_GIT_REV_H
#include "git-revision.h"
#endif
#include "PmuppScript.h"
#include "PmuppGui.h"
@@ -477,7 +480,11 @@ int main(int argc, char *argv[])
mupp_syntax();
return 0;
} else if (!qstrcmp(argv[1], "-v") || !qstrcmp(argv[1], "--version")) {
std::cout << std::endl << "mupp version: " << MUPP_VERSION << ", git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_COMMIT_HASH << std::endl << std::endl;
#ifdef HAVE_GIT_REV_H
std::cout << std::endl << "mupp version: " << MUPP_VERSION << ", git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << std::endl << std::endl;
#else
std::cout << std::endl << "mupp version: " << MUPP_VERSION << std::endl << std::endl;
#endif
return 0;
} else if (!qstrcmp(argv[1], "-s") || !qstrcmp(argv[1], "--script")) {
if (argc != 3) {