Use CLion CMake Profiles to Manage Debug and Release Builds
Switch between Debug and Release CMake configurations in one CLion project without editing CMakeLists.txt, and verify profile isolation before relying on it.
14 Aug 2025, 19:24 UTC

The problem: one project, two builds
You are working on a C++ project in CLion and need a Debug build with symbols for stepping through code, plus a Release build to measure actual performance. Editing CMakeLists.txt every time you switch is easy to forget and easy to break. Maintaining separate project folders duplicates source control and configuration.
CLion’s CMake profiles address this directly. A profile is a named set of CMake settings—build type, toolchain, and CMake options—attached to the same project. You can switch profiles from the IDE without changing CMakeLists.txt.
What a CMake profile controls
CMake is a build-system generator: it reads CMakeLists.txt and produces native build files for a specific directory. A CLion profile stores the values that go into that generation step. The most common settings are:
- Build type:
Debug,Release,RelWithDebInfo, orMinSizeRel, passed to CMake asCMAKE_BUILD_TYPE. - Toolchain: the compiler, debugger, and CMake executable used for that profile.
- CMake options: arbitrary
-Dcache variables, such as enabling tests or selecting a backend.
A cache variable is a CMake option stored in CMakeCache.txt inside the build directory. Because each profile uses its own generation directory, its cache variables are isolated from other profiles.
Worked example: Debug and Release profiles
This setup assumes a recent CLion release with the bundled CMake. Confirm the bundled version under Help > About and compare it to the cmake_minimum_required version in your project’s CMakeLists.txt.
- Open Settings (Windows/Linux) or Preferences (macOS), then go to Build, Execution, Deployment > CMake.
- Click the plus icon to add a profile. Name it
Debug. In CMake options, enter-DCMAKE_BUILD_TYPE=Debug. Set the build directory to something like.cmake/build/debug. - Add a second profile named
Release. Enter-DCMAKE_BUILD_TYPE=Releaseand set the build directory to.cmake/build/release. - Apply the changes. CLion reloads the CMake project for the active profile.
To switch, open the CMake tool window and use the profile dropdown at the top. Select Release. CLion shows a reload notification and regenerates build files in the Release directory. The CMake tool window lists cache variables, targets, and can generate run/debug configurations from executable targets.
Expected check: after switching, the active profile’s build directory should contain a fresh CMakeCache.txt with the matching CMAKE_BUILD_TYPE. The inactive profile’s directory should remain unchanged.
Reload, reindex, and what to watch
Changing a profile triggers a CMake reload. For large projects this can be slow, and CLion may temporarily block code insight—navigation and refactoring—until indexing finishes. You can enable auto-reload on CMakeLists.txt save, but be aware that each save can start another reload cycle.
Profile-specific cache edits do not migrate automatically. If you add a variable in the Debug profile’s cache and then switch to Release, that variable stays in the Debug generation directory. Do not hand-edit CMakeCache.txt expecting the change to follow you across profiles.
Very new CMake syntax may not be fully supported until the IDE or bundled CMake updates. If a profile fails to reload, check Help > About for the bundled CMake version and consider pointing CLion to a system CMake that meets your project’s requirements.
Verification and closing
Before relying on profiles, run this quick check:
- Open the CMake tool window and open the profile dropdown. Confirm both
DebugandReleaseappear with distinct build directories. - Change
CMAKE_BUILD_TYPEin the Release profile, reload CMake, and confirm the Debug profile still shows its original value. - Run
cmake --versionin the CLion terminal or your system terminal. No special permissions are required. The output should begin withcmake version; compare it to your project’s minimum required version. This command only reads version information.
Risk: reloading can reset transient IDE run configurations tied to the previous profile. Regenerate them from the CMake tool window after switching if they disappear.
Start with two profiles, keep build directories separate, and treat profile switches as configuration changes rather than code changes. To undo a switch, simply select the previous profile from the dropdown; each profile’s state remains in its own build directory.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.