Skip to content

Commit

Permalink
[nrf fromlist] cmake: Zephyr kernel version.h and app_version.h creation
Browse files Browse the repository at this point in the history
Move the custom commands creating the version.h and app_version.h below
the Zephyr modules sourcing.

This allows custom user specific Zephyr modules to adjust the value of
KERNEL_VERSION_CUSTOMIZATION and APP_VERSION_CUSTOMIZATION values and
thereby make use of the functionality introduced with #61635.

The creation of the version_h and app_version_h targets, which drives
the custom commands, are kept at their current location.

This ensure that the targets themselves are still defined when the
Zephyr and Zephyr modules CMakeLists trees are sourced.

Upstream PR: zephyrproject-rtos/zephyr#62395

Signed-off-by: Torsten Rasmussen <[email protected]>
  • Loading branch information
tejlmand authored and nordicjm committed Sep 7, 2023
1 parent 08307c9 commit 96a0d4e
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -546,31 +546,9 @@ if(ZEPHYR_GIT_INDEX)
set(git_dependency ${ZEPHYR_GIT_INDEX})
endif()

add_custom_command(
OUTPUT ${PROJECT_BINARY_DIR}/include/generated/version.h
COMMAND ${CMAKE_COMMAND} -DZEPHYR_BASE=${ZEPHYR_BASE}
-DOUT_FILE=${PROJECT_BINARY_DIR}/include/generated/version.h
-DVERSION_TYPE=KERNEL
-DVERSION_FILE=${ZEPHYR_BASE}/VERSION
-DKERNEL_VERSION_CUSTOMIZATION="${KERNEL_VERSION_CUSTOMIZATION}"
${build_version_argument}
-P ${ZEPHYR_BASE}/cmake/gen_version_h.cmake
DEPENDS ${ZEPHYR_BASE}/VERSION ${git_dependency}
)
add_custom_target(version_h DEPENDS ${PROJECT_BINARY_DIR}/include/generated/version.h)

if(EXISTS ${APPLICATION_SOURCE_DIR}/VERSION)
add_custom_command(
OUTPUT ${PROJECT_BINARY_DIR}/include/generated/app_version.h
COMMAND ${CMAKE_COMMAND} -DZEPHYR_BASE=${ZEPHYR_BASE}
-DOUT_FILE=${PROJECT_BINARY_DIR}/include/generated/app_version.h
-DVERSION_TYPE=APP
-DVERSION_FILE=${APPLICATION_SOURCE_DIR}/VERSION
-DAPP_VERSION_CUSTOMIZATION="${APP_VERSION_CUSTOMIZATION}"
${build_version_argument}
-P ${ZEPHYR_BASE}/cmake/gen_version_h.cmake
DEPENDS ${APPLICATION_SOURCE_DIR}/VERSION ${git_dependency}
)
add_custom_target(app_version_h DEPENDS ${PROJECT_BINARY_DIR}/include/generated/app_version.h)
add_dependencies(zephyr_interface app_version_h)
endif()
Expand Down Expand Up @@ -626,6 +604,32 @@ endforeach()
set(ZEPHYR_CURRENT_MODULE_DIR)
set(ZEPHYR_CURRENT_CMAKE_DIR)

add_custom_command(
OUTPUT ${PROJECT_BINARY_DIR}/include/generated/version.h
COMMAND ${CMAKE_COMMAND} -DZEPHYR_BASE=${ZEPHYR_BASE}
-DOUT_FILE=${PROJECT_BINARY_DIR}/include/generated/version.h
-DVERSION_TYPE=KERNEL
-DVERSION_FILE=${ZEPHYR_BASE}/VERSION
-DKERNEL_VERSION_CUSTOMIZATION="${KERNEL_VERSION_CUSTOMIZATION}"
${build_version_argument}
-P ${ZEPHYR_BASE}/cmake/gen_version_h.cmake
DEPENDS ${ZEPHYR_BASE}/VERSION ${git_dependency}
)

if(EXISTS ${APPLICATION_SOURCE_DIR}/VERSION)
add_custom_command(
OUTPUT ${PROJECT_BINARY_DIR}/include/generated/app_version.h
COMMAND ${CMAKE_COMMAND} -DZEPHYR_BASE=${ZEPHYR_BASE}
-DOUT_FILE=${PROJECT_BINARY_DIR}/include/generated/app_version.h
-DVERSION_TYPE=APP
-DVERSION_FILE=${APPLICATION_SOURCE_DIR}/VERSION
-DAPP_VERSION_CUSTOMIZATION="${APP_VERSION_CUSTOMIZATION}"
${build_version_argument}
-P ${ZEPHYR_BASE}/cmake/gen_version_h.cmake
DEPENDS ${APPLICATION_SOURCE_DIR}/VERSION ${git_dependency}
)
endif()

get_property(LIBC_LINK_LIBRARIES TARGET zephyr_interface PROPERTY LIBC_LINK_LIBRARIES)
zephyr_link_libraries(${LIBC_LINK_LIBRARIES})

Expand Down

0 comments on commit 96a0d4e

Please sign in to comment.