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.
This commit is contained in:
parent
bf4b26d73f
commit
47772e7ae3
|
@ -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()
|
||||
|
|
|
@ -46,8 +46,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
|
||||
|
@ -71,6 +71,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__ */
|
||||
"
|
||||
|
|
Loading…
Reference in New Issue