cmake: more cleanup / code deduplication