Run/Debug my main.cpp in CLion rebuilds a main executable and runs/debugs it, instead of using the cmake-build-default profile it can build

18 hours ago 1
ARTICLE AD BOX

On a simple CLion project, I have this CMakeList.txt:

cmake_minimum_required(VERSION 4.2.3) project(beaufort-tempete LANGUAGES CXX) set(CMAKE_CXX_STANDARD 26) set(CMAKE_CXX_STANDARD_REQUIRED OFF) set(CMAKE_CXX_EXTENSIONS OFF) add_executable(beaufort-tempete src/main.cpp) target_include_directories(beaufort-tempete PUBLIC include)

For toolchain settings, I'm using:

enter image description here that gives me the versions of g++ and CMake required.

For CMake ones, it's:

enter image description here

And I build my project that is limited to that main.cpp:

#include <iostream> using namespace std; int main() { cout << "C++ Version: " << __cplusplus << endl; return 0; }

If I run my program with: ./cmake-build-default/beaufort-tempete,
it responds: C++ Version: 202400 which is expected.

But if I'm willing to Run or Debug main.cpp by the Run or Debug commands in the CLion's menu bar:

enter image description here

It:

Builds another executable: main it puts in src and runs/debugs it. And this one responds: C++ Version: 201703

I've noticed that if I don't generate by CMake the cmake-build-default profile (I'm deleting its folder) and runs main.cpp directly, it succeed in compiling/linking it and produce the main executable that shows this not wished: C++ Version: 201703.

Why aren't my Run/Debug commands linked to the cmake-build-default profile I have created? How can I correct this?


@3CEZVQ : What I can see when I try what you're suggesting to do:

enter image description here

Run... with Edit Configuration on main.cpp is only willing to go there:

enter image description here

And I see no other way to start my executable in Run/Debug mode.

Read Entire Article