Refactored some CMake code and added messages.