Custom targets that use terminal individually, but can be run parallel in batch

Say I have 10 custom targets build-package-{1..10} that I can run in with an umbrella target build-all. I really appreciate that CMake + Ninja allow me to run these in parallel and have them print their result only when a job is finished.

However, the jobs individually can take several minutes, so when I need to debug a particular job, say build-package-3, I actually want to see the output live rather than wait until it’s finished. I know how adding USES_TERMINAL achieves this goal, but my understanding is that this will make it so build-all doesn’t work in parallel anymore.

I tried looking in the documentation and around here but couldn’t find exactly what I’m looking for. Any suggestions?

Only those targets with USES_TERMINAL are restricted to to be sequential.
Everything else still works in parallel.

Make it a configuration option that adds the USES_TERMINAL as needed

I understand, but if I want to debug each build-package-N target individually, I would have to add USES_TERMINAL to all of them, which would mean none of them will be built in parallel.

Currently I’ve been manually editing the CMake file, but this is tedious. I was hoping there a way to achieve this:

ninja build-package-all # runs all build-package-N in parallel, printing when each target is finished
ninja build-package-1   # works sequentially, printing to terminal interactively

I’m not sure if I understand your suggestion. This would require rerunning cmake, correct? If there’s a way to have USES_TERMINAL depend on an environment variable that would be great, so I could run:

SEQUENTIAL=true ninja build-package-1

Or something similar, but without rerunning cmake.

No, I meant with running cmake. The variable could be a list of targets to run sequentially.

You could also just run the custom command independent of ninja. If it is to complex, write it to a script that you can run as custom command and independently.

Thank you, but again, I have ways of doing this currently and I hoping there was a proper way of setting this up using JOB_POOL or similar tricks.