zephyr/cmake/kobj.cmake
Torsten Rasmussen d7862cf776 cmake: using ${ZEPHYR_BASE} instead of $ENV{ZEPHYR_BASE}
With the introduction of ZephyrConfig.cmake all parts of CMake code
should rely on the CMake ZEPHYR_BASE variable instead of the environment
setting.

This ensures that after the first CMake invocation, then all subsequent
invocation in same build folder will use same zephyr base.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-03-27 16:23:46 +01:00

36 lines
1 KiB
CMake

# SPDX-License-Identifier: Apache-2.0
function(gen_kobj gen_dir_out)
if (PROJECT_BINARY_DIR)
set(gen_dir ${PROJECT_BINARY_DIR}/include/generated)
else ()
set(gen_dir ${CMAKE_BINARY_DIR}/include/generated)
endif ()
set(KOBJ_TYPES ${gen_dir}/kobj-types-enum.h)
set(KOBJ_OTYPE ${gen_dir}/otype-to-str.h)
set(KOBJ_SIZE ${gen_dir}/otype-to-size.h)
file(MAKE_DIRECTORY ${gen_dir})
add_custom_command(
OUTPUT ${KOBJ_TYPES} ${KOBJ_OTYPE}
COMMAND
${PYTHON_EXECUTABLE}
${ZEPHYR_BASE}/scripts/gen_kobject_list.py
--kobj-types-output ${KOBJ_TYPES}
--kobj-otype-output ${KOBJ_OTYPE}
--kobj-size-output ${KOBJ_SIZE}
${gen_kobject_list_include_args}
$<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose>
DEPENDS
${ZEPHYR_BASE}/scripts/gen_kobject_list.py
${PARSE_SYSCALLS_TARGET}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
add_custom_target(${KOBJ_TYPES_H_TARGET} DEPENDS ${KOBJ_TYPES} ${KOBJ_OTYPE})
set(${gen_dir_out} ${gen_dir} PARENT_SCOPE)
endfunction ()