
Now let's declare a new target manually in the CMakeLists.txt. Accordingly, CLion notifies us that the new file currently does not belong to any target:

Since our goal is to create a new target, we clear the Add to targets checkbox. CLion prompts to add the file to an existing target: Right-click the root folder in the Project tree and select New | C/C++ Source File. Now let’s add another source file calc.cpp and create a new executable target from it. To learn more about various build actions available in CLion, see Build actions. So we can use this configuration not only to debug or run our target but also to perform the build. Notice the Before launch area of this dialog: Build is set as a before launch step by default. The target name and the executable name were taken directly from the 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. Build targets and Run/Debug configurations

Sets the CMAKE_CXX_STANDARD variable to the value of 14, as we selected when creating the project.Īdds the cmake_testapp executable target which will be built from main.cpp.Ģ. It is set to the version of CMake bundled in CLion (always one of the newest versions available).ĭefines the project name according to what we provided during project creation. Specifies the minimum required version of CMake.
