1
+ cmake_minimum_required (VERSION 3.5 )
1
2
include ("${BUILD_PROPERTIES_FILE} " )
2
3
include ("${COMPONENT_PROPERTIES_FILE} " )
3
4
@@ -18,6 +19,38 @@ function(__component_get_property var component_target property)
18
19
set (${var} ${${_property}} PARENT_SCOPE )
19
20
endfunction ()
20
21
22
+ #
23
+ # Given a component name or alias, get the corresponding component target.
24
+ #
25
+ function (__component_get_target var name_or_alias )
26
+ idf_build_get_property (component_targets __COMPONENT_TARGETS )
27
+
28
+ # Assume first that the paramters is an alias.
29
+ string (REPLACE "::" "_" name_or_alias "${name_or_alias} " )
30
+ set (component_target ___${name_or_alias} )
31
+
32
+ if (component_target IN_LIST component_targets )
33
+ set (${var} ${component_target} PARENT_SCOPE )
34
+ set (target ${component_target} )
35
+ else () # assumption is wrong, try to look for it manually
36
+ unset (target )
37
+ foreach (component_target ${component_targets} )
38
+ __component_get_property (_component_name ${component_target} COMPONENT_NAME )
39
+ if (name_or_alias STREQUAL _component_name )
40
+ set (target ${component_target} )
41
+ break ()
42
+ endif ()
43
+ endforeach ()
44
+ set (${var} ${target} PARENT_SCOPE )
45
+ endif ()
46
+ endfunction ()
47
+
48
+ function (idf_component_get_property var component property )
49
+ __component_get_target (component_target ${component} )
50
+ __component_get_property (_var ${component_target} ${property} )
51
+ set (${var} ${_var} PARENT_SCOPE )
52
+ endfunction ()
53
+
21
54
macro (require_idf_targets )
22
55
endmacro ()
23
56
@@ -104,15 +137,15 @@ __component_set_property(${__component_target} __COMPONENT_REGISTERED ${__compon
104
137
105
138
if (__component_kconfig )
106
139
get_filename_component (__component_kconfig "${__component_kconfig} " ABSOLUTE )
107
- set (__contents
108
- "${__contents} \n __component_set_property(${__component_target} KCONFIG \" ${__component_kconfig} \" "
140
+ set (__contents
141
+ "${__contents} \n __component_set_property(${__component_target} KCONFIG \" ${__component_kconfig} \" ) "
109
142
)
110
143
endif ()
111
144
112
145
if (__component_kconfig_projbuild )
113
146
get_filename_component (__component_kconfig "${__component_kconfig} " ABSOLUTE )
114
- set (__contents
115
- "${__contents} \n __component_set_property(${__component_target} KCONFIG_PROJBUILD \" ${__component_kconfig_projbuild} \" "
147
+ set (__contents
148
+ "${__contents} \n __component_set_property(${__component_target} KCONFIG_PROJBUILD \" ${__component_kconfig_projbuild} \" ) "
116
149
)
117
150
endif ()
118
151
0 commit comments