CLion 2018.3 Help

Load/Reload CMake Project

When a CMakeLists.txt file changes, CLion shows a banner on top of the editor:

cl reload cmake

As you see, CLion suggests to reload the current project using the following options:

  • Reload changes

  • Enable Auto-reload

Choose the first option to reload the current project manually. In this case, the subsequent editing on the file CMakeLists.txt will lead to showing the same banner.

The second option results in selecting the checkbox Automatically reload CMake project on editing in the CMake page of Settings. All the subsequent changes of the file CMakeLists.txt will cause the automatic reload of the current project and will pass unnoticed.

It is possible to make CLion always reload automatically. This is done in one of the following ways:

  • Open Settings, and under the Build, Execution, Deployment node click the CMake page. Then select the checkbox Automatically reload CMake project on editing.

  • Click artwork studio icons common search and type reload cmake. Click the line with the required action:

    cl cmake reload

In addition, CLion allows you to reload the project using the main menu. To reload a project from the main menu, do one of the following:

  • On the main menu, choose File | Reload Project

  • On the main menu, choose Tools | CMake | Reload Project

  • In CMake tool window, click the icons actions refresh svg button

Besides, a project is reloaded when you perform the Reset CMake Cache action, as described below.

Reset CMake cache

In some cases you may need to reset the CMake cache before building a project, without affecting the CLion cache. To reset the CMake cache and reload the project, do one of the following:

  • Go to Tools | CMake | Reset Cache and Reload Project.

  • Click the IconDBToolbarMenu button of the CMake tool window. In the drop down menu that opens, select the icon forceRefresh 2x Reset Cache and Reload Project option.

Troubleshooting

You may face the following cases when working on your project:

CMakeLists.txt file is not detected

If you open a project in CLion, but no CMakeLists.txt file is detected (e.g. the project does not contain a CMakeLists.txt file or it is located out of the project root folder), you can see that there is no CMake tool window opened. Besides, the CMake related options such as Reload CMake Project, Change Project Root Directory, and other options of the main and context menus are unavailable: the project is not associated with the CMake build system. To associate your project with CMake, click the warning message Select CMakeLists.txt file:

cl SelectCMake
Select the desired CMakeLists.txt in the dialog that opens.

CLion detected an improper CMakeLists.txt file

If CLion detects a CMakeLists.txt file, but you want to use another one for your project, then you need to disassociate a project from CMake, and then link the project again with the proper CMakeLists.txt. To do that:

  1. Go to the Tools | CMake main menu option and select Unload CMake Project option from the drop down menu:

    cl SelectUnloadCmake

  2. Upon this action, the CLion's state is as described in case #1. Now do one of the following:

    • Click Select CMakeLists.txt file and select the proper CMakeLists.txt file from the dialog.

    • Find the desired CMakeLists.txt file in the Project View and right click it. Select Load CMake Project from the context menu.

Unload CMake

If you need to unlink your project off the CMake build system completely, use the Unload CMake Project action as described above.

Last modified: 7 December 2018

See Also

Languages, Frameworks and Technologies:

Reference:

External Links: