Refactor cmake files