Open or Create Projects
Open a project
To open an existing CMake project in CLion, you can:
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, then choose Open as Project.
Select File | Open and locate the CMakeCache.txt file then choose Open as Project.
Create a new project
If no project is currently opened in CLion, click New Project on the Welcome screen. Otherwise, select on the main menu.
In the New Project dialog that opens, select the target type of your project (executable or library), and the language to be used (pure C or C++). CLion will generate the top-level CMakeLists.txt file based on the provided settings.
New project example
As an example, let's create a simple shared library assuming the C++ 11 standard.
Click New Project from the Welcome screen or the File menu.
In the left pane, choose C++ library.
In the right pane, set the location and the name of your project. You can type the path in the text field or click to browse for the desired folder.
Click the Language standard control and select the standard from the drop down list (C++11 in our example).
Use the Library type control to select the library type (shared in our example).
Click Create to create a project and generate the corresponding CMakeLists.txt file:
Create a CMake project from sources
To work with non-CMake sources in CLion, you can convert them into a CMake project structure.
On the main menu, chooseand select the path to the sources.
In the Import CMake Project dialog, 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 command. CLion includes a directory automatically when it contains at least one header file, if it is named include, or when it has subdirectories that contain header files only.
Note that directories not selected in the Select Project Files pane are not presented in the User Include Directories list - select them first, and then the available include directories will appear in the list.