@@ -51,6 +51,12 @@ def _get_includes(includes):
51
51
def _cmake_aspect_impl (target , ctx ):
52
52
if not ctx .rule .kind .startswith ("cc_" ):
53
53
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
+ )]
54
60
55
61
name = _cmake_name (ctx .label )
56
62
@@ -146,7 +152,7 @@ def _cmake_aspect_impl(target, ctx):
146
152
147
153
cmake_aspect = aspect (
148
154
implementation = _cmake_aspect_impl ,
149
- attr_aspects = ["deps" ],
155
+ attr_aspects = ["deps" , "dep" ],
150
156
fragments = ["cpp" ],
151
157
)
152
158
@@ -156,10 +162,10 @@ def _map_cmake_info(info, is_windows):
156
162
"add_%s(%s)" % (info .kind , args ),
157
163
]
158
164
if info .imported_libs :
159
- commands += [
165
+ commands . append (
160
166
"target_link_libraries(%s %s %s)" %
161
167
(info .name , info .modifier or "PUBLIC" , " " .join (info .imported_libs )),
162
- ]
168
+ )
163
169
if info .deps :
164
170
libs = {}
165
171
if info .modifier == "INTERFACE" :
@@ -168,46 +174,46 @@ def _map_cmake_info(info, is_windows):
168
174
for lib in info .deps :
169
175
libs .setdefault (lib .modifier , []).append (lib .name )
170
176
for modifier , names in libs .items ():
171
- commands += [
177
+ commands . append (
172
178
"target_link_libraries(%s %s %s)" % (info .name , modifier or "PUBLIC" , " " .join (names )),
173
- ]
179
+ )
174
180
if info .includes :
175
- commands += [
181
+ commands . append (
176
182
"target_include_directories(%s %s %s)" % (info .name , info .modifier or "PUBLIC" , " " .join (info .includes )),
177
- ]
183
+ )
178
184
if info .system_includes :
179
- commands += [
185
+ commands . append (
180
186
"target_include_directories(%s SYSTEM %s %s)" % (info .name , info .modifier or "PUBLIC" , " " .join (info .system_includes )),
181
- ]
187
+ )
182
188
if info .quote_includes :
183
189
if is_windows :
184
- commands += [
190
+ commands . append (
185
191
"target_include_directories(%s %s %s)" % (info .name , info .modifier or "PUBLIC" , " " .join (info .quote_includes )),
186
- ]
192
+ )
187
193
else :
188
- commands += [
194
+ commands . append (
189
195
"target_compile_options(%s %s %s)" % (info .name , info .modifier or "PUBLIC" , " " .join (["-iquote%s" % i for i in info .quote_includes ])),
190
- ]
196
+ )
191
197
if info .copts and info .modifier != "INTERFACE" :
192
- commands += [
198
+ commands . append (
193
199
"target_compile_options(%s PRIVATE %s)" % (info .name , " " .join (info .copts )),
194
- ]
200
+ )
195
201
if info .linkopts :
196
- commands += [
202
+ commands . append (
197
203
"target_link_options(%s %s %s)" % (info .name , info .modifier or "PUBLIC" , " " .join (info .linkopts )),
198
- ]
204
+ )
199
205
if info .force_cxx_compilation and any ([f .endswith (".c" ) for f in info .srcs ]):
200
- commands += [
206
+ commands . append (
201
207
"set_source_files_properties(%s PROPERTIES LANGUAGE CXX)" % " " .join ([f for f in info .srcs if f .endswith (".c" )]),
202
- ]
208
+ )
203
209
if info .defines :
204
- commands += [
210
+ commands . append (
205
211
"target_compile_definitions(%s %s %s)" % (info .name , info .modifier or "PUBLIC" , " " .join (info .defines )),
206
- ]
212
+ )
207
213
if info .local_defines :
208
- commands += [
214
+ commands . append (
209
215
"target_compile_definitions(%s %s %s)" % (info .name , info .modifier or "PRIVATE" , " " .join (info .local_defines )),
210
- ]
216
+ )
211
217
return commands
212
218
213
219
GeneratedCmakeFiles = provider (
0 commit comments