# Run CMake targets before launch

CMake targets can be executed automatically before the launch of a run/debug configuration. This covers both the built-in CMake targets like `all` or `clean` and the targets specified via `add_executable` or `add_custom_target`.

Procedure:

1. In the main menu, go to `Run | Edit Configurations` and select a [CMake Application](run-debug-configuration-makefile-application.html) or a test configuration to edit.

2. In the Before launch area, click ![](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.general.add.svg) and select CMake Target:

![Adding CMake targets before launch](https://resources.jetbrains.com/help/img/idea/2026.2/cl_rdconfig_beforelaunch_cmaketagrets.png)

> **Tip:**
> For the `install` target, you can also use another task called Install. See [CMake install](using-cmake-install.html#configure-install).

3. In the dialog that opens, select the desired target:

![Adding CMake targets before launch](https://resources.jetbrains.com/help/img/idea/2026.2/cl_rdconfig_beforelaunch_cmaketargets_dialog.png)

Set the Run with root privileges checkbox to run the target with administrative privileges:

![Option to run a before launch target with root privileges](https://resources.jetbrains.com/help/img/idea/2026.2/cl_rdconfig_beforelaunch_cmaketargets_root.png)

4. Save the settings. Next time you run or debug this configuration, the specified target will be executed before launch.

> **Note:**
> The Before launch tasks are performed in the order they appear in the list.

## See also

### How tos

[Quick CMake tutorial](quick-cmake-tutorial.html) [CMake install](using-cmake-install.html)

