@@ -212,7 +212,7 @@ def _map_cmake_info(info, is_windows):
212212
213213GeneratedCmakeFiles = provider (
214214 fields = {
215- "files " : "" ,
215+ "targets " : "" ,
216216 },
217217)
218218
@@ -221,7 +221,11 @@ def _generate_cmake_impl(ctx):
221221 inputs = []
222222
223223 infos = {}
224- for dep in ctx .attr .targets :
224+ targets = list (ctx .attr .targets )
225+ for include in ctx .attr .includes :
226+ targets += include [GeneratedCmakeFiles ].targets .to_list ()
227+
228+ for dep in targets :
225229 for info in [dep [CmakeInfo ]] + dep [CmakeInfo ].transitive_deps .to_list ():
226230 if info .name != None :
227231 inputs += info .inputs
@@ -233,11 +237,6 @@ def _generate_cmake_impl(ctx):
233237 commands += _map_cmake_info (info , is_windows )
234238 commands .append ("" )
235239
236- for include in ctx .attr .includes :
237- for file in include [GeneratedCmakeFiles ].files .to_list ():
238- inputs .append (file )
239- commands .append ("include(${BAZEL_EXEC_ROOT}/%s)" % file .path )
240-
241240 # we want to use a run or run_shell action to register a bunch of files like inputs, but we cannot write all
242241 # in a shell command as we would hit the command size limit. So we first write the file and then copy it with
243242 # the dummy inputs
@@ -248,7 +247,7 @@ def _generate_cmake_impl(ctx):
248247
249248 return [
250249 DefaultInfo (files = depset ([output ])),
251- GeneratedCmakeFiles (files = depset ([ output ] )),
250+ GeneratedCmakeFiles (targets = depset (ctx . attr . targets )),
252251 ]
253252
254253generate_cmake = rule (
0 commit comments