cmake-rs
cmake-rs copied to clipboard
Allow building multiple targets at once
The current API only allows specifying a single build target. However, the cmake CLI allows specifying multiple targets.
--target <tgt>..., -t <tgt>...
Build <tgt> instead of the default target. Multiple targets may
be given, separated by spaces.
It would be convenient to allow this in cmake-rs. Calling build_target("target1 target2") does not work with the build() API which only returns a single path.
The workaround is to invoke cmake once for each target, but this is slow.
Perhaps each call to build_target can be collected into a vector?
Perhaps each call to
build_targetcan be collected into a vector?
build_target() mutates self, so I'd need to copy the config for each. But yeah, you can build multiple targets today if you call build_target() and then build() once per target. I didn't quite grok how your idea helps with the usecase of building multiple targets at once though.
Er what I mean is that cmake_target internally could become a Vec whereas it's now an Option. We could then pass all those down all at once when calling cmake to avoid having to call cmake multiple times. There could be some sort of alternate API or something or other for building to learn about all the paths if you'd like multiple returned (although I though the return value was just the output directory, not the actual artifacts...)
Ah yes, you are right about the output directory. That makes me hopeful for this issue since it seems doable without a public API change. Internally using a vector seems like the right approach to me.
On Wed, Apr 28, 2021 at 9:29 AM Alex Crichton @.***> wrote:
Er what I mean is that cmake_target internally could become a Vec whereas it's now an Option. We could then pass all those down all at once when calling cmake to avoid having to call cmake multiple times. There could be some sort of alternate API or something or other for building to learn about all the paths if you'd like multiple returned (although I though the return value was just the output directory, not the actual artifacts...)
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/alexcrichton/cmake-rs/issues/115#issuecomment-828596469, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIIKIHKD5AM2M5SE3EFVPDTLAZXTANCNFSM43VRJE2Q .
@alexcrichton are you open to PRs for this issue using the vector approach?
indeed!