cmake: add support for building and installing interfaces

This commit is contained in:
2026-02-26 19:45:46 +00:00
parent b631fca0fd
commit dc93f7db4c
3 changed files with 107 additions and 0 deletions

View File

@@ -186,6 +186,37 @@ function(sysroot_add_file)
set_property(GLOBAL PROPERTY sysroot_target_list ${sysroot_targets} ${sysroot_target_name})
endfunction(sysroot_add_file)
function(sysroot_add_interface)
set(options)
set(one_value_args NAME DEST_DIR)
set(multi_value_args DEPENDS)
cmake_parse_arguments(PARSE_ARGV 0 arg
"${options}"
"${one_value_args}"
"${multi_value_args}")
iface_get_header_path(NAME ${arg_NAME} OUT src_path)
iface_get_parent_dir(NAME ${arg_NAME} OUT parent_dir)
set(dest_dir ${arg_DEST_DIR}/${parent_dir})
set(sysroot_target_name _sysroot-iface-${arg_NAME})
get_property(sysroot_targets GLOBAL PROPERTY sysroot_target_list)
list(LENGTH sysroot_targets nr_sysroot_targets)
if (${nr_sysroot_targets} GREATER 0)
math(EXPR serialiser_index "${nr_sysroot_targets}-1")
list(GET sysroot_targets ${serialiser_index} serialiser)
endif ()
add_custom_target(${sysroot_target_name}
COMMAND ${Python_EXECUTABLE} ${sysroot_tool}
add-binary ${sysroot_manifest} ${arg_NAME}
${dest_dir} ${src_path}
COMMENT "Preparing sysroot component: ${arg_ID}"
DEPENDS ifgen-${arg_NAME} ${serialiser} ${arg_DEPENDS})
set_property(GLOBAL PROPERTY sysroot_target_list ${sysroot_targets} ${sysroot_target_name})
endfunction(sysroot_add_interface)
function(sysroot_finalise)
get_property(sysroot_targets GLOBAL PROPERTY sysroot_target_list)