Skip to content

Commit 4959a02

Browse files
tejlmandaescolar
authored andcommitted
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 <[email protected]>
1 parent e1ef3e4 commit 4959a02

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

cmake/modules/version.cmake

+6-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,12 @@
3636
# The final load of `version.cmake` will setup correct build version values.
3737

3838
if(NOT DEFINED VERSION_FILE AND NOT DEFINED VERSION_TYPE)
39-
set(VERSION_FILE ${ZEPHYR_BASE}/VERSION ${APPLICATION_SOURCE_DIR}/VERSION)
40-
set(VERSION_TYPE KERNEL APP)
39+
set(VERSION_FILE ${ZEPHYR_BASE}/VERSION)
40+
set(VERSION_TYPE KERNEL)
41+
if(DEFINED APPLICATION_SOURCE_DIR)
42+
list(APPEND VERSION_FILE ${APPLICATION_SOURCE_DIR}/VERSION)
43+
list(APPEND VERSION_TYPE APP)
44+
endif()
4145
endif()
4246

4347
foreach(type file IN ZIP_LISTS VERSION_TYPE VERSION_FILE)

0 commit comments

Comments
 (0)