Replace config.h with cmake template; fix more compile warnings