Fixing cppcheck warnings and cleaning top-level CMakeLists

Change-Id: I58205203e168a2fdc59bdf59ecc17dc188dbe747