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

**URL:** https://discourse.cmake.org/t/custom-targets-that-use-terminal-individually-but-can-be-run-parallel-in-batch/14054
**Category:** Code
**Created:** [May 7, 2025, 9:32am UTC](https://discourse.cmake.org/t/custom-targets-that-use-terminal-individually-but-can-be-run-parallel-in-batch/14054 "2025-05-07T09:32:11Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![mahrud](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mahrud/32/5549_2.png) [@mahrud](https://discourse.cmake.org/u/mahrud)
#### Post date: [May 7, 2025, 9:32am UTC](https://discourse.cmake.org/t/custom-targets-that-use-terminal-individually-but-can-be-run-parallel-in-batch/14054/1 "2025-05-07T09:32:11Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![jtxa](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jtxa/32/1535_2.png) [@jtxa](https://discourse.cmake.org/u/jtxa)
#### Post date: [May 7, 2025, 6:07pm UTC](https://discourse.cmake.org/t/custom-targets-that-use-terminal-individually-but-can-be-run-parallel-in-batch/14054/2 "2025-05-07T18:07:56Z")

</div>

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

---

<div class="post-metadata">

### Author: ![hsattler](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/h/59ef9b/32.png) [@hsattler](https://discourse.cmake.org/u/hsattler)
#### Post date: [May 7, 2025, 6:15pm UTC](https://discourse.cmake.org/t/custom-targets-that-use-terminal-individually-but-can-be-run-parallel-in-batch/14054/3 "2025-05-07T18:15:21Z")

</div>

Make it a configuration option that adds the USES\_TERMINAL as needed

---

<div class="post-metadata">

### Author: ![mahrud](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mahrud/32/5549_2.png) [@mahrud](https://discourse.cmake.org/u/mahrud)
#### Post date: [May 8, 2025, 4:12pm UTC](https://discourse.cmake.org/t/custom-targets-that-use-terminal-individually-but-can-be-run-parallel-in-batch/14054/4 "2025-05-08T16:12:41Z")

</div>

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:

```auto
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

```

---

<div class="post-metadata">

### Author: ![mahrud](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mahrud/32/5549_2.png) [@mahrud](https://discourse.cmake.org/u/mahrud)
#### Post date: [May 8, 2025, 4:14pm UTC](https://discourse.cmake.org/t/custom-targets-that-use-terminal-individually-but-can-be-run-parallel-in-batch/14054/5 "2025-05-08T16:14:14Z")

</div>

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:

```auto
SEQUENTIAL=true ninja build-package-1

```

Or something similar, but without rerunning cmake.

---

<div class="post-metadata">

### Author: ![hsattler](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/h/59ef9b/32.png) [@hsattler](https://discourse.cmake.org/u/hsattler)
#### Post date: [May 8, 2025, 9:57pm UTC](https://discourse.cmake.org/t/custom-targets-that-use-terminal-individually-but-can-be-run-parallel-in-batch/14054/6 "2025-05-08T21:57:28Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![mahrud](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mahrud/32/5549_2.png) [@mahrud](https://discourse.cmake.org/u/mahrud)
#### Post date: [May 8, 2025, 10:05pm UTC](https://discourse.cmake.org/t/custom-targets-that-use-terminal-individually-but-can-be-run-parallel-in-batch/14054/7 "2025-05-08T22:05:54Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [February 20, 2026, 2:36pm UTC](https://discourse.cmake.org/t/custom-targets-that-use-terminal-individually-but-can-be-run-parallel-in-batch/14054/8 "2026-02-20T14:36:26Z")

</div>

Ninja does not (currently) support a mechanism to change the job pool at `ninja` time. I could forsee a `-T` flag or something to assume that all jobs are the equivalent of `USES_TERMINAL`.
