cmake: a lot of fixes