Skip to content

Commit 99064c2

Browse files
tejlmandcarlescufi
authored andcommitted
cmake: generated application version header when VERSION file is present
Allow applications to create a VERSION file in their application folder. The presence of a VERSION file will create a app_version_h target which generates an app_version.h file using same infrastructure as the Zephyr kernel version.h generation. Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
1 parent 2c757f9 commit 99064c2

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,21 @@ add_custom_command(
552552
)
553553
add_custom_target(version_h DEPENDS ${PROJECT_BINARY_DIR}/include/generated/version.h)
554554

555+
if(EXISTS ${APPLICATION_SOURCE_DIR}/VERSION)
556+
add_custom_command(
557+
OUTPUT ${PROJECT_BINARY_DIR}/include/generated/app_version.h
558+
COMMAND ${CMAKE_COMMAND} -DZEPHYR_BASE=${ZEPHYR_BASE}
559+
-DOUT_FILE=${PROJECT_BINARY_DIR}/include/generated/app_version.h
560+
-DVERSION_TYPE=APP
561+
-DVERSION_FILE=${APPLICATION_SOURCE_DIR}/VERSION
562+
${build_version_argument}
563+
-P ${ZEPHYR_BASE}/cmake/gen_version_h.cmake
564+
DEPENDS ${APPLICATION_SOURCE_DIR}/VERSION ${git_dependency}
565+
)
566+
add_custom_target(app_version_h DEPENDS ${PROJECT_BINARY_DIR}/include/generated/app_version.h)
567+
add_dependencies(zephyr_interface app_version_h)
568+
endif()
569+
555570
# Unfortunately, the order in which CMakeLists.txt code is processed
556571
# matters so we need to be careful about how we order the processing
557572
# of subdirectories. One example is "Compiler flags added late in the

0 commit comments

Comments
 (0)