# Create/open CMake projects

Procedure: Create a CMake project from scratch

1. Click New Project on the Welcome screen or select `File | New Project` from the main menu.

2. Select C++ Executable in the left-hand pane. Set the project name and the language standard.

![Creating a new CMake project](https://resources.jetbrains.com/help/img/idea/2026.2/cl_cmaketutorial_create_prj.png)

3. Click Create.

4. CLion generates a stub project with a single source file `main.cpp` and root [CMakeLists.txt](cmakelists-txt-file.html) containing the following commands:

![CMakeLists.txt in a stub CMake project](https://resources.jetbrains.com/help/img/idea/2026.2/cl_simple_cmakeprj.png)

| Command | Description |
| --- | --- |
| `cmake_minimum_required(VERSION 3.31)` | [Specifies](https://cmake.org/cmake/help/latest/command/cmake_minimum_required.html) the minimum required version of CMake. It is set to the version of CMake bundled in CLion (always one of the newest versions available). |
| `project(cmake_testapp)` | Defines the project name according to what we provided during project creation. |
| `set(CMAKE_CXX_STANDARD 20)` | [Sets](https://cmake.org/cmake/help/latest/command/set.html) the CMAKE_CXX_STANDARD variable to the value of 20, as we selected when creating the project.     |
| `add_executable(cmake_testapp main.cpp)` | [Adds](https://cmake.org/cmake/help/latest/command/add_executable.html) the cmake_testapp executable target which will be built from `main.cpp`. |

> **Tip:**
> You can adjust the template code in [file templates for C/C++ and CMake files](using-file-and-code-templates.html#cpp-templates).

5. CMake tool window shows the progress and status of the project load. You can always access it from `View | Tool Windows | CMake` or switch to it in the navigation bar at the bottom.

![CMake tool window](https://resources.jetbrains.com/help/img/idea/2026.2/cl_cmaketutorial_toolwindow.png)

> **Tip:**
> The CMake tool window opens up automatically in case of load failure.

Procedure: Create a CMake project from sources

In CLion, you can open a non-CMake project and convert its structure into CMake.

1. Click Open on the Welcome screen or select `File | Open` from the main menu.

2. Select the project root folder and click Open:

![Opening a non-CMake project folder](https://resources.jetbrains.com/help/img/idea/2026.2/cl_non_cmake_open_project.png)

3. Open any source file in the editor. You will see the ![](https://resources.jetbrains.com/help/img/idea/2026.2/app.general.inspectionsWarningIcon.svg) notification of the `Project Status Widget` in the status bar:

![Project not configured notification](https://resources.jetbrains.com/help/img/idea/2026.2/cl_non_cmake_is_not_configured.png)

Click ![](https://resources.jetbrains.com/help/img/idea/2026.2/app.general.inspectionsWarningIcon.svg), select Configure CMake Project, and then Create CMakeLists.txt:

![Create CMakeLists.txt](https://resources.jetbrains.com/help/img/idea/2026.2/cl_non_cmake_configure.png)

> **Tip:**
> The Create CMakeLists.txt action appears only when there is no `CMakeLists.txt` under the project root, disregarding the subfolders.
>
>
>
> If there is a `CMakeLists.txt` file under the root, the only available action will be Select CMakeLists.txt.

> **Tip:**
> You can also use `c_cpp_properties.json` to help CLion find header files that are mentioned in `.cpp` files and should be included in the project.
>
>
>
> If there is no project model loaded and the headers are located in non-automatically included paths, you can include them using `c_cpp_properties.json`. The language engine then takes them into account during code analysis and code insight.
>
>
>
> Learn more in the [c_cpp_properties.json reference](https://code.visualstudio.com/docs/cpp/customize-cpp-settings).

4. In the dialog that opens, specify the following:

* Select project files. Select the files to be imported as project files. Use the subdirectories checkboxes to import their entire contents or clear the checkboxes to import the contents selectively.

* User include directories. Select the directories to be included in the project and specified in the CMake [include_directories](https://cmake.org/cmake/help/latest/command/include_directories.html) command. Directories not selected in Select project files are not presented in the User include directories list - select them first, and then the available include directories will appear in the list. ![Create CMakeLists.txt dialog](https://resources.jetbrains.com/help/img/idea/2026.2/cl_non_cmake_create_cmk_list.png)

5. After you click OK, CLion generates a `CMakeLists.txt` file according to your selections and loads the CMake project structure.

![CMakeLists.txt generated](https://resources.jetbrains.com/help/img/idea/2026.2/cl_non_cmake_cmk_list_include.png)

Procedure: Open a CMake project

> **Tip:**
> See [this instruction](#monorepos) if you are working with a monorepo.

To open an existing CMake project in CLion, do one of the following:

* Select File | Open and locate the project directory. This directory should contain a `CMakeLists.txt` file.

* Select File | Open and point CLion to the top-level `CMakeLists.txt` file (or locate the `CMakeCache.txt` file).

Then click Open as Project:

![Opening CMakeLists.txt as project](https://resources.jetbrains.com/help/img/idea/2026.2/cl_cmake_openasproject.png)

When you open a project for the first time, CLion displays the [CMake Profiles](cmake-profile.html) dialog with the initial configuration. You can edit the profile or proceed with default settings.

![Default CMake profile settings](https://resources.jetbrains.com/help/img/idea/2026.2/cl_cmake_default_profile.png)

To disable this initial profile configuration, go to `Settings | Advanced Settings` and clear the corresponding checkbox:

![Initial CMake profile configuration setting](https://resources.jetbrains.com/help/img/idea/2026.2/cl_cmake_advancedsettings_initialprofile.png)

> **Note:**
> You can set up a [CMake profile](cmake-profile.html) to be used for all new projects by default (`File | New Projects Setup | Settings for New Projects | Build, Execution, Deployment | CMake`).

Procedure: Work with a monorepo

Monorepos are repositories that combine multiple projects, usually without a top-level CMake script. Instructions below describe how to work with a monorepo in CLion using [LLVM Project](https://github.com/llvm/llvm-project) as an example.

1. Call `File | Open` and point CLion to `CMakeLists.txt`  in the required subdirectory. For the case of LLVM, select `llvm-project/llvm/CMakeLists.txt`.

In the dialog that opens, click Open as Project.

2. In the Open Project Wizard,  add the subprojects that you want to build in the CMake options field.

For example, to add clang and clang-tools-extra, specify

```
-DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra"
```

![Compiler flags for LLVM subprojects](https://resources.jetbrains.com/help/img/idea/2026.2/cl_llvmmonorepo_flags.png)

Project load should perform successfully at this point.

3. To be able to view the entire repository in the Project tree, change the project root: call `Tools | CMake | Change Project Root` from the main menu and select the top-level repository folder, `llvm-project`.

4. We also recommend that you [build](build-actions.html) the project. This way, resolve will work on the entire codebase, including the parts generated at build time.

## See also

### Concepts

[Projects](project.html)

### Procedures

[Quick CMake tutorial](quick-cmake-tutorial.html)

### How tos

[File templates](using-file-and-code-templates.html)

### External Links

[JetBrains CLion Blog](http://blog.jetbrains.com/clion/)

