Cleaned up and restructured all the cmake files (use OBJECT targets to avoid repetition of compilation).