# CMake profiles

Settings required for building a CMake project are incorporated into a CMake profile. It includes [toolchain](how-to-create-toolchain-in-clion.html) and [build type](#buildtypes), as well as CMake options such as [generators](#cmake-generators) and [environment variables](#EnvVariables).

You can configure multiple profiles for your project in order to, for example, use different compilers or to build targets with differing settings.

Procedure: Access profile settings

Do one of the following to open the CMake profile settings.

* Go to `Settings | Build, Execution, Deployment | CMake`.

* Press `Ctrl+Shift+A` (Windows), `⌘ ⇧ A` (macOS), `⌘ ⇧ A` (IntelliJ IDEA Classic (macOS)), `⌘ ⇧ P` (macOS System Shortcuts), `Ctrl+Shift+A` (XWin), `Ctrl+Shift+A` (GNOME), `Ctrl+Shift+A` (KDE), `Escape, X` (Emacs), `Ctrl+Shift+P` (Sublime Text), `⌘ ⇧ P` (Sublime Text (macOS)), `⌘ ⇧ A` (Xcode), `Ctrl+Shift+A` (Visual Studio), `⌘ ⇧ A` (Visual Studio (macOS)), `Ctrl+Shift+A` (ReSharper), `⌘ ⇧ A` (ReSharper (macOS)), `Ctrl+Shift+A` (QtCreator), `⌘ ⇧ A` (QtCreator (macOS)), `Ctrl+I` (NetBeans), `Ctrl+Shift+A` (Eclipse), `⌘ 3` (Eclipse (macOS)) to open the Find Action dialog and search for CMake settings:

![CMake settings in Find Action](https://resources.jetbrains.com/help/img/idea/2026.2/cl_cmake_settings_findaction.png)

* Go to `Settings | Keymap` and [assign a shortcut](configuring-keyboard-and-mouse-shortcuts.html#add-keyboard-shortcut) for CMake settings. Use this shortcut to quickly open the CMake settings page.

![Assigning a shortcut for CMake settings](https://resources.jetbrains.com/help/img/idea/2026.2/cl_cmake_settings_keymap.png)

> **Note:**
> CMake profiles are configured per project.

Procedure: Add a new profile

1. Go to `Settings | Build, Execution, Deployment | CMake`.

2. Click ![](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.general.add.svg), and CLion will add a new profile to the list.

3. If required, change the profile name, build type, and other settings.

Procedure: Build with a profile

1. The enabled profiles are listed in the profile switcher.

Select the desired profile before building, running, or debugging your application.

![cmake profiles in the configuration switcher](https://resources.jetbrains.com/help/img/idea/2026.2/cl_profileSwitcher.png)

> **Note:**
> CLion filters the list of profiles it suggests in this switcher based on whether the selected target supports that profile. For example:
>
>
>
> Suppose you have two profiles, Debug and Release, and a target called `debug_target`, which is supported for Debug only:
>
>
>
>
> ```CMAKE
> if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
> add_executable(debug_target main.cpp)
> endif()
> ```
>
>
>
> If you select this target in the [run/debug configuration](run-debug-configuration.html), CLion will only suggest the Debug profile.

> **Note:**
> The CMake profile defines how the project is built. To choose the debugger for a debug session, select a [debug profile](debug-profiles.html) from the separate debug profile switcher on the same toolbar.

2. Click ![](https://resources.jetbrains.com/help/img/idea/2026.2/app-client.expui.build.build.svg) or call one of the available [Build actions](build-actions.html).

Also, build is performed by default before 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) (you can change this in the configuration settings).

Procedure: Configure default profiles for new projects

1. Go to `File | New Projects Setup | Settings for New Projects | Build, Execution, Deployment | CMake`.

2. Configure the list of profiles to be used for all [new projects](creating-new-project-from-scratch.html) by default.

Procedure: Share profiles

You can share CMake profiles in VCS along with the project. The profiles' settings are stored in `cmake.xml` in the `.idea` directory.

* Select the profile you want to share and set the Share checkbox:

![Shared CMake profile](https://resources.jetbrains.com/help/img/idea/2026.2/cl_cmakeprofile_shared.png)

Shared profiles are automatically moved to the bottom of the list.

> **Note:**
> Only the Profile settings can be shared. The Reload CMake project on editing CMakeLists.txt or other CMake configuration files option is common for all profiles and is stored in `workspace.xml`.

Make sure to have different names for shared and local profiles. If a shared and a local profile have the same name, the local one takes precedence and you will not see the shared one in the settings.

Procedure: Disable/enable profiles

You can disable the profiles that are not currently in use to save time on loading and avoid potential errors (for example, when you have a remote profile you don't use regularly and the machine is shut down).

> **Note:**
> [Presets](cmake-presets.html) profiles are disabled by default.

> **Note:**
> When you enable or disable a profile, CLion incrementally reloads CMake regardless of the Reload CMake project on editing CMakeLists.txt or other CMake configuration files control.
>
>
>
> On reloading CMake, all the profiles are reloaded in parallel. It may cause issues for some configurations. To resolve this, select the Reload CMake profiles sequentially option in `Settings | Advanced Settings | CMake`.

Use one of the following options:

* Clear or set the Enable profile checkbox in `Settings | Build, Execution, Deployment | CMake`. Disabled profiles are grayed out in the list.

![Disabled profiles](https://resources.jetbrains.com/help/img/idea/2026.2/cl_cmake_disabledprofiles.png)

* To disable a successfully loaded profile, select Disable This Profile from the configuration menu in the CMake tool window:

![Disabling a loaded profile from the CMake tool window](https://resources.jetbrains.com/help/img/idea/2026.2/cl_cmake_disableprofile_fromtw.png)

From this menu, you can also enable any of the disabled profiles:

![Enabling a disabled profile from the CMake tool window](https://resources.jetbrains.com/help/img/idea/2026.2/cl_cmakeprofile_enable_fromtw.png)

## CMake options

Procedure: Compiler flags

In CLion, you can specify compiler flags in the CMake options field of a profile or in the `CMakeLists.txt` script.

* Using CMake options:

Select the profile in `Settings | Build, Execution, Deployment | CMake` and edit the CMake options field.

Use `-D` with the `CMAKE_CXX_FLAGS` variable (or `CMAKE_C_FLAGS` for C projects). For example, `-DCMAKE_CXX_FLAGS="-Wall -Wextra"`.

> **Note:**
> You can change values of existing CMake variables in the [Cache variables](#cmake-cache-variables) table.

![Setting compiler flags in CMake options](https://resources.jetbrains.com/help/img/idea/2026.2/cl_compilerlfags_cmakeoptions.png)

CLion also works with the `--preset` argument passed to CMake options. The data from the specified [preset](cmake-presets.html) is loaded into build type, toolchain, and build directory settings.

> **Tip:**
> Click ![](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.general.add.svg) to insert the project root directory macro. For more information, refer to the [CMake settings reference page](cmake0.html).

* Alternatively, you can set compiler flags in [CMakeLists.txt](cmakelists-txt-file.html).

Add the following command with the required flags:

```CMAKE
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
```

Procedure: CMake toolchain files

* In CMake options, you can specify a CMake toolchain file using the [CMAKE_TOOLCHAIN_FILE](https://cmake.org/cmake/help/latest/variable/CMAKE_TOOLCHAIN_FILE.html) variable.

## CMake cache variables

You can view and edit the CMake cache variables in the Cache variables table:

![CMake cache variables](https://resources.jetbrains.com/help/img/idea/2026.2/cl_cmake_variables.png)

You can add new variables either in the [CMake options](#compiler-flags) field or in the [CMakeLists.txt](cmakelists-txt-file.html) file. User-defined variables are placed on the top of the table. Values of the user-defined variables are highlighted in bold, while the changed values of the other variables are shown in italics:

![Custom CMake variables](https://resources.jetbrains.com/help/img/idea/2026.2/cl_cmake_custom_variables.png)

To remove a variable from the CMake options field, select it in the table and click ![the Remove button](https://resources.jetbrains.com/help/img/idea/2026.2/app.actions.popFrame.svg) or press `Alt+Delete` (Windows), `⌘ ⌦` (macOS), `⌘ ⌦` (IntelliJ IDEA Classic (macOS)), `⌘ ⌦` (macOS System Shortcuts), `Alt+Delete` (XWin), `Alt+Delete` (GNOME), `Alt+Delete` (KDE), `Alt+Delete` (Emacs), `Alt+Delete` (Sublime Text), `⌘ ⌦` (Sublime Text (macOS)), `⌘ ⌦` (Xcode), `Ctrl+R, D` (Visual Studio), `⌘ R, D` (Visual Studio (macOS)), `Alt+Delete` (ReSharper), `⌥ ⌦` (ReSharper (macOS)), `Alt+Delete` (QtCreator), `⌘ ⌦` (QtCreator (macOS)), `Alt+Delete` (NetBeans), `Alt+Delete` (Eclipse), `Alt+Delete` (Eclipse (macOS)). The variable will be removed from the table or its value will be set to default after [resetting the CMake cache](cmake-cache.html#reset-cache).

To discard changes made in the current session, select a variable and click ![the Revert icon](https://resources.jetbrains.com/help/img/idea/2026.2/app.diff.revert.svg) or press `Ctrl+Z` (Windows), `⌘ Z` (macOS), `⌘ Z` (IntelliJ IDEA Classic (macOS)), `⌘ Z` (macOS System Shortcuts), `Ctrl+Z` (XWin), `Ctrl+Z` (GNOME), `Ctrl+Z` (KDE), `Ctrl+Shift+Minus` (Emacs), `Ctrl+Z` (Sublime Text), `⌘ Z` (Sublime Text (macOS)), `⌘ Z` (Xcode), `Ctrl+Z` (Visual Studio), `⌘ Z` (Visual Studio (macOS)), `Ctrl+Z` (ReSharper), `⌘ Z` (ReSharper (macOS)), `Ctrl+Z` (QtCreator), `⌘ Z` (QtCreator (macOS)), `Ctrl+Z` (NetBeans), `Ctrl+Z` (Eclipse), `⌘ Z` (Eclipse (macOS)).

Advanced CMake variables are hidden by default, but you can show them by selecting the Show advanced checkbox:

![Show advanced CMake variables](https://resources.jetbrains.com/help/img/idea/2026.2/cl_cmake_variables_advanced.png)

CLion also shows the short description in tooltips for CMake cache variables:

![Boolean variables with tooltips](https://resources.jetbrains.com/help/img/idea/2026.2/cl_cmake_vars_boolean.png)

The IDE shows Boolean values as checkboxes. Next to the checkboxes, you can see the actual values behind the Boolean variables. The following values are treated as `False`: `0`, `OFF`, `NO`, `N`, `IGNORE`, `NOTFOUND`, empty strings, and values that end in the suffix `-NOTFOUND`. In all other cases, the value is treated as `True`.

When you check or uncheck the checkbox in the CLion user interface, the following pairs of values are used to configure option values: `0-1`, `OFF-ON`, `NO-YES`, `FALSE-TRUE`, and `N-Y`. For any other values, the IDE converts the checkbox state to `OFF-ON`.

> **Note:**
> Named Boolean constants are case-insensitive.

## Generators

In the Generator field, you can switch between [CMake generators](https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html). Use the default value for the selected toolchain or set another generator from the predefined list:

![Specifying a custom CMake generator](https://resources.jetbrains.com/help/img/idea/2026.2/cl_cmakeprofile_generators.png)

| Use default |    CLion uses either [Ninja](https://ninja-build.org/) or Makefiles as the default generator.                      Ninja is used when all of the following is true:       * The selected [toolchain](how-to-create-toolchain-in-clion.html) is local (this excludes [Remote](remote-projects-support.html#remote-toolchain), [Docker](clion-toolchains-in-docker.html), and [WSL](how-to-use-wsl-development-environment-in-product.html)).    * The build tool configured for the selected toolchain in Ninja (bundled Ninja is the default build tool).    * CMake version is 3.20 or later.    * The project is created or opened for the first time in CLion 2021.3.    * The Use legacy generator for CMake 3.20 and higher checkbox in [Advanced Settings](advanced-settings.html) is not set.     In all other cases, the Makefiles generator is used.    |
| Let CMake decide | If you choose this option, CLion will not force any generator explicitly, and CMake will decide which generator to use. By default, this is controlled by the [CMAKE_GENERATOR](https://cmake.org/cmake/help/latest/envvar/CMAKE_GENERATOR.html#envvar:CMAKE_GENERATOR) environment variable. |

Alternatively, you can set the generator in CMake options via `-G`.  When the Generator field is used, CLion automatically updates CMake options and vice versa:

![CMake generator in CMake options](https://resources.jetbrains.com/help/img/idea/2026.2/cl_cmakeprofiles_generator_options.png)

> **Note:**
> Actual built tools for a CMake profile are taken from the selected [toolchain](how-to-create-toolchain-in-clion.html).

### Current limitations

* CLion uses [CMake File API](https://cmake.org/cmake/help/v3.15/manual/cmake-file-api.7.html), which first appeared in CMake v3.14. However, the minimum CMake version supported by CLion is 3.15, so if you decide to switch from the bundled CMake, make sure to use version 3.15.x or newer.

* For multi-config generators like Ninja Multi-Config, Xcode, or Visual Studio, CLion uses only the configuration that corresponds to the [build type](#buildtypes) specified in the CMake profile ([CPP-20890](https://youtrack.jetbrains.com/issue/CPP-20890)).

## Build types

Use the Build type field to set one of the following [CMake build types](https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html):

* Default (corresponds to the empty value of CMAKE_BUILD_TYPE).

* Debug (the default build type)

* Release

* RelWithDebInfo (Release with debugging information)

* MinSizeRel (Release optimized for size)

To refer to the build type in `CMakeLists.txt`, use the `CMAKE_BUILD_TYPE` variable. For example:

```CMAKE
if (CMAKE_BUILD_TYPE MATCHES Debug)
    add_definitions(-DDEBUG=1)
endif()
```

You can also create conditional statements in your code based on the current build type:

```CPLUSPLUS
int main(int argc, const char* argv[]) {
#if DEBUG
...
#else
...
#endif
```

### Custom build types

The list of the available build types is defined in the `CMAKE_CONFIGURATION_TYPES` command. The default value of this command is the four build types given above, but you can extend it to have other build types. For example:

```CMAKE
# adding two custom build types to the cached value
# variable CMAKE_CONFIGURATION_TYPES should be defined before other definitions:
set(CMAKE_CONFIGURATION_TYPES "MyDebug;MyRelease" CACHE STRING "" FORCE)
```

After reloading the project, custom types will be available from the CMake settings:

![Custom build types](https://resources.jetbrains.com/help/img/idea/2026.2/cl_cmake_custom_buildtypes.png)

Note that the custom types were added to the value Debug which was cached in `CMakeCache.txt`. So for example, if you add a new CMake profile, it will have its own `CMakeCache.txt`, and for this profile, the list of the available build types will contain your custom types only:

![Custom build types for new cmake profile](https://resources.jetbrains.com/help/img/idea/2026.2/cl_cmake_custom_buildtypes_profiles.png)

## Build options

In the Build options field, you can set the options to be passed either to the build tool used by CMake or as command line parameters to CMake itself. These options will be used during the [build](https://cmake.org/cmake/help/latest/manual/cmake.1.html#build-a-project) phase.

Arguments for the underlying build tool (make, Ninja, or another one) should be preceded with `--`. For example, if you specify `-j 5 --clean-first -- -d -p`, then `-j 5 --clean-first` will be processed by CMake, while `-d -p` will be passed to the build tool.

When nothing is specified in this field, CLion uses default settings which depend on the selected environment. For example, the default setting for build processes running in parallel is `-- -j max(cpucount * 0.8, cpucount - 2)` for make and Ninja, while for [Microsoft Visual C++](quick-tutorial-on-configuring-clion-on-windows.html#MSVC) this option is not set and the field is empty.

## Environment variables

You can pass additional environment variables to CMake generation and build via the Environment field of the `CMake Settings` dialog (navigate to `Settings | Build, Execution, Deployment | CMake`).

> **Note:**
> The environment variables you specify in the profile affect CMake generation and build, but not the binary launch.

The overall impacting environment for CMake generation and build consists of:

* Parent environment To include parent environment, open the Environment Variables dialog by clicking ![](https://resources.jetbrains.com/help/img/idea/2026.2/app.general.inlineVariables.svg) or pressing `Shift+Enter` (Windows), `⇧ ⏎` (macOS), `⇧ ⏎` (IntelliJ IDEA Classic (macOS)), `⇧ ⏎` (macOS System Shortcuts), `Shift+Enter` (XWin), `Shift+Enter` (GNOME), `Shift+Enter` (KDE), `Shift+Enter` (Emacs), `Shift+Enter` (Sublime Text), `⇧ ⏎` (Sublime Text (macOS)), `⇧ ⏎` (Xcode), `Shift+Enter` (Visual Studio), `⇧ ⏎` (Visual Studio (macOS)), `Shift+Enter` (ReSharper), `⇧ ⏎` (ReSharper (macOS)), `Shift+Enter` (QtCreator), `⇧ ⏎` (QtCreator (macOS)), `Shift+Enter` (NetBeans), `Shift+Enter` (Eclipse), `⇧ ⏎` (Eclipse (macOS)), and set the Include system environment variables checkbox. The values you specify additionally will be appended to system variables. Otherwise, when the checkbox is cleared, your custom values will overwrite the system ones.

* Toolchain environment These are the variables defined by the selected toolset (for example, `vcvarsall.bat` for [MSVC](quick-tutorial-on-configuring-clion-on-windows.html#MSVC) or path variables like `mingw/bin`), or the variables from an [environment initialization script](how-to-create-toolchain-in-clion.html#env-scripts). > **Tip:** > You can use [toolchain environment scripts](how-to-create-toolchain-in-clion.html#env-scripts) to set CMake variables from a file.

* CMake profile environment Your custom variables specified in the Environment field.

You can reference existing variables, including the parent environment variables, using the `$VAR$` syntax. Note that such references are case-sensitive: for example, `PATH=xxx:$PATH$` for Linux/macOS and `Path=xxx;$Path$` for Windows.  Referencing existing variables is currently not available for [remote toolchains](remote-projects-support.html) ([CPP-15693](https://youtrack.jetbrains.com/issue/CPP-15693)).

## See also

### Reference

[CMake Profile settings](cmake0.html)

### How tos

[CMakeLists.txt](cmakelists-txt-file.html) [CMake profiling](cmake-profiling.html) [Compilers](how-to-switch-compilers-in-clion.html) [Toolchains](how-to-create-toolchain-in-clion.html) [Build actions](build-actions.html) [Run/debug configurations](run-debug-configuration.html)

