Thanks comments.
The issue was that I built the project using the terminal command cmake ..
, and used a copied configuration for debugging.
I removed the previously configured .vscode
folder and used the CMake plugin in VS Code to build and compile, which solved the problem.