Clion automatically adds add_executable
Install a plug-in C/C++ Single File Execution, path File-Settings-plugins, search for C/C++ Single File Execution and install, and finally apply.
The preparation is complete. Next, you can create a new c/cpp file. After entering the code, press the ctrl+alt+shift+E shortcut or right-click in the code area to find add executable for simple C/C++ file and click, then right-click in the project area on the left and select reload CMake For Project, you can select auto-reload so that it can be automatically added to the executable file every time you right-click and add.
Support me if it's useful