Update cmake to work in more cases