mirror of
https://github.com/zephyrproject-rtos/zephyr
synced 2025-08-09 05:55:22 +00:00
Hardcode --abbrev=12 not to depend on personal git config preference. 12 is deemed large enough for the Linux kernel which should leave some room: https://public-inbox.org/git/xmqq37knwcf4.fsf@gitster.mtv.corp.google.com/ Signed-off-by: Marc Herbert <marc.herbert@intel.com>
21 lines
713 B
CMake
21 lines
713 B
CMake
# Use git if it is installed, to set BUILD_VERSION
|
|
|
|
# https://cmake.org/cmake/help/latest/module/FindGit.html
|
|
find_package(Git QUIET)
|
|
if(GIT_FOUND)
|
|
execute_process(
|
|
COMMAND ${GIT_EXECUTABLE} describe --abbrev=12
|
|
WORKING_DIRECTORY ${ZEPHYR_BASE}
|
|
OUTPUT_VARIABLE BUILD_VERSION
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
ERROR_STRIP_TRAILING_WHITESPACE
|
|
ERROR_VARIABLE stderr
|
|
RESULT_VARIABLE return_code
|
|
)
|
|
if(return_code)
|
|
message(STATUS "git describe failed: ${stderr}; ${KERNEL_VERSION_STRING} will be used instead")
|
|
elseif(CMAKE_VERBOSE_MAKEFILE)
|
|
message(STATUS "git describe stderr: ${stderr}")
|
|
endif()
|
|
endif()
|