From f97a0fb3e912ab3976809165a4c2c5709bf4e0a8 Mon Sep 17 00:00:00 2001 From: Marek Roszko Date: Sat, 15 Jan 2022 15:20:27 -0500 Subject: [PATCH] Add a way to add a "revision" for use in windows manifests (cherry picked from commit d4ee74a832561f4216a799aa51a331239aba4604) --- CMakeModules/BuildSteps/WriteVersionHeader.cmake | 6 +++--- CMakeModules/CreateGitVersionHeader.cmake | 10 ++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CMakeModules/BuildSteps/WriteVersionHeader.cmake b/CMakeModules/BuildSteps/WriteVersionHeader.cmake index 7fbcdbca8e..c9add10375 100644 --- a/CMakeModules/BuildSteps/WriteVersionHeader.cmake +++ b/CMakeModules/BuildSteps/WriteVersionHeader.cmake @@ -38,10 +38,10 @@ if( CMAKE_MATCH_COUNT EQUAL 2 ) set( KICAD_MAJOR_MINOR_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}" ) set( KICAD_MAJOR_MINOR_VERSION_TUPLE "{ ${CMAKE_MATCH_1}, ${CMAKE_MATCH_2} }" ) set( KICAD_MAJOR_VERSION "${CMAKE_MATCH_1}" ) - set( KICAD_WIN32_RC_FILEVER_STR "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.0.0\\0" ) - set( KICAD_WIN32_RC_FILEVER "${CMAKE_MATCH_1}, ${CMAKE_MATCH_2}, 0, 0" ) + set( KICAD_WIN32_RC_FILEVER_STR "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.0.${KICAD_GIT_REV}\\0" ) + set( KICAD_WIN32_RC_FILEVER "${CMAKE_MATCH_1}, ${CMAKE_MATCH_2}, 0, ${KICAD_GIT_REV}" ) set( KICAD_WIN32_RC_PRODVER_STR "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}\\0" ) - set( KICAD_WIN32_RC_PRODVER "${CMAKE_MATCH_1}, ${CMAKE_MATCH_2}, 0, 0" ) + set( KICAD_WIN32_RC_PRODVER "${CMAKE_MATCH_1}, ${CMAKE_MATCH_2}, 0, ${KICAD_GIT_REV}" ) else() message( FATAL_ERROR "Unable to extract major and minor version string" ) endif() diff --git a/CMakeModules/CreateGitVersionHeader.cmake b/CMakeModules/CreateGitVersionHeader.cmake index 1b2ac483a5..0c10fb61ec 100644 --- a/CMakeModules/CreateGitVersionHeader.cmake +++ b/CMakeModules/CreateGitVersionHeader.cmake @@ -42,6 +42,15 @@ macro( create_git_version_header _git_src_path ) RESULT_VARIABLE _git_log_result OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process( + COMMAND + ${GIT_EXECUTABLE} rev-list --count --first-parent HEAD + WORKING_DIRECTORY ${_git_src_path} + OUTPUT_VARIABLE _git_REV_COUNT + ERROR_VARIABLE _git_log_error + RESULT_VARIABLE _git_log_result + OUTPUT_STRIP_TRAILING_WHITESPACE) + set( ENV{LC_ALL} ${_Git_SAVED_LC_ALL} ) endif( GIT_FOUND ) @@ -49,6 +58,7 @@ macro( create_git_version_header _git_src_path ) # to KiCadVersion.cmake as the revision level. if( _git_DESCRIBE ) set( KICAD_VERSION "(${_git_DESCRIBE})" ) + set( KICAD_GIT_REV "${_git_REV_COUNT}" ) endif() endmacro()