

In this case of adding a file automatically, CMake reload is also performed automatically in the background.Ĥ. Set the Add to targets checkbox to automatically add the file to an existing target:Ĭlick OK, and the new file will be added to the add_executable command: Right-click the root folder in the Project tree and select New | C/C++ Source File: Let’s create a new source file general.cpp and add it to our cmake_testapp target. To learn more about various build actions available in CLion, check out Build actions. So we can use this configuration not only to debug or run our target, but also to perform the build. Build is set as a before launch step by default. Notice the Before launch area of this dialog. The target name and the executable name are the same as specified in CMakeLists.txt: Upon the first project loading, CLion automatically adds a run/debug configuration associated with this target:Ĭlick Edit Configurations in the switcher or select Run | Edit Configurations from the main menu to view the details. You can define multiple build targets in a single script.įor now, our test project has only one build target, cmake_testapp. Target is an executable or a library to be built using a CMake script. The CMake tool window opens up automatically in case of load failure.Ģ.
CMAKE MESSAGE WINDOWS
To access it, call View | Tool Windows | CMake or switch to it in the tool windows bar: In the CMake tool window, you can check the progress and status of project load. Sets the CMAKE_CXX_STANDARD variable to the value of 17, as we selected when creating the project.Īdds the cmake_testapp executable target to be built from main.cpp. For most cases, if CMake executable was not changed intentionally, this is the bundled CMake version.ĭefines the project name according to what we provided during project creation. Specifies the minimum required version of CMake, as set in the default toolchain. We get the default project with a single source file main.cpp and the automatically created root CMakeLists.txt containing the following commands: In our example, the project name is cmake_testapp and the selected language standard in C++17. Select File | New Project from the main menu.Ĭhoose C++ Executable on the left-hand pane. Let’s create a new CMake project in CLion. When you create a new CMake project in CLion, a CMakeLists.txt file is automatically generated under the project root. Simple CMake projectĬMake is a meta build system that uses scripts called CMakeLists to generate build files for a specific environment (for example, makefiles on Unix machines).
CMAKE MESSAGE CODE
The source code of the sample project used below is available on GitHub. Step by step, we will learn the basics of CMake as a build system, along with the CLion settings and actions for CMake projects. This tutorial will guide you through the process of creating and developing a simple CMake project.
