# Custom build targets and applications

Custom build targets are independent of any particular build system or project model: CLion uses [external tools](configuring-third-party-tools.html) of your choice for building the sources and cleaning build artifacts.

Custom targets are especially useful for [compilation database projects](compilation-database.html). Although `compile_commands.json` itself lacks the information required for building and therefore running applications, custom targets and custom run/debug configurations help bypass this limitation.

> **Tip:**
> Custom targets can also be used in [Makefile](makefiles-support.html#rd-configs) run/debug configurations.

In the following example, we will add a target to a compilation database project, get build results, and then create a custom configuration to run the executable right from CLion.

Procedure: Create a custom build target

1. Let's open a compilation database project. Click `File | Open`, point CLion to `compile_commands.json`, and choose Open as Project.

Notice that by default the [Build](build-actions.html) menu shows no available actions except for [Recompile](compilation-database.html#compdb_recompile) (you can use it to compile the currently opened source file):

![empty build menu for compdb projects](https://resources.jetbrains.com/help/img/idea/2026.2/cl_customtargets_buildmenu_init.png)

2. Go to `Settings | Build, Execution, Deployment | Custom Build Targets` and click ![](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.general.add.svg) to add a new target. This dialog is also accessible from the [Custom Build Application](#custom-rundebug) editor.

3. Specify the following settings:

![settings for a custom build tagget](https://resources.jetbrains.com/help/img/idea/2026.2/cl_custombuildtargets_settings.png)

* Toolchain Toolchain selected here will provide the environment and the debugger for the [custom run/debug configuration](#custom-rundebug) that we will create later. > **Note:** > By default, custom build tools work in native system environment disregarding the selected toolchain. > > > > If you need to build the project on another toolchain, such as [WSL](how-to-use-wsl-development-environment-in-product.html), the tool you call for building should take care of configuring the connection and launching there. For such cases, we recommend using a build script. Note that [compilation database](compilation-database.html) projects with custom build targets use two separate toolchains: 1. `Settings | Build, Execution, Deployment | Compilation Database` for resolving your project files. 2. The target's toolchain, which defines the environment and the debugger for custom run/debug configurations.

* Build and Clean Set up the tools for building and cleaning your project: select from the list of the available tools or click ![the Browse button](https://resources.jetbrains.com/help/img/idea/2026.2/app.general.ellipsis.svg) and use the ![](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.general.edit.svg) and ![](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.general.add.svg) buttons to edit or add new tools. In our example, the Build tool (named build_with_make) calls make, and the Clean tool (clean_with_make) calls `make clean`: ![external tools for build and clean](https://resources.jetbrains.com/help/img/idea/2026.2/cl_externaltool_makeclean.png) > **Note:** > Unlike regular [external tools](configuring-third-party-tools.html) configured in `Settings | Tools | External Tools`, custom target tools are stored per project, and they are not accessible via `Tools | External Tools` in the main menu. In turn, you cannot set an IDE-wide external tool as a build/clean tool for your custom target.

4. After saving the target, we can start using the Build Project and Rebuild Project actions. Note that in case of several custom targets, these actions are associated with the first target from the list.

![build menu for custom build targets](https://resources.jetbrains.com/help/img/idea/2026.2/cl_customtargets-buildmenu.png)

5. If we select Build Project, CLion runs the build_with_make tool that calls `make` for the project sources:

![building a custom target](https://resources.jetbrains.com/help/img/idea/2026.2/cl_customtargets_runbuild.png)

Procedure: Create a custom run/debug configuration

Now that we have a build target, we can create a configuration to run and debug the executable.

1. In the main menu, go to `Run | Edit Configurations`, click ![](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.general.add.svg) and choose [Custom Build Application](custom-build-application.html) from the list of the configuration templates.

2. Select the newly created custom target in the Target field. To add or edit the targets without leaving the configuration editor, click Configure Custom Build Targets.

Specify the application binary in the Executable field. Note that you can use [remote](remote-development.html) executables here as well.

For our example, we also add a program argument func.cpp:

![custom run-debug configuration](https://resources.jetbrains.com/help/img/idea/2026.2/cl_customapplication.png)

3. After saving the configuration, we can see new build actions available in the Build menu:

![custom application build menu](https://resources.jetbrains.com/help/img/idea/2026.2/cl_customapp_buildmenu.png)

4. We can now Run![](https://resources.jetbrains.com/help/img/idea/2026.2/app.actions.execute.svg) or Debug![](https://resources.jetbrains.com/help/img/idea/2026.2/app.actions.startDebugger.svg) this configuration and use all the CLion [debugging](debugging-code.html) and [dynamic analysis](profiling-tools.html) features.

Let's run our example and view the program results:

![result of running a custom run-debug configuration](https://resources.jetbrains.com/help/img/idea/2026.2/cl_customapp_runresult.png)

## See also

### How tos

[Build Actions](build-actions.html) [Compilation database](compilation-database.html) [External Tools](configuring-third-party-tools.html)

