Refactor for CMake and C++