CMake remains the project model that’s most deeply integrated into CLion.
Any CMake-based projects can be opened easily in CLion, with no additional configuration needed:
In case you'd like to mark directories manually as libraries or project sources/headers, or exclude some directories (i.e. independently from the CMake project structure), you can do this with the Mark directory as feature. This will affect indexing (for example, you can exclude build directories, binaries, logs and generated data from indexing), along with code generation, refactorings and navigation. Find more details.
If you need to detect that CMake command on your project was run from CLion (and if so, set special variables/paths or execute some additional scripts of your choice) use CLION_IDE environment variable. To make it easier to find it CLion provides you with the environment variables completion.
When adding a new file, CLion suggests to add it to the CMake target.
When deleting files from the project, CLion removes the file reference from the command arguments, or warns you about a possibly incorrect command after deletion.
You can also import non-CMake projects (
File | Import Project...),
CLion will generate a CMakeLists.txt file.
Support for the CMake File API lets CLion enable various CMake generators. Users can select Ninja, Xcode, Visual Studio, etc. This works for all platforms, in remote mode, and with WSL.Learn more
With CMake profiles (
Build, Execution, Deployment | CMake) you have control
CMake generation directory, CMake configuration types, CMake options and environment
Create any necessary number of CMake profiles from scratch, or copy existing ones (with all the settings pre-filled). Store your project build configuration in new and universal CMake Presets, and CLion will automatically detect and import the necessary CMake Presets into CMake Profiles.
Switch between CMake profiles in the run configuration switcher on the toolbar or in the Run (Shift+Alt+F10)/Debug (Shift+Alt+F9) configuration switcher popup.
CMake tool window includes the CMake output logs, that can be used to track the progress and debug CMake scripts.
You can review CMake cache variables and update CMake options that are passed to the CMake command in a single table-based UI in Settings | Build, Execution, Deployment | CMake.
When the table is in focus, start typing to search for a variable or its value. CLion also shows the short description in tooltips for CMake cache variables.
Tools | CMake for useful CMake-related actions:
Build, Execution, Deployment | CMakesettings).
If you use Rename refactoring Shift+F6 to rename user symbols in CMake (like functions or macros), all the usages will be updated automatically.
If you have any CMake install targets in your project, you can call Install from the CLion’s Run menu now. The cmake install command will be executed. Alternatively, you can add an Install step to any of your run configurations in CLion.
CLion supports CMake 3 bracket-arguments and block comments syntax. To quickly comment a line in CMake, you don’t need to select it — simply put the caret on it and press Ctrl+/ . To comment a block, select it and press Ctrl+Shift+/.
The CMake file editor in CLion helps you edit CMakeLists.txt files more easily. This includes:
find_packagefor packages bundled with CMake.
Create frequently-used or custom code constructs in CMake and reuse them with live templates. Select between predefined templates or create your own.
To use the template, type its abbreviation (you can use auto-completion here as well) and then press Tab (or any non-default key you’ve configured) to expand the template.
After you finish editing, a banner shows up where you can choose to reload the current project manually, or enable automatic reload on every edit.
The Quick Documentation popup is now available in CMake scripts. The documentation is shown for the standard CMake entities:
Documentation is always rendered for the currently bundled CMake version and is not available for the user-defined entities for now.
Since CMake is a language of build systems, investigating errors and catching suspicious behavior in a CMake script is not always easy. You can debug CMake scripts in CLion as regular code. Set breakpoints, step through code, and watch CMake variables and targets. Learn more.
In CLion, you can visually inspect why it takes a long time to reload your CMake project. Starting with CMake 3.18, the new tracing can be enabled in the CMake settings. CLion will help you run the tracing and visualize the results. Learn more.