From 38f1288571aadd159df2b5c9b5e80d5c4cd50782 Mon Sep 17 00:00:00 2001 From: brunoherbelin Date: Tue, 23 Feb 2021 20:04:37 +0100 Subject: [PATCH] Reading version from git --- CMakeLists.txt | 28 ++++++++++++++++++++++++++-- Settings.cpp | 10 +++++++--- UserInterfaceManager.cpp | 9 ++++++++- defines.h | 2 -- 4 files changed, 41 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 039859b..f225a5c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,28 @@ cmake_minimum_required(VERSION 3.8.0) project(vimix VERSION 0.0.1 LANGUAGES CXX C) +# use git +find_package (Git) +if(GIT_EXECUTABLE) + execute_process( + COMMAND ${GIT_EXECUTABLE} describe --tags + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + OUTPUT_VARIABLE GIT_DESCRIBE_VERSION + RESULT_VARIABLE GIT_DESCRIBE_ERROR_CODE + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(NOT GIT_DESCRIBE_ERROR_CODE) + string(SUBSTRING ${GIT_DESCRIBE_VERSION} 0 1 VIMIX_VERSION_MAJOR) + string(SUBSTRING ${GIT_DESCRIBE_VERSION} 2 1 VIMIX_VERSION_MINOR) + string(SUBSTRING ${GIT_DESCRIBE_VERSION} 4 1 VIMIX_VERSION_PATCH) + add_definitions(-DVIMIX_VERSION_MAJOR=${VIMIX_VERSION_MAJOR}) + add_definitions(-DVIMIX_VERSION_MINOR=${VIMIX_VERSION_MINOR}) + add_definitions(-DVIMIX_VERSION_PATCH=${VIMIX_VERSION_PATCH}) + endif() +endif() + +message(STATUS "Compiling vimix version ${VIMIX_VERSION_MAJOR}.${VIMIX_VERSION_MINOR}.${VIMIX_VERSION_PATCH}") + set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "ON") set(CMAKE_INCLUDE_CURRENTDIR ON) set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ) @@ -34,6 +56,7 @@ endif() # Include the CMake RC module include(CMakeRC) + # # GSTREAMER # @@ -483,8 +506,9 @@ SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "vimix\n Real-time video mixing for live p SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md") SET(CPACK_PACKAGE_CONTACT "bruno.herbelin@gmail.com") SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING.txt") -SET(CPACK_PACKAGE_VERSION_MAJOR "0") -SET(CPACK_PACKAGE_VERSION_MINOR "5") +SET(CPACK_PACKAGE_VERSION_MAJOR "${VIMIX_VERSION_MAJOR}") +SET(CPACK_PACKAGE_VERSION_MINOR "${VIMIX_VERSION_MINOR}") +SET(CPACK_PACKAGE_VERSION_PATCH "${VIMIX_VERSION_PATCH}") SET(CPACK_PACKAGE_VENDOR "Bruno Herbelin") SET(CPACK_SOURCE_IGNORE_FILES "/\\\\.git/" diff --git a/Settings.cpp b/Settings.cpp index 74e5e40..c78d97b 100644 --- a/Settings.cpp +++ b/Settings.cpp @@ -22,9 +22,11 @@ void Settings::Save() xmlDoc.InsertFirstChild(pDec); XMLElement *pRoot = xmlDoc.NewElement(application.name.c_str()); - pRoot->SetAttribute("major", APP_VERSION_MAJOR); - pRoot->SetAttribute("minor", APP_VERSION_MINOR); +#ifdef VIMIX_VERSION_MAJOR + pRoot->SetAttribute("major", VIMIX_VERSION_MAJOR); + pRoot->SetAttribute("minor", VIMIX_VERSION_MINOR); xmlDoc.InsertEndChild(pRoot); +#endif string comment = "Settings for " + application.name; XMLComment *pComment = xmlDoc.NewComment(comment.c_str()); @@ -233,12 +235,14 @@ void Settings::Load() if (application.name.compare( string( pRoot->Value() ) ) != 0 ) return; +#ifdef VIMIX_VERSION_MAJOR // cancel on different version int version_major = -1, version_minor = -1; pRoot->QueryIntAttribute("major", &version_major); pRoot->QueryIntAttribute("minor", &version_minor); - if (version_major != APP_VERSION_MAJOR || version_minor != APP_VERSION_MINOR) + if (version_major != VIMIX_VERSION_MAJOR || version_minor != VIMIX_VERSION_MINOR) return; +#endif XMLElement * applicationNode = pRoot->FirstChildElement("Application"); if (applicationNode != nullptr) { diff --git a/UserInterfaceManager.cpp b/UserInterfaceManager.cpp index 2cb9460..2e9588d 100644 --- a/UserInterfaceManager.cpp +++ b/UserInterfaceManager.cpp @@ -3042,9 +3042,16 @@ void UserInterface::RenderAbout(bool* p_open) return; } +#ifdef VIMIX_VERSION_MAJOR ImGuiToolkit::PushFont(ImGuiToolkit::FONT_BOLD); - ImGui::Text("%s %d.%d", APP_NAME, APP_VERSION_MAJOR, APP_VERSION_MINOR); + ImGui::Text("%s %d.%d.%d", APP_NAME, VIMIX_VERSION_MAJOR, VIMIX_VERSION_MINOR, VIMIX_VERSION_PATCH); ImGui::PopFont(); +#else + ImGuiToolkit::PushFont(ImGuiToolkit::FONT_BOLD); + ImGui::Text("%s", APP_NAME); + ImGui::PopFont(); +#endif + ImGui::Separator(); ImGui::Text("vimix performs graphical mixing and blending of\nseveral movie clips and computer generated graphics,\nwith image processing effects in real-time."); ImGui::Text("\nvimix is licensed under the GNU GPL version 3.\nCopyright 2019-2020 Bruno Herbelin."); diff --git a/defines.h b/defines.h index a5b2e31..0afc909 100644 --- a/defines.h +++ b/defines.h @@ -4,8 +4,6 @@ #define APP_NAME "vimix" #define APP_TITLE " -- Video Live Mixer" #define APP_SETTINGS "vimix.xml" -#define APP_VERSION_MAJOR 0 -#define APP_VERSION_MINOR 5 #define XML_VERSION_MAJOR 0 #define XML_VERSION_MINOR 2 #define MAX_RECENT_HISTORY 20