cmake: refactor os prefix stuff