mirror of
https://github.com/zephyrproject-rtos/zephyr.git
synced 2024-12-04 10:18:24 +08:00
a880fb1343
- Add examples for the latter. - Point at each other and highlight how independent they are from each other. - State their inputs and outputs in plain English. - Fix "git describe" error message giving the wrong impression that everyone cares about BUILD_VERSION. Only the boot banner cares now. Signed-off-by: Marc Herbert <marc.herbert@intel.com>
33 lines
1.0 KiB
CMake
33 lines
1.0 KiB
CMake
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
#.rst:
|
|
# git.cmake
|
|
# ---------
|
|
# If the user didn't already define BUILD_VERSION then try to initialize
|
|
# it with the output of "git describe". Warn but don't error if
|
|
# everything fails and leave BUILD_VERSION undefined.
|
|
#
|
|
# See also: independent and more static ``KERNEL_VERSION_*`` in
|
|
# ``version.cmake`` and ``kernel_version.h``
|
|
|
|
|
|
# https://cmake.org/cmake/help/latest/module/FindGit.html
|
|
find_package(Git QUIET)
|
|
if(NOT BUILD_VERSION AND 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};
|
|
BUILD_VERSION is left undefined")
|
|
elseif(CMAKE_VERBOSE_MAKEFILE)
|
|
message(STATUS "git describe stderr: ${stderr}")
|
|
endif()
|
|
endif()
|