1# SPDX-License-Identifier: Apache-2.0 2 3cmake_minimum_required(VERSION 3.20.0) 4 5set(ZEPHYR_BASE $ENV{ZEPHYR_BASE} CACHE PATH "Zephyr base") 6set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ZEPHYR_BASE}/cmake/modules) 7 8include(git) 9 10if(VERSION_TYPE STREQUAL KERNEL) 11 set(BUILD_VERSION_NAME BUILD_VERSION) 12else() 13 set(BUILD_VERSION_NAME ${VERSION_TYPE}_BUILD_VERSION) 14endif() 15 16if(NOT DEFINED ${BUILD_VERSION_NAME}) 17 cmake_path(GET VERSION_FILE PARENT_PATH work_dir) 18 git_describe(${work_dir} ${BUILD_VERSION_NAME}) 19endif() 20 21include(${ZEPHYR_BASE}/cmake/modules/version.cmake) 22file(READ ${ZEPHYR_BASE}/version.h.in version_content) 23string(CONFIGURE "${version_content}" version_content) 24string(CONFIGURE "${version_content}" version_content) 25file(WRITE ${OUT_FILE} "${version_content}") 26