cmake: fix issue with parsing version file located in /VERSION
Fixes: #71384 A VERSION file placed in `/` or `<drive>:\` was accidentally being picked up during `find_package(Zephyr)`. This happened because Zephyr loads the VERSION file to determine if it is the correct Zephyr to use. During initial phase of find_package(), then APPLICATION_SOURCE_DIR is not defined, causing one version file to be picked up from `/VERSION` instead of `<app>/VERSION`. `/VERSION` is outside any Zephyr repo, west workspace, or the application itself and therefore should not be picked up accidentally. Fix this be checking that APPLICATION_SOURCE_DIR is defined, and only when defined, look for a VERSION file there. Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit is contained in:
parent
e1ef3e41de
commit
4959a0241e
|
@ -36,8 +36,12 @@
|
|||
# The final load of `version.cmake` will setup correct build version values.
|
||||
|
||||
if(NOT DEFINED VERSION_FILE AND NOT DEFINED VERSION_TYPE)
|
||||
set(VERSION_FILE ${ZEPHYR_BASE}/VERSION ${APPLICATION_SOURCE_DIR}/VERSION)
|
||||
set(VERSION_TYPE KERNEL APP)
|
||||
set(VERSION_FILE ${ZEPHYR_BASE}/VERSION)
|
||||
set(VERSION_TYPE KERNEL)
|
||||
if(DEFINED APPLICATION_SOURCE_DIR)
|
||||
list(APPEND VERSION_FILE ${APPLICATION_SOURCE_DIR}/VERSION)
|
||||
list(APPEND VERSION_TYPE APP)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
foreach(type file IN ZIP_LISTS VERSION_TYPE VERSION_FILE)
|
||||
|
|
Loading…
Reference in a new issue