In CLion, settings required for building a CMake project are incorporated in a CMake profile. It includes toolchains, build types, CMake options, and environment variables. You can create multiple profiles with different build types and toolchains:
Having multiple CMake profiles enables you, for example, to use different compilers for one project, or to build CMake targets with differing settings.
To build a target using a specific profile, select it in the Run/Debug configuration switcher on the toolbar (or press N/A for Run and N/A for Debug):
By default, CMake supports the following build types:
RelWithDebInfo (Release with debugging information)
MinSizeRel (Release optimized for size)
You can select the required build type in
CMAKE_BUILD_TYPE. For example, add the following code into the CMakeLists.txt script:
Сustom 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:
After reloading the project, custom types will be available from the CMake settings:
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:
You can pass additional environment variables to CMake generation and build via the Environment field of the dialog (navigate to ).
The overall effective environment for CMake generation and build consists of:
To include parent environment, open the Environment Variables dialog by clicking or pressing N/A, 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.
For example, variables defined in vcvarsall.bat for MSVC, path variables like
mingw/bin, and others.
CMake profile environment
Your custom variables specified in the Environment field.