Add more info to versioninfo
This commit is contained in:
parent
e4250d05db
commit
cbe326a798
@ -15,7 +15,7 @@ project (
|
|||||||
find_package(Git REQUIRED)
|
find_package(Git REQUIRED)
|
||||||
|
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND "${GIT_EXECUTABLE}" describe --long --dirty=-WIP --tags
|
COMMAND "${GIT_EXECUTABLE}" describe --long --dirty --tags --match v[0-9]*
|
||||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||||
RESULT_VARIABLE git_result
|
RESULT_VARIABLE git_result
|
||||||
OUTPUT_VARIABLE git_tag
|
OUTPUT_VARIABLE git_tag
|
||||||
@ -23,20 +23,49 @@ execute_process(
|
|||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
ERROR_STRIP_TRAILING_WHITESPACE
|
ERROR_STRIP_TRAILING_WHITESPACE
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if( NOT git_result EQUAL 0 )
|
||||||
|
message( FATAL_ERROR "Failed to execute Git: ${git_error}" )
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if( git_tag MATCHES "v([0-9]+).([0-9]+).([0-9]+)-([0-9]+)-g([0-9,a-f]+)(-dirty)?" )
|
||||||
|
set( git_version_major "${CMAKE_MATCH_1}" )
|
||||||
|
set( git_version_minor "${CMAKE_MATCH_2}" )
|
||||||
|
set( git_version_patch "${CMAKE_MATCH_3}" )
|
||||||
|
set( git_commits_since_last_tag "${CMAKE_MATCH_4}" )
|
||||||
|
set( git_hash "${CMAKE_MATCH_5}" )
|
||||||
|
set( git_wip "${CMAKE_MATCH_6}" )
|
||||||
|
else()
|
||||||
|
message( FATAL_ERROR "Git tag isn't valid semantic version: [${git_tag}]" )
|
||||||
|
endif()
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND "${GIT_EXECUTABLE}" rev-parse --abbrev-ref HEAD
|
||||||
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||||
|
RESULT_VARIABLE git_result
|
||||||
|
OUTPUT_VARIABLE git_current_branch
|
||||||
|
ERROR_VARIABLE git_error
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
ERROR_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
if( NOT git_result EQUAL 0 )
|
if( NOT git_result EQUAL 0 )
|
||||||
message( FATAL_ERROR "Failed to execute Git: ${git_error}" )
|
message( FATAL_ERROR "Failed to execute Git: ${git_error}" )
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if( git_tag MATCHES "([0-9]+).([0-9]+).([0-9]+)-?([0-9]+)?-g([0-9,a-f]+)" )
|
if(${git_commits_since_last_tag} EQUAL 0)
|
||||||
set( git_version_major "${CMAKE_MATCH_1}" )
|
set (PRERELEASE 0)
|
||||||
set( git_version_minor "${CMAKE_MATCH_2}" )
|
|
||||||
set( git_version_patch "${CMAKE_MATCH_3}" )
|
|
||||||
set( git_commits_since_last_tag "${CMAKE_MATCH_4}" )
|
|
||||||
set( git_hash "${CMAKE_MATCH_5}" )
|
|
||||||
else()
|
else()
|
||||||
message( FATAL_ERROR "Git tag isn't valid semantic version: [${git_tag}]" )
|
set (PRERELEASE 1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set(BUILD_BRANCH ${git_current_branch})
|
||||||
|
if(BUILD_BRANCH STREQUAL "master")
|
||||||
|
set (SPECIALBUILD 0)
|
||||||
|
else()
|
||||||
|
set (SPECIALBUILD 1)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
set (PROJECT_VERSION_MAJOR ${git_version_major})
|
set (PROJECT_VERSION_MAJOR ${git_version_major})
|
||||||
set (PROJECT_VERSION_MINOR ${git_version_minor})
|
set (PROJECT_VERSION_MINOR ${git_version_minor})
|
||||||
set (PROJECT_VERSION_PATCH ${git_version_patch})
|
set (PROJECT_VERSION_PATCH ${git_version_patch})
|
||||||
@ -45,7 +74,14 @@ if(NOT PROJECT_VERSION_TWEAK)
|
|||||||
set(PROJECT_VERSION_TWEAK 0)
|
set(PROJECT_VERSION_TWEAK 0)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set (PROJECT_VERSION "${git_version_major}.${git_version_minor}.${git_version_patch}.${git_commits_since_last_tag}-g${git_hash}")
|
if(git_wip)
|
||||||
|
set (DIRTY_BUILD 1)
|
||||||
|
else()
|
||||||
|
set (DIRTY_BUILD 0)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
set (PROJECT_VERSION "${git_version_major}.${git_version_minor}.${git_version_patch}.${git_commits_since_last_tag}-g${git_hash}${git_wip}")
|
||||||
message(STATUS "Version: ${PROJECT_VERSION}")
|
message(STATUS "Version: ${PROJECT_VERSION}")
|
||||||
|
|
||||||
# Set output directories
|
# Set output directories
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
#include "version.h"
|
#include "version.h"
|
||||||
#include "Windows.h"
|
#include <Windows.h>
|
||||||
|
|
||||||
|
/* VERSIONINFO can be read with the WINAPI https://msdn.microsoft.com/en-us/library/windows/desktop/ms647003(v=vs.85).aspx
|
||||||
|
or by POWERSHELL:
|
||||||
|
PS> (dir *.exe).VersionInfo|fl
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef DEBUG
|
#ifndef DEBUG
|
||||||
#define VER_DEBUG 0
|
#define VER_DEBUG 0
|
||||||
@ -7,14 +12,34 @@
|
|||||||
#define VER_DEBUG VS_FF_DEBUG
|
#define VER_DEBUG VS_FF_DEBUG
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define VER_PRIVATEBUILD 0
|
// DIRTY_BUILD (patched) if there are uncommitted changes
|
||||||
#define VER_PRERELEASE VS_FF_PRERELEASE
|
#if DIRTY_BUILD
|
||||||
|
#define VER_PATCHED VS_FF_PATCHED
|
||||||
|
#else
|
||||||
|
#define VER_PATCHED 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// SPECIALBUILD if build from a different branch then master
|
||||||
|
#if SPECIALBUILD
|
||||||
|
#define VER_SPECIALBUILD VS_FF_SPECIALBUILD
|
||||||
|
#else
|
||||||
|
#define VER_SPECIALBUILD 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// PRERELEASE if its not build on a tag
|
||||||
|
#if PRERELEASE
|
||||||
|
#define VER_PRERELEASE VS_FF_PRERELEASE
|
||||||
|
#else
|
||||||
|
#define VER_PRERELEASE 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define VER_PRIVATEBUILD 0
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION VER_FILEVERSION
|
FILEVERSION VER_FILEVERSION
|
||||||
PRODUCTVERSION VER_PRODUCTVERSION
|
PRODUCTVERSION VER_PRODUCTVERSION
|
||||||
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
||||||
FILEFLAGS (VER_PRIVATEBUILD|VER_PRERELEASE|VER_DEBUG)
|
FILEFLAGS (VER_PRIVATEBUILD | VER_PRERELEASE | VER_DEBUG | VER_PATCHED | VER_SPECIALBUILD)
|
||||||
FILEOS VOS__WINDOWS32
|
FILEOS VOS__WINDOWS32
|
||||||
FILETYPE VFT_APP
|
FILETYPE VFT_APP
|
||||||
FILESUBTYPE VFT2_UNKNOWN
|
FILESUBTYPE VFT2_UNKNOWN
|
||||||
@ -33,6 +58,9 @@ BEGIN
|
|||||||
VALUE "OriginalFilename", VER_ORIGINALFILENAME_STR
|
VALUE "OriginalFilename", VER_ORIGINALFILENAME_STR
|
||||||
VALUE "ProductName", VER_PRODUCTNAME_STR
|
VALUE "ProductName", VER_PRODUCTNAME_STR
|
||||||
VALUE "ProductVersion", VER_PRODUCTVERSION_STR
|
VALUE "ProductVersion", VER_PRODUCTVERSION_STR
|
||||||
|
#if SPECIALBUILD
|
||||||
|
VALUE "SpecialBuild", "Build on branch " BUILD_BRANCH
|
||||||
|
#endif
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
|
|
||||||
|
@ -23,6 +23,11 @@
|
|||||||
#define VER_PRODUCTNAME_STR PROJECT_NAME
|
#define VER_PRODUCTNAME_STR PROJECT_NAME
|
||||||
#define VER_PRODUCTVERSION_STR VER_FILEVERSION_STR
|
#define VER_PRODUCTVERSION_STR VER_FILEVERSION_STR
|
||||||
|
|
||||||
|
#define DIRTY_BUILD @DIRTY_BUILD@
|
||||||
|
#define SPECIALBUILD @SPECIALBUILD@
|
||||||
|
#define BUILD_BRANCH "@BUILD_BRANCH@"
|
||||||
|
#define PRERELEASE @PRERELEASE@
|
||||||
|
|
||||||
/* Copyright string */
|
/* Copyright string */
|
||||||
#cmakedefine PROJECT_COPYRIGHT "@PROJECT_COPYRIGHT@"
|
#cmakedefine PROJECT_COPYRIGHT "@PROJECT_COPYRIGHT@"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user