From 668b4bf481b98a4c7096baa4e115bf406ac7a965 Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Mon, 12 Jul 2021 16:00:19 +0200 Subject: [PATCH] more work on the none git source version. --- src/musredit_qt5/musrStep/CMakeLists.txt | 12 ++++++++++++ src/musredit_qt5/musrStep/musrStep.cpp | 8 +++++++- src/musredit_qt6/musrStep/CMakeLists.txt | 12 ++++++++++++ src/musredit_qt6/musrStep/musrStep.cpp | 8 +++++++- 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/musredit_qt5/musrStep/CMakeLists.txt b/src/musredit_qt5/musrStep/CMakeLists.txt index 907d4b46..ff1f889f 100644 --- a/src/musredit_qt5/musrStep/CMakeLists.txt +++ b/src/musredit_qt5/musrStep/CMakeLists.txt @@ -1,5 +1,12 @@ #--- musrStep 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) set(musrStep_src @@ -47,6 +54,11 @@ target_include_directories(musrStep $ ) +target_compile_options(musrWiz + PRIVATE + "${HAVE_GIT_REV_H}" +) + target_link_libraries(musrStep ${qt_libs}) #--- installation info -------------------------------------------------------- diff --git a/src/musredit_qt5/musrStep/musrStep.cpp b/src/musredit_qt5/musrStep/musrStep.cpp index b2314b26..9742ff61 100644 --- a/src/musredit_qt5/musrStep/musrStep.cpp +++ b/src/musredit_qt5/musrStep/musrStep.cpp @@ -5,7 +5,9 @@ #include +#ifdef HAVE_GIT_REV_H #include "git-revision.h" +#endif #include "PMusrStep.h" //------------------------------------------------------------------------- @@ -29,7 +31,11 @@ int main(int argc, char *argv[]) return 1; } else { if (!strcmp(argv[1], "--version") || (!strcmp(argv[1], "-v"))) { - std::cout << std::endl << "musrStep git-rev: " << GIT_CURRENT_SHA1 << std::endl << std::endl; +#ifdef HAVE_GIT_REV_H + std::cout << std::endl << "musrStep - git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << std::endl << std::endl; +#else + std::cout << std::endl << "musrStep - git-branch: unknown, git-rev: unknown" << std::endl << std::endl; +#endif return 0; } else if (!strcmp(argv[1], "--help") || (!strcmp(argv[1], "-h"))) { musrStep_syntax(); diff --git a/src/musredit_qt6/musrStep/CMakeLists.txt b/src/musredit_qt6/musrStep/CMakeLists.txt index 95e8af95..623cebcf 100644 --- a/src/musredit_qt6/musrStep/CMakeLists.txt +++ b/src/musredit_qt6/musrStep/CMakeLists.txt @@ -1,5 +1,12 @@ #--- musrStep 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) set(musrStep_src @@ -47,6 +54,11 @@ target_include_directories(musrStep $ ) +target_compile_options(musrStep + PRIVATE + "${HAVE_GIT_REV_H}" +) + target_link_libraries(musrStep ${qt_libs}) #--- installation info -------------------------------------------------------- diff --git a/src/musredit_qt6/musrStep/musrStep.cpp b/src/musredit_qt6/musrStep/musrStep.cpp index b2314b26..9742ff61 100644 --- a/src/musredit_qt6/musrStep/musrStep.cpp +++ b/src/musredit_qt6/musrStep/musrStep.cpp @@ -5,7 +5,9 @@ #include +#ifdef HAVE_GIT_REV_H #include "git-revision.h" +#endif #include "PMusrStep.h" //------------------------------------------------------------------------- @@ -29,7 +31,11 @@ int main(int argc, char *argv[]) return 1; } else { if (!strcmp(argv[1], "--version") || (!strcmp(argv[1], "-v"))) { - std::cout << std::endl << "musrStep git-rev: " << GIT_CURRENT_SHA1 << std::endl << std::endl; +#ifdef HAVE_GIT_REV_H + std::cout << std::endl << "musrStep - git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << std::endl << std::endl; +#else + std::cout << std::endl << "musrStep - git-branch: unknown, git-rev: unknown" << std::endl << std::endl; +#endif return 0; } else if (!strcmp(argv[1], "--help") || (!strcmp(argv[1], "-h"))) { musrStep_syntax();