Some CMake scripts refactoring