From 183835ee67a9930d9a3242efffeacdbd0e39fd8d Mon Sep 17 00:00:00 2001 From: Chris Pavlina Date: Sun, 25 Sep 2016 10:28:50 -0400 Subject: [PATCH] cmake: rewrite version header when branch changes Before, only KICAD_BUILD_VERSION, which includes the hash but not the branch, was compared when deciding whether to regenerate kicad_build_version.h. This header also contains the branch name though, so we should compare both to address the case of two branches pointing at the same commit. --- CMakeModules/CreateGitVersionHeader.cmake | 2 ++ CMakeModules/WriteVersionHeader.cmake | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CMakeModules/CreateGitVersionHeader.cmake b/CMakeModules/CreateGitVersionHeader.cmake index b9bfdf9479..b2317993d3 100644 --- a/CMakeModules/CreateGitVersionHeader.cmake +++ b/CMakeModules/CreateGitVersionHeader.cmake @@ -28,6 +28,7 @@ macro( create_git_version_header _git_src_path ) # branch name to unknown set( KICAD_BUILD_VERSION "no-git" ) set( KICAD_BRANCH_NAME ${KICAD_REPO_NAME} ) + set( KICAD_FULL_VERSION "${KICAD_BUILD_VERSION}-${KICAD_BRANCH_NAME}") # Include Git support to automagically create version header file. find_package( Git ) @@ -107,4 +108,5 @@ macro( create_git_version_header _git_src_path ) endif() set( KICAD_BUILD_VERSION ${KICAD_BUILD_VERSION} ) + set( KICAD_FULL_VERSION "${KICAD_BUILD_VERSION}-${KICAD_BRANCH_NAME}") endmacro() diff --git a/CMakeModules/WriteVersionHeader.cmake b/CMakeModules/WriteVersionHeader.cmake index da1b9a4168..735edb5bc3 100644 --- a/CMakeModules/WriteVersionHeader.cmake +++ b/CMakeModules/WriteVersionHeader.cmake @@ -50,8 +50,8 @@ set( _wvh_write_version_file ON ) # Compare the version argument against the version in the existing header file for a mismatch. if( EXISTS ${OUTPUT_FILE} ) file( STRINGS ${OUTPUT_FILE} _current_version_str - REGEX "^#define[\t ]+KICAD_BUILD_VERSION[\t ]+.*" ) - string( REGEX REPLACE "^#define KICAD_BUILD_VERSION \"([()a-zA-Z0-9 -.]+)\".*" + REGEX "^#define[\t ]+KICAD_FULL_VERSION[\t ]+.*" ) + string( REGEX REPLACE "^#define KICAD_FULL_VERSION \"([()a-zA-Z0-9 -.]+)\".*" "\\1" _wvh_last_version "${_current_version_str}" ) # No change, do not write version.h @@ -75,6 +75,7 @@ if( _wvh_write_version_file ) #define KICAD_BUILD_VERSION \"${_wvh_version_str}\" #define KICAD_BRANCH_NAME \"${KICAD_BRANCH_NAME}\" +#define KICAD_FULL_VERSION \"${KICAD_FULL_VERSION}\" #endif /* __KICAD_VERSION_H__ */ "