cmake: get: using NOT DEFINE BUILD_VERSION instead of NOT BUILD_VERSION

If user is specifying `-DBUILD_VERSION=<value>` then the proper way to
test is using `NOT DEFINED BUILD_VERSION`.

The difference between `NOT DEFINED BUILD_VERSION` and
`NOT BUILD_VERSION` is that a user specifying `-DBUILD_VERSION=0` will
result in `NOT BUILD_VERSION` becoming true, whereas
`NOT DEFINED BUILD_VERSION` would be false, which is the correct
behavior here, as the user actually provided a specific BUILD_VERSION.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit is contained in:
Torsten Rasmussen 2021-05-07 11:41:09 +02:00 committed by Anas Nashif
commit 8ff65f4087

View file

@ -13,7 +13,7 @@
# https://cmake.org/cmake/help/latest/module/FindGit.html # https://cmake.org/cmake/help/latest/module/FindGit.html
find_package(Git QUIET) find_package(Git QUIET)
if(NOT BUILD_VERSION AND GIT_FOUND) if(NOT DEFINED BUILD_VERSION AND GIT_FOUND)
execute_process( execute_process(
COMMAND ${GIT_EXECUTABLE} describe --abbrev=12 --always COMMAND ${GIT_EXECUTABLE} describe --abbrev=12 --always
WORKING_DIRECTORY ${ZEPHYR_BASE} WORKING_DIRECTORY ${ZEPHYR_BASE}