Skip to content

Commit 657462d

Browse files
committed
build: Set compiler specific macro inclusion of VERSION_H
Set compiler specific macro inclusion of the version.h just like the autoconf.h, so that the kernel version is accessible everywhere. Signed-off-by: Yong Cong Sin <[email protected]>
1 parent cd506ed commit 657462d

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

CMakeLists.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,8 @@ endif()
286286

287287
# @Intent: Set compiler specific macro inclusion of AUTOCONF_H
288288
zephyr_compile_options("SHELL: $<TARGET_PROPERTY:compiler,imacros> ${AUTOCONF_H}")
289+
# @Intent: Set compiler specific macro inclusion of VERSION_H
290+
zephyr_compile_options("SHELL: $<TARGET_PROPERTY:compiler,imacros> ${VERSION_H}")
289291

290292
if(CONFIG_COMPILER_FREESTANDING)
291293
# @Intent: Set compiler specific flag for bare metal freestanding option
@@ -552,16 +554,16 @@ if(ZEPHYR_GIT_INDEX)
552554
endif()
553555

554556
add_custom_command(
555-
OUTPUT ${PROJECT_BINARY_DIR}/include/generated/version.h
557+
OUTPUT ${VERSION_H}
556558
COMMAND ${CMAKE_COMMAND} -DZEPHYR_BASE=${ZEPHYR_BASE}
557-
-DOUT_FILE=${PROJECT_BINARY_DIR}/include/generated/version.h
559+
-DOUT_FILE=${VERSION_H}
558560
-DVERSION_TYPE=KERNEL
559561
-DVERSION_FILE=${ZEPHYR_BASE}/VERSION
560562
${build_version_argument}
561563
-P ${ZEPHYR_BASE}/cmake/gen_version_h.cmake
562564
DEPENDS ${ZEPHYR_BASE}/VERSION ${git_dependency}
563565
)
564-
add_custom_target(version_h DEPENDS ${PROJECT_BINARY_DIR}/include/generated/version.h)
566+
add_custom_target(version_h DEPENDS ${VERSION_H})
565567

566568
if(EXISTS ${APPLICATION_SOURCE_DIR}/VERSION)
567569
add_custom_command(
@@ -1875,7 +1877,7 @@ if(log_dict_db_output)
18751877
${ZEPHYR_BASE}/scripts/logging/dictionary/database_gen.py
18761878
${KERNEL_ELF_NAME}
18771879
${log_dict_db_output}
1878-
--build-header ${PROJECT_BINARY_DIR}/include/generated/version.h
1880+
--build-header ${VERSION_H}
18791881
)
18801882
list(APPEND
18811883
post_build_byproducts

cmake/modules/version.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,5 @@ foreach(type file IN ZIP_LISTS VERSION_TYPE VERSION_FILE)
119119
unset(PATCH)
120120
unset(${type}_VERSION_WITHOUT_TWEAK)
121121
endforeach()
122+
123+
set(VERSION_H ${PROJECT_BINARY_DIR}/include/generated/version.h)

include/zephyr/kernel.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#define ZEPHYR_INCLUDE_KERNEL_H_
1515

1616
#if !defined(_ASMLANGUAGE)
17-
#include "version.h" /* generated by MAKE, at compile time */
1817
#include <zephyr/kernel_includes.h>
1918
#include <errno.h>
2019
#include <limits.h>

0 commit comments

Comments
 (0)