Skip to content

Commit 2a09063

Browse files
nordicjmjhedberg
authored andcommitted
cmake: Allow specifying custom VERSION file dependency
Allows applications and projects to specify their own requirements for the application VERSION file to be re-generated, this fixes an issue whereby the application git repository is updated with a new commit but the old commit is still used by a build, users would need to add a dependency in their application to the git index file Signed-off-by: Jamie McCrae <[email protected]>
1 parent 1b50f08 commit 2a09063

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,10 @@ zephyr_get(KERNEL_VERSION_CUSTOMIZATION SYSBUILD LOCAL)
737737
set_property(TARGET version_h PROPERTY KERNEL_VERSION_CUSTOMIZATION ${KERNEL_VERSION_CUSTOMIZATION})
738738

739739
if(EXISTS ${APPLICATION_SOURCE_DIR}/VERSION)
740+
# A generator expression is used to allow applications to add their own dependencies for the
741+
# file version, this might typically be the git index file if the application is in a git
742+
# repository. To add a dependency to the application version file, this can be used:
743+
# set_property(TARGET app_version_h PROPERTY APP_VERSION_DEPENDS <FILE>)
740744
add_custom_command(
741745
OUTPUT ${PROJECT_BINARY_DIR}/include/generated/zephyr/app_version.h
742746
COMMAND ${CMAKE_COMMAND} -DZEPHYR_BASE=${ZEPHYR_BASE}
@@ -747,6 +751,7 @@ if(EXISTS ${APPLICATION_SOURCE_DIR}/VERSION)
747751
${build_version_argument}
748752
-P ${ZEPHYR_BASE}/cmake/gen_version_h.cmake
749753
DEPENDS ${APPLICATION_SOURCE_DIR}/VERSION ${git_dependency}
754+
$<TARGET_PROPERTY:app_version_h,APP_VERSION_DEPENDS>
750755
COMMAND_EXPAND_LISTS
751756
)
752757
add_custom_target(

0 commit comments

Comments
 (0)