diff --git a/CMakeLists.txt b/CMakeLists.txt index c470020..c3849c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,9 @@ cmake_minimum_required(VERSION 3.10) +option(GIT_TAG "The current git tag") + include(external/MunkeiVersionFromGit.cmake) -version_from_git() +version_from_git(${GIT_TAG}) # Change obs-plugintemplate to your plugin's name in a machine-readable format # (e.g.: obs-myawesomeplugin) and set diff --git a/external/MunkeiVersionFromGit.cmake b/external/MunkeiVersionFromGit.cmake index 15ab0d2..48c48bd 100644 --- a/external/MunkeiVersionFromGit.cmake +++ b/external/MunkeiVersionFromGit.cmake @@ -24,64 +24,8 @@ cmake_minimum_required( VERSION 3.0.0 ) include( CMakeParseArguments ) -function( version_from_git ) +function( version_from_git git_tag ) # Parse arguments - set( options OPTIONAL FAST ) - set( oneValueArgs - GIT_EXECUTABLE - INCLUDE_HASH - LOG - TIMESTAMP - ) - set( multiValueArgs ) - cmake_parse_arguments( ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) - - # Defaults - if( NOT DEFINED ARG_INCLUDE_HASH ) - set( ARG_INCLUDE_HASH ON ) - endif() - - if( DEFINED ARG_GIT_EXECUTABLE ) - set( GIT_EXECUTABLE "${ARG_GIT_EXECUTABLE}" ) - else () - # Find Git or bail out - find_package( Git ) - if( NOT GIT_FOUND ) - message( FATAL_ERROR "[MunkeiVersionFromGit] Git not found" ) - endif( NOT GIT_FOUND ) - endif() - - # Git describe - execute_process( - COMMAND "${GIT_EXECUTABLE}" describe --tags - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" - RESULT_VARIABLE git_result - OUTPUT_VARIABLE git_describe - ERROR_VARIABLE git_error - OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_STRIP_TRAILING_WHITESPACE - ) - if( NOT git_result EQUAL 0 ) - message( FATAL_ERROR - "[MunkeiVersionFromGit] Failed to execute Git: ${git_error}" - ) - endif() - - # Get Git tag - execute_process( - COMMAND "${GIT_EXECUTABLE}" describe --tags --abbrev=0 - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" - RESULT_VARIABLE git_result - OUTPUT_VARIABLE git_tag - ERROR_VARIABLE git_error - OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_STRIP_TRAILING_WHITESPACE - ) - if( NOT git_result EQUAL 0 ) - message( FATAL_ERROR - "[MunkeiVersionFromGit] Failed to execute Git: ${git_error}" - ) - endif() if( git_tag MATCHES "^v(0|[1-9][0-9]*)[.](0|[1-9][0-9]*)[.](0|[1-9][0-9]*)(-[.0-9A-Za-z-]+)?([+][.0-9A-Za-z-]+)?$" ) set( version_major "${CMAKE_MATCH_1}" )