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:
suter_a 2021-07-12 15:34:07 +02:00
parent f41c633bfe
commit daa2ea1347
31 changed files with 279 additions and 70 deletions

View File

@ -220,6 +220,15 @@ endif (nexus)
set(HAVE_CONFIG_H 1 CACHE INTERNAL "config.h is available")
configure_file(${CMAKE_SOURCE_DIR}/cmake/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
#--- check if project source is a git repo ------------------------------------
if (EXISTS "${CMAKE_SOURCE_DIR}/.git/HEAD")
message(STATUS "is a git repo")
set(IS_GIT_REPO 1)
else ()
message(STATUS "is NOT a git repo")
set(IS_GIT_REPO 0)
endif ()
#--- propagate to the sub-directories -----------------------------------------
add_subdirectory(src)

View File

@ -23,32 +23,38 @@ endif (nexus)
set(MUSRFIT_LIBS ${MUSRFIT_LIBS} PMusr)
#--- start create git-revision.h ----------------------------------------------
configure_file(
${CMAKE_SOURCE_DIR}/cmake/configure_musrfit_version_file.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/configure_musrfit_version_file.cmake
@ONLY
)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/git-revision.h
COMMAND ${CMAKE_COMMAND} -P
if (IS_GIT_REPO)
configure_file(
${CMAKE_SOURCE_DIR}/cmake/configure_musrfit_version_file.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/configure_musrfit_version_file.cmake
DEPENDS
${CMAKE_CURRENT_BINARY_DIR}/configure_musrfit_version_file.cmake
${CMAKE_SOURCE_DIR}/cmake/git-revision.h.in
COMMENT "Configuring git-revision.h"
VERBATIM
)
@ONLY
)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/git-revision.h
COMMAND ${CMAKE_COMMAND} -P
${CMAKE_CURRENT_BINARY_DIR}/configure_musrfit_version_file.cmake
DEPENDS
${CMAKE_CURRENT_BINARY_DIR}/configure_musrfit_version_file.cmake
${CMAKE_SOURCE_DIR}/cmake/git-revision.h.in
COMMENT "Configuring git-revision.h"
VERBATIM
)
add_custom_target(
configure_musrfit_version ALL
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/git-revision.h
)
set(HAVE_GIT_REV_H "-DHAVE_GIT_REV_H")
else (IS_GIT_REPO)
set(HAVE_GIT_REV_H "")
endif (IS_GIT_REPO)
add_custom_target(
configure_musrfit_version ALL
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/git-revision.h
)
#--- end create git-revision.h ------------------------------------------------
#--- add all executables ------------------------------------------------------
add_executable(any2many git-revision.h any2many.cpp)
target_compile_options(any2many BEFORE PRIVATE "-DHAVE_CONFIG_H")
target_compile_options(any2many BEFORE PRIVATE "-DHAVE_CONFIG_H" "${HAVE_GIT_REV_H}")
target_include_directories(any2many
BEFORE PRIVATE
$<BUILD_INTERFACE:${Boost_INCLUDE_DIR}>
@ -60,7 +66,7 @@ target_include_directories(any2many
target_link_libraries(any2many ${ROOT_LIBRARIES} ${MUSRFIT_LIBS})
add_executable(dump_header git-revision.h dump_header.cpp)
target_compile_options(dump_header BEFORE PRIVATE "-DHAVE_CONFIG_H")
target_compile_options(dump_header BEFORE PRIVATE "-DHAVE_CONFIG_H" "${HAVE_GIT_REV_H}")
target_include_directories(dump_header
BEFORE PRIVATE
$<BUILD_INTERFACE:${Boost_INCLUDE_DIRS}>
@ -78,7 +84,7 @@ target_include_directories(dump_header
target_link_libraries(dump_header ${ROOT_LIBRARIES} ${MUSRFIT_LIBS})
add_executable(msr2data git-revision.h msr2data.cpp)
target_compile_options(msr2data BEFORE PRIVATE "-DHAVE_CONFIG_H")
target_compile_options(msr2data BEFORE PRIVATE "-DHAVE_CONFIG_H" "${HAVE_GIT_REV_H}")
target_include_directories(msr2data
BEFORE PRIVATE
$<BUILD_INTERFACE:${Boost_INCLUDE_DIRS}>
@ -93,7 +99,7 @@ add_executable(msr2msr msr2msr.cpp)
target_link_libraries(msr2msr ${ROOT_LIBRARIES})
add_executable(musrfit git-revision.h musrfit.cpp)
target_compile_options(musrfit BEFORE PRIVATE "-DHAVE_CONFIG_H")
target_compile_options(musrfit BEFORE PRIVATE "-DHAVE_CONFIG_H" "${HAVE_GIT_REV_H}")
target_include_directories(musrfit
BEFORE PRIVATE
$<BUILD_INTERFACE:${Boost_INCLUDE_DIR}>
@ -105,7 +111,7 @@ target_include_directories(musrfit
target_link_libraries(musrfit ${ROOT_LIBRARIES} ${MUSRFIT_LIBS})
add_executable(musrFT git-revision.h musrFT.cpp)
target_compile_options(musrFT BEFORE PRIVATE "-DHAVE_CONFIG_H")
target_compile_options(musrFT BEFORE PRIVATE "-DHAVE_CONFIG_H" "${HAVE_GIT_REV_H}")
target_include_directories(musrFT
BEFORE PRIVATE
$<BUILD_INTERFACE:${Boost_INCLUDE_DIR}>
@ -117,7 +123,7 @@ target_include_directories(musrFT
target_link_libraries(musrFT ${FFTW3_LIBRARY} ${ROOT_LIBRARIES} ${MUSRFIT_LIBS})
add_executable(musrRootValidation git-revision.h musrRootValidation.cpp)
target_compile_options(musrRootValidation BEFORE PRIVATE "-DHAVE_CONFIG_H")
target_compile_options(musrRootValidation BEFORE PRIVATE "-DHAVE_CONFIG_H" "${HAVE_GIT_REV_H}")
target_include_directories(musrRootValidation
BEFORE PRIVATE
$<BUILD_INTERFACE:${FFTW3_INCLUDE_DIR}>
@ -129,7 +135,7 @@ target_include_directories(musrRootValidation
target_link_libraries(musrRootValidation ${ROOT_LIBRARIES} ${MUSRFIT_LIBS} ${LIBXML2_LIBRARIES})
add_executable(musrt0 git-revision.h musrt0.cpp)
target_compile_options(musrt0 BEFORE PRIVATE "-DHAVE_CONFIG_H")
target_compile_options(musrt0 BEFORE PRIVATE "-DHAVE_CONFIG_H" "${HAVE_GIT_REV_H}")
target_include_directories(musrt0
BEFORE PRIVATE
$<BUILD_INTERFACE:${Boost_INCLUDE_DIR}>
@ -141,7 +147,7 @@ target_include_directories(musrt0
target_link_libraries(musrt0 ${ROOT_LIBRARIES} ${MUSRFIT_LIBS})
add_executable(musrview git-revision.h musrview.cpp)
target_compile_options(musrview BEFORE PRIVATE "-DHAVE_CONFIG_H")
target_compile_options(musrview BEFORE PRIVATE "-DHAVE_CONFIG_H" "${HAVE_GIT_REV_H}")
target_include_directories(musrview
BEFORE PRIVATE
$<BUILD_INTERFACE:${Boost_INCLUDE_DIR}>
@ -153,7 +159,7 @@ target_include_directories(musrview
target_link_libraries(musrview ${FFTW3_LIBRARY} ${ROOT_LIBRARIES} ${MUSRFIT_LIBS})
add_executable(write_musrRoot_runHeader git-revision.h write_musrRoot_runHeader.cpp)
target_compile_options(write_musrRoot_runHeader BEFORE PRIVATE "-DHAVE_CONFIG_H")
target_compile_options(write_musrRoot_runHeader BEFORE PRIVATE "-DHAVE_CONFIG_H" "${HAVE_GIT_REV_H}")
target_include_directories(write_musrRoot_runHeader
BEFORE PRIVATE
$<BUILD_INTERFACE:${FFTW3_INCLUDE_DIR}>

View File

@ -41,7 +41,10 @@
#include <TString.h>
#include <TSAXParser.h>
#ifdef HAVE_GIT_REV_H
#include "git-revision.h"
#endif
#include "PMusr.h"
#include "PStartupHandler.h"
#include "PRunDataHandler.h"
@ -197,9 +200,17 @@ int main(int argc, char *argv[])
any2many_syntax();
else if (strstr(argv[1], "--v")) {
#ifdef HAVE_CONFIG_H
#ifdef HAVE_GIT_REV_H
std::cout << std::endl << "any2many version: " << PACKAGE_VERSION << ", git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << " (" << BUILD_TYPE << "), ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl;
#else
std::cout << std::endl << "any2many version: " << PACKAGE_VERSION << " (" << BUILD_TYPE << "), ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl;
#endif
#else
#ifdef HAVE_GIT_REV_H
std::cout << std::endl << "any2many git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << std::endl << std::endl;
#else
std::cout << std::endl << "any2many version: unkown." << std::endl << std::endl;
#endif
#endif
} else {
any2many_syntax();

View File

@ -53,7 +53,10 @@
#include <TFolder.h>
#include <TString.h>
#ifdef HAVE_GIT_REV_H
#include "git-revision.h"
#endif
#include "PStartupHandler.h"
#include "TMusrRunHeader.h"
#include "TLemRunHeader.h"
@ -778,9 +781,17 @@ int main(int argc, char *argv[])
return 0;
} else if (!strcmp(argv[i], "--version") || !strcmp(argv[i], "-v")) {
#ifdef HAVE_CONFIG_H
#ifdef HAVE_GIT_REV_H
std::cout << std::endl << "dump_header version: " << PACKAGE_VERSION << ", git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << " (" << BUILD_TYPE << "), ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl;
#else
std::cout << std::endl << "dump_header version: " << PACKAGE_VERSION << " (" << BUILD_TYPE << "), ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl;
#endif
#else
#ifdef HAVE_GIT_REV_H
std::cout << std::endl << "dump_header git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << std::endl << std::endl;
#else
std::cout << std::endl << "dump_header version: unknown" << std::endl << std::endl;
#endif
#endif
return 0;
} else if (!strcmp(argv[i], "-rn") || !strcmp(argv[i], "--runNo")) {

View File

@ -36,7 +36,10 @@
#include "config.h"
#endif
#ifdef HAVE_GIT_REV_H
#include "git-revision.h"
#endif
#include "PMusr.h"
#include "PMsr2Data.h"
@ -512,9 +515,17 @@ int main(int argc, char *argv[])
return 0;
} else if (!strcmp(argv[1], "--version")) {
#ifdef HAVE_CONFIG_H
#ifdef HAVE_GIT_REV_H
std::cout << std::endl << "msr2data version: " << PACKAGE_VERSION << ", git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << " (" << BUILD_TYPE << "), ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl;
#else
std::cout << std::endl << "msr2data version: " << PACKAGE_VERSION << " (" << BUILD_TYPE << "), ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl;
#endif
#else
#ifdef HAVE_GIT_REV_H
std::cout << std::endl << "msr2data git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << std::endl << std::endl;
#else
std::cout << std::endl << "msr2data version: unknown." << std::endl << std::endl;
#endif
#endif
return 0;
} else {

View File

@ -44,7 +44,10 @@
#include <TObjString.h>
#include <TSAXParser.h>
#ifdef HAVE_GIT_REV_H
#include "git-revision.h"
#endif
#include "PMusr.h"
#include "PStartupHandler.h"
#include "PMsrHandler.h"
@ -297,9 +300,17 @@ Int_t musrFT_parse_options(Int_t argc, Char_t *argv[], musrFT_startup_param &sta
tstr = argv[i];
if (tstr.BeginsWith("--version")) {
#ifdef HAVE_CONFIG_H
#ifdef HAVE_GIT_REV_H
std::cout << std::endl << "musrFT version: " << PACKAGE_VERSION << ", git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << " (" << BUILD_TYPE << "), ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl;
#else
std::cout << std::endl << "musrFT version: " << PACKAGE_VERSION << " (" << BUILD_TYPE << "), ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl;
#endif
#else
#ifdef HAVE_GIT_REV_H
std::cout << std::endl << "musrFT git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << std::endl << std::endl;
#else
std::cout << std::endl << "musrFT version: unknown." << std::endl << std::endl;
#endif
#endif
return 1;
} else if (tstr.BeginsWith("--help")) {

View File

@ -48,7 +48,10 @@
#include <libxml/parser.h>
#include <libxml/xmlschemas.h>
#ifdef HAVE_GIT_REV_H
#include "git-revision.h"
#endif
#include "PMusr.h"
//-----------------------------------------------------------------------
@ -574,9 +577,17 @@ int main(int argc, char *argv[])
} else if (argc==2) {
if (!strcmp(argv[1], "--version")) {
#ifdef HAVE_CONFIG_H
#ifdef HAVE_GIT_REV_H
std::cout << std::endl << "musrRootValidation version: " << PACKAGE_VERSION << ", git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << " (" << BUILD_TYPE << "), ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl;
#else
std::cout << std::endl << "musrRootValidation version: " << PACKAGE_VERSION << " (" << BUILD_TYPE << "), ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl;
#endif
#else
#ifdef HAVE_GIT_REV_H
std::cout << std::endl << "musrRootValidation git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << std::endl << std::endl;
#else
std::cout << std::endl << "musrRootValidation version: unknown." << std::endl << std::endl;
#endif
#endif
return 0;
} else {

View File

@ -32,7 +32,9 @@ using namespace std;
#include <QApplication>
#ifdef HAVE_GIT_REV_H
#include "../include/git-revision.h"
#endif
#include "PTextEdit.h"
#include "PFitOutputHandler.h"
@ -53,7 +55,11 @@ int main( int argc, char ** argv )
cout << endl << endl;
return 0;
} else if (!strcmp(argv[1], "--version") || !strcmp(argv[1], "-v")) {
#ifdef HAVE_GIT_REV_H
cout << endl << "musredit git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1;
#else
cout << endl << "musredit version: unknown. ";
#endif
cout << endl << endl;
return 0;
}

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"
"${HAVE_GIT_REV_H}"
)
#--- add the variable related sources -----------------------------------------

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()
{
#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_COMMIT_HASH));
#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"
@ -525,7 +528,11 @@ int main(int argc, char *argv[])
mupp_syntax();
return 0;
} else if (!qstrcmp(argv[1], "-v") || !qstrcmp(argv[1], "--version")) {
#ifdef HAVE_GIT_REV_H
std::cout << std::endl << "mupp version: " << MUPP_VERSION << ", git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_COMMIT_HASH << 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) {

View File

@ -1,5 +1,12 @@
#--- musrWiz for Qt > 5.0 -----------------------------------------------------
#--- 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)
set(qt_libs Qt5::Core Qt5::Widgets Qt5::Svg Qt5::Xml)
set(musrWiz_src
@ -51,6 +58,11 @@ target_include_directories(musrWiz
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../include>
)
target_compile_options(musrWiz
PRIVATE
"${HAVE_GIT_REV_H}"
)
target_link_libraries(musrWiz ${qt_libs})
#--- installation info --------------------------------------------------------

View File

@ -1,5 +1,12 @@
#--- musredit for Qt > 5.0 ----------------------------------------------------
#--- 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)
set(qt_libs Qt5::Core Qt5::Widgets Qt5::Network Qt5::Xml Qt5::Svg Qt5::PrintSupport)
set(musredit_src
@ -116,6 +123,11 @@ target_include_directories(musredit
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../include>
)
target_compile_options(musredit
PRIVATE
"${HAVE_GIT_REV_H}"
)
target_link_libraries(musredit ${qt_libs})
#--- installation info --------------------------------------------------------

View File

@ -28,7 +28,9 @@
***************************************************************************/
#include "config.h"
#ifdef HAVE_GIT_REV_H
#include "git-revision.h"
#endif
#include "PMusrEditAbout.h"
//---------------------------------------------------------------------------
@ -39,8 +41,13 @@ PMusrEditAbout::PMusrEditAbout(QWidget *parent) : QDialog(parent)
{
setupUi(this);
#ifdef HAVE_GIT_REV_H
fGitBranch_label->setText(QString("git-branch: %1").arg(GIT_BRANCH));
fGitRev_label->setText(QString("git-rev: %1").arg(GIT_CURRENT_SHA1));
#else
fGitBranch_label->setText(QString("git-branch: unknown"));
fGitRev_label->setText(QString("git-rev: unknown"));
#endif
fMusrfitVersion_label->setText(QString("musrfit-version: %1 (%2)").arg(PACKAGE_VERSION).arg(BUILD_TYPE));
fRootVersion_label->setText(QString("ROOT-version: %1").arg(ROOT_VERSION_USED));

View File

@ -31,7 +31,10 @@
#include <QApplication>
#ifdef HAVE_GIT_REV_H
#include "git-revision.h"
#endif
#include "PTextEdit.h"
#include "PFitOutputHandler.h"
@ -52,7 +55,11 @@ int main( int argc, char ** argv )
std::cout << std::endl << std::endl;
return 0;
} else if (!strcmp(argv[1], "--version") || !strcmp(argv[1], "-v")) {
#ifdef HAVE_GIT_REV_H
std::cout << std::endl << "musredit git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1;
#else
std::cout << std::endl << "musredit git-branch: unknown, git-rev: unknown.";
#endif
std::cout << std::endl << std::endl;
return 0;
}

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"
"${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) {

View File

@ -1,5 +1,12 @@
#--- musrWiz for Qt > 6.0 -----------------------------------------------------
#--- 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)
set(qt_libs Qt6::Core Qt6::Widgets Qt6::Svg Qt6::Xml)
set(musrWiz_src
@ -51,6 +58,11 @@ target_include_directories(musrWiz
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../include>
)
target_compile_options(musrWiz
PRIVATE
"${HAVE_GIT_REV_H}"
)
target_link_libraries(musrWiz ${qt_libs})
#--- installation info --------------------------------------------------------

View File

@ -6,7 +6,10 @@
#include <QMessageBox>
#include <QObject>
#ifdef HAVE_GIT_REV_H
#include "git-revision.h"
#endif
#include "musrWiz.h"
#include "PAdmin.h"
#include "PMusrWiz.h"
@ -53,7 +56,11 @@ int main(int argc, char *argv[])
if (argc == 2) {
if (!strcmp(argv[1], "--version") || (!strcmp(argv[1], "-v"))) {
#ifdef HAVE_GIT_REV_H
std::cout << std::endl << "musrWiz - git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << std::endl << std::endl;
#else
std::cout << std::endl << "musrWiz - git-branch: unknown, git-rev: unknown." << std::endl << std::endl;
#endif
return 0;
} else if (!strcmp(argv[1], "--help")) {
musrWiz_syntax();

View File

@ -1,5 +1,12 @@
#--- musredit for Qt > 6.0 ----------------------------------------------------
#--- 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)
set(qt_libs Qt6::Core Qt6::Widgets Qt6::Network Qt6::Xml Qt6::Svg Qt6::PrintSupport)
set(musredit_src
@ -115,6 +122,11 @@ target_include_directories(musredit
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../include>
)
target_compile_options(musredit
PRIVATE
"${HAVE_GIT_REV_H}"
)
target_link_libraries(musredit ${qt_libs})
#--- installation info --------------------------------------------------------

View File

@ -28,7 +28,9 @@
***************************************************************************/
#include "config.h"
#ifdef HAVE_GIT_REV_H
#include "git-revision.h"
#endif
#include "PMusrEditAbout.h"
//---------------------------------------------------------------------------
@ -39,8 +41,13 @@ PMusrEditAbout::PMusrEditAbout(QWidget *parent) : QDialog(parent)
{
setupUi(this);
#ifdef HAVE_GIT_REV_H
fGitBranch_label->setText(QString("git-branch: %1").arg(GIT_BRANCH));
fGitRev_label->setText(QString("git-rev: %1").arg(GIT_CURRENT_SHA1));
#else
fGitBranch_label->setText(QString("git-branch: unknown"));
fGitRev_label->setText(QString("git-rev: unknown"));
#endif
fMusrfitVersion_label->setText(QString("musrfit-version: %1 (%2)").arg(PACKAGE_VERSION).arg(BUILD_TYPE));
fRootVersion_label->setText(QString("ROOT-version: %1").arg(ROOT_VERSION_USED));

View File

@ -31,7 +31,9 @@
#include <QApplication>
#ifdef HAVE_GIT_REV_H
#include "git-revision.h"
#endif
#include "PTextEdit.h"
#include "PFitOutputHandler.h"
@ -52,7 +54,11 @@ int main( int argc, char ** argv )
std::cout << std::endl << std::endl;
return 0;
} else if (!strcmp(argv[1], "--version") || !strcmp(argv[1], "-v")) {
#ifdef HAVE_GIT_REV_H
std::cout << std::endl << "musredit git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1;
#else
std::cout << std::endl << "musredit git-branch: unknown, git-rev: unknown.";
#endif
std::cout << std::endl << std::endl;
return 0;
}

View File

@ -50,7 +50,10 @@
#include <TSystemFile.h>
#include <TThread.h>
#ifdef HAVE_GIT_REV_H
#include "git-revision.h"
#endif
#include "PMusr.h"
#include "PStartupHandler.h"
#include "PMsrHandler.h"
@ -464,9 +467,17 @@ int main(int argc, char *argv[])
if (argc == 2) {
if (!strcmp(argv[1], "--version")) {
#ifdef HAVE_CONFIG_H
#ifdef HAVE_GIT_REV_H
std::cout << std::endl << "musrfit version: " << PACKAGE_VERSION << ", git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << " (" << BUILD_TYPE << "), ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl;
#else
std::cout << std::endl << "musrfit version: " << PACKAGE_VERSION << " (" << BUILD_TYPE << "), ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl;
#endif
#else
#ifdef HAVE_GIT_REV_H
std::cout << std::endl << "musrfit git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << std::endl << std::endl;
#else
std::cout << std::endl << "musrfit version: unknown" << std::endl << std::endl;
#endif
#endif
return PMUSR_SUCCESS;
} else if (!strcmp(argv[1], "--nexus-support")) {

View File

@ -42,7 +42,10 @@
#include <TROOT.h>
#include <TSystem.h>
#ifdef HAVE_GIT_REV_H
#include "git-revision.h"
#endif
#include "PMusr.h"
#include "PStartupHandler.h"
#include "PMsrHandler.h"
@ -237,9 +240,17 @@ Int_t main(Int_t argc, Char_t *argv[])
for (int i=1; i<argc; i++) {
if (!strcmp(argv[i], "--version")) {
#ifdef HAVE_CONFIG_H
#ifdef HAVE_GIT_REV_H
std::cout << std::endl << "musrt0 version: " << PACKAGE_VERSION << ", git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << " (" << BUILD_TYPE << "), ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl;
#else
std::cout << std::endl << "musrt0 version: " << PACKAGE_VERSION << " (" << BUILD_TYPE << "), ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl;
#endif
#else
#ifdef HAVE_GIT_REV_H
std::cout << std::endl << "musrt0 git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << std::endl << std::endl;
#else
std::cout << std::endl << "musrt0 version: unknown." << std::endl << std::endl;
#endif
#endif
return PMUSR_SUCCESS;
} else if (!strcmp(argv[i], "--help")) {

View File

@ -41,7 +41,10 @@
#include <TSAXParser.h>
#include <TROOT.h>
#ifdef HAVE_GIT_REV_H
#include "git-revision.h"
#endif
#include "PMusr.h"
#include "PStartupHandler.h"
#include "PMsrHandler.h"
@ -135,9 +138,17 @@ int main(int argc, char *argv[])
}
} else if (!strcmp(argv[i], "--version")) {
#ifdef HAVE_CONFIG_H
#ifdef HAVE_GIT_REV_H
std::cout << std::endl << "musrview version: " << PACKAGE_VERSION << ", git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << " (" << BUILD_TYPE << "), ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl;
#else
std::cout << std::endl << "musrview version: " << PACKAGE_VERSION << " (" << BUILD_TYPE << "), ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl;
#endif
#else
#ifdef HAVE_GIT_REV_H
std::cout << std::endl << "musrview git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << std::endl << std::endl;
#else
std::cout << std::endl << "musrview version: unknown." << std::endl << std::endl;
#endif
#endif
return PMUSR_SUCCESS;
} else if (!strcmp(argv[i], "--show-dynamic-path")) {

View File

@ -41,7 +41,10 @@
#include <TFile.h>
#include <TFolder.h>
#ifdef HAVE_GIT_REV_H
#include "git-revision.h"
#endif
#include "PMusr.h"
#include "TMusrRunHeader.h"
@ -61,9 +64,17 @@ int main(int argc, char *argv[])
if (!strcmp(argv[1], "--version")) {
#ifdef HAVE_CONFIG_H
#ifdef HAVE_GIT_REV_H
std::cout << std::endl << "write_musrRoot_runHeader version: " << PACKAGE_VERSION << ", git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << " (" << BUILD_TYPE << "), ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl;
#else
std::cout << std::endl << "write_musrRoot_runHeader version: " << PACKAGE_VERSION << " (" << BUILD_TYPE << "), ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl;
#endif
#else
#ifdef HAVE_GIT_REV_H
std::cout << std::endl << "write_musrRoot_runHeader git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << std::endl << std::endl;
#else
std::cout << std::endl << "write_musrRoot_runHeader version: unknown." << std::endl << std::endl;
#endif
#endif
return 0;
}