@@ -51,6 +51,12 @@ def _get_includes(includes):
5151def _cmake_aspect_impl (target , ctx ):
5252 if not ctx .rule .kind .startswith ("cc_" ):
5353 return [CmakeInfo (name = None , transitive_deps = depset ())]
54+ if ctx .rule .kind == "cc_binary_add_features" :
55+ dep = ctx .rule .attr .dep [0 ][CmakeInfo ]
56+ return [CmakeInfo (
57+ name = None ,
58+ transitive_deps = depset ([dep ], transitive = [dep .transitive_deps ]),
59+ )]
5460
5561 name = _cmake_name (ctx .label )
5662
@@ -146,7 +152,7 @@ def _cmake_aspect_impl(target, ctx):
146152
147153cmake_aspect = aspect (
148154 implementation = _cmake_aspect_impl ,
149- attr_aspects = ["deps" ],
155+ attr_aspects = ["deps" , "dep" ],
150156 fragments = ["cpp" ],
151157)
152158
@@ -156,10 +162,10 @@ def _map_cmake_info(info, is_windows):
156162 "add_%s(%s)" % (info .kind , args ),
157163 ]
158164 if info .imported_libs :
159- commands += [
165+ commands . append (
160166 "target_link_libraries(%s %s %s)" %
161167 (info .name , info .modifier or "PUBLIC" , " " .join (info .imported_libs )),
162- ]
168+ )
163169 if info .deps :
164170 libs = {}
165171 if info .modifier == "INTERFACE" :
@@ -168,46 +174,46 @@ def _map_cmake_info(info, is_windows):
168174 for lib in info .deps :
169175 libs .setdefault (lib .modifier , []).append (lib .name )
170176 for modifier , names in libs .items ():
171- commands += [
177+ commands . append (
172178 "target_link_libraries(%s %s %s)" % (info .name , modifier or "PUBLIC" , " " .join (names )),
173- ]
179+ )
174180 if info .includes :
175- commands += [
181+ commands . append (
176182 "target_include_directories(%s %s %s)" % (info .name , info .modifier or "PUBLIC" , " " .join (info .includes )),
177- ]
183+ )
178184 if info .system_includes :
179- commands += [
185+ commands . append (
180186 "target_include_directories(%s SYSTEM %s %s)" % (info .name , info .modifier or "PUBLIC" , " " .join (info .system_includes )),
181- ]
187+ )
182188 if info .quote_includes :
183189 if is_windows :
184- commands += [
190+ commands . append (
185191 "target_include_directories(%s %s %s)" % (info .name , info .modifier or "PUBLIC" , " " .join (info .quote_includes )),
186- ]
192+ )
187193 else :
188- commands += [
194+ commands . append (
189195 "target_compile_options(%s %s %s)" % (info .name , info .modifier or "PUBLIC" , " " .join (["-iquote%s" % i for i in info .quote_includes ])),
190- ]
196+ )
191197 if info .copts and info .modifier != "INTERFACE" :
192- commands += [
198+ commands . append (
193199 "target_compile_options(%s PRIVATE %s)" % (info .name , " " .join (info .copts )),
194- ]
200+ )
195201 if info .linkopts :
196- commands += [
202+ commands . append (
197203 "target_link_options(%s %s %s)" % (info .name , info .modifier or "PUBLIC" , " " .join (info .linkopts )),
198- ]
204+ )
199205 if info .force_cxx_compilation and any ([f .endswith (".c" ) for f in info .srcs ]):
200- commands += [
206+ commands . append (
201207 "set_source_files_properties(%s PROPERTIES LANGUAGE CXX)" % " " .join ([f for f in info .srcs if f .endswith (".c" )]),
202- ]
208+ )
203209 if info .defines :
204- commands += [
210+ commands . append (
205211 "target_compile_definitions(%s %s %s)" % (info .name , info .modifier or "PUBLIC" , " " .join (info .defines )),
206- ]
212+ )
207213 if info .local_defines :
208- commands += [
214+ commands . append (
209215 "target_compile_definitions(%s %s %s)" % (info .name , info .modifier or "PRIVATE" , " " .join (info .local_defines )),
210- ]
216+ )
211217 return commands
212218
213219GeneratedCmakeFiles = provider (
0 commit comments