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?
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.