cmake: allow overriding kconfig, kconfig_projbuild on registration

This commit is contained in:
Renz Bagaporo
2020-04-02 21:02:09 +08:00
parent f8d0c5770b
commit ebf07d353d
3 changed files with 29 additions and 4 deletions
@@ -23,13 +23,15 @@ endmacro()
macro(idf_component_register)
set(options)
set(single_value)
set(single_value KCONFIG KCONFIG_PROJBUILD)
set(multi_value SRCS SRC_DIRS EXCLUDE_SRCS
INCLUDE_DIRS PRIV_INCLUDE_DIRS LDFRAGMENTS REQUIRES
PRIV_REQUIRES REQUIRED_IDF_TARGETS EMBED_FILES EMBED_TXTFILES)
cmake_parse_arguments(_ "${options}" "${single_value}" "${multi_value}" "${ARGN}")
set(__component_requires "${__REQUIRES}")
set(__component_priv_requires "${__PRIV_REQUIRES}")
set(__component_requires "${__REQUIRES}")
set(__component_kconfig "${__KCONFIG}")
set(__component_kconfig_projbuild "${__KCONFIG_PROJBUILD}")
set(__component_registered 1)
return()
endmacro()
@@ -64,6 +66,8 @@ function(__component_get_requirements)
set(__component_requires "${__component_requires}" PARENT_SCOPE)
set(__component_priv_requires "${__component_priv_requires}" PARENT_SCOPE)
set(__component_kconfig "${__component_kconfig}" PARENT_SCOPE)
set(__component_kconfig_projbuild "${__component_kconfig_projbuild}" PARENT_SCOPE)
set(__component_registered ${__component_registered} PARENT_SCOPE)
endfunction()
@@ -97,6 +101,21 @@ foreach(__component_target ${__component_targets})
__component_set_property(${__component_target} PRIV_REQUIRES \"${__component_priv_requires}\")
__component_set_property(${__component_target} __COMPONENT_REGISTERED ${__component_registered})"
)
if(__component_kconfig)
get_filename_component(__component_kconfig "${__component_kconfig}" ABSOLUTE)
set(__contents
"${__contents}\n__component_set_property(${__component_target} KCONFIG \"${__component_kconfig}\""
)
endif()
if(__component_kconfig_projbuild)
get_filename_component(__component_kconfig "${__component_kconfig}" ABSOLUTE)
set(__contents
"${__contents}\n__component_set_property(${__component_target} KCONFIG_PROJBUILD \"${__component_kconfig_projbuild}\""
)
endif()
set(__component_requires_contents "${__component_requires_contents}\n${__contents}")
endforeach()