cppcheck: fix --with-gui option not finding cfg

Fixes #27756.