출처: http://hiramekun.hatenablog.com/entry/2019/02/20/213421 

실행하고 싶은 파일 위에서 마우스 오른쪽 클릭 → Add executable for single c/cpp file 를 선택하면 단일 파일마다 main()를 실행할 수 있다.

아래의 플러그인 설치 필요

https://plugins.jetbrains.com/plugin/8352-c-c--single-file-execution 

CMakeLists에 executable로서 등록하는 것으로 수동으로도 할 수 있지만 이 기능을 사용하면 편하게 사용할 수 있다.