CMakeLists File
CMakeLists.txt file contains a set of directives and instructions describing the project's source files and targets (executable, library, or both).
When you create a new project, CLion generates CMakeLists.txt file automatically and places it into the project root directory. To open the project, you can simply open the top-level CMakeLists.txt file.
For projects with complex structure, you can create subdirectory CMakeList.txt files to describe the build, contents, and target rules for a subdirectory. Type of a target added by a subdirectory CMakeLists.txt
file can differ depending on the role of a module.
Example below shows the CMakeLists.txt
file of a simple "Hello, World!" project:
cmake_minimum_required(VERSION 3.6) # CMake version check
project(simple_example) # Create project "simple_example"
set(CMAKE_CXX_STANDARD 11) # Enable c++11 standard
set(SOURCE_FILES main.cpp) # Add main.cpp file of project root directory as source file
add_executable(simple_example ${SOURCE_FILES}) # Add executable target with source files listed in SOURCE_FILES variable
You can edit CMakeLists.txt files right in the Editor. Make sure to reload the project after editing. Automatic reload feature is disabled by default, you can turn it on by selecting the Automatically reload CMake project on editing checkbox in .