Adding a New Executable Target in CLion and Verifying the Run Configuration
Learn how to add a new executable target in CLion, reload CMake, and verify that the target appears in the run/debug selector.
28 Jun 2026, 13:31 UTC

Problem: New target missing from run configurations
When you add an executable to a CMakeLists.txt file, CLion should surface it in the run/debug selector so you can launch it without leaving the IDE. If the target does not appear, you may wonder whether the change was ignored, the CMake model is out of sync, or the toolchain is mis‑configured.
Thesis: Reloading CMake and checking the CMake tool window gives you immediate feedback
The reliable way to see the new target is to trigger a CMake reload, inspect the CMake problems view for any configuration errors, and then verify that the target appears in the run configuration dropdown. This workflow works for both single‑config generators (Unix Makefiles, Ninja) and multi‑config generators (Visual Studio, Xcode) as long as the CMake profile points to a valid toolchain.
Worked example: Adding a simple executable
- Open a CMake project in CLion (File → Open). Assume the project already contains a library target
mylib. - In the
CMakeLists.txtat the project root, append the following lines:
add_executable(hello_main src/hello_main.cpp)
target_link_libraries(hello_main PRIVATE mylib)
Save the file. CLion watches for changes and will show a banner “CMakeLists.txt changed. Reload project?” Click the Reload button, or open the CMake tool window and press the reload icon.
After the reload, open the CMake tool window (usually on the left). Expand the project node; you should see hello_main listed under Targets. If the CMake configuration failed, the Problems tab at the bottom will show messages such as “Cannot find source file” or “Unknown CMake command”. Fix those errors and reload again.
Now look at the run configuration selector in the top‑right corner of the IDE. Click the dropdown; you should see an entry named hello_main. Selecting it and pressing the green run button will build the executable (if needed) and launch it using the active toolchain.
To double‑check that the configuration matches your CMake settings, open Settings/Preferences → Build, Execution, Deployment → CMake. Verify that the Generator field shows the generator you expect (e.g., Ninja or Unix Makefiles) and that the Build directory points to a folder inside .cmake under the project. The CMake options field should be empty unless you added custom flags.
Trade‑off / limitation
Large codebases can make the initial CMake reload take several seconds or minutes because CLion re‑indexes all source files to provide navigation and refactoring features. You can reduce this cost by marking directories that do not need indexing (e.g., generated code, third‑party libraries) as excluded: right‑click the folder in the Project view, choose Mark Directory as → Excluded. Another limitation is that non‑standard generators or custom CMake commands that produce targets with unusual naming patterns may not be automatically turned into run configurations; in those cases you can create a manual run/debug configuration via Run → Edit Configurations and point it to the generated executable.
Actionable closing
- Whenever you touch
CMakeLists.txt, trigger a reload and watch the CMake tool window for success or error messages. - Confirm the new target appears under Targets and then in the run configuration dropdown.
- If the target is missing, check the Problems view for configuration errors, verify the generator and build directory in the CMake settings, and consider excluding large sub‑directories to speed up future reloads.
- For exotic generators, fall back to a manual run configuration until the CMake model improves in a later CLion release.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.