mirror of
https://github.com/vsergeev/c-periphery.git
synced 2026-02-06 23:42:24 +08:00
cmake: fix identifying COMMIT_ID within build system
When using a Buildroot (a build system for generating Embedded Linux images) to cross compile the c-periphery package, the git commit ID from Buildroot will be used if Buildroot itself is a Git repo. For example, Buildroot will perform a build of c-periphery at: buildroot/output/build/c-periphery The buildroot directory is a Git repo but the c-periphery source folder is not. The following command: git describe will use the top-level '.git' directory in buildroot for getting the COMMIT_ID. It will then populate the buildroot COMMIT_ID for c-periphery itself instead of putting in 'unknown'. Utilize '--git-dir=' option to force it to only use the '.git' directory from within the top-level c-periphery folder. Signed-off-by: Ryan Barnett <ryan.barnett@rockwellcollins.com> Modifications to original commit: * Add "/.git" suffix to path passed to --git-dir option Signed-off-by: Vanya A. Sergeev <v@sergeev.io>
This commit is contained in:
committed by
Vanya A. Sergeev
parent
76b7c224d4
commit
ea1e0da26f
@@ -19,7 +19,7 @@ file(GLOB_RECURSE periphery_TESTS tests/*.c)
|
||||
|
||||
# Expose git commit id into COMMIT_ID variable
|
||||
execute_process(
|
||||
COMMAND git describe --abbrev --always --tags --dirty
|
||||
COMMAND git --git-dir="${CMAKE_CURRENT_SOURCE_DIR}/.git" describe --abbrev --always --tags --dirty
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
OUTPUT_VARIABLE COMMIT_ID
|
||||
ERROR_QUIET
|
||||
|
||||
Reference in New Issue
Block a user