Can CMake stop at the first error?
To make CMake stop at the first error add the following to your CMakeLists.txt file.
-Wfatal-errors
This option causes the compiler to abort compilation on the first error occurred rather than trying to keep going and printing further error messages
You can read about more GCC Compiler options if you'd like to know or add more.
For those who are not using CMake, but would like their compiler to stop after the first error, use the flag in your command g++ -Wfatal-errors foo.cpp