Major changes to the CMake files to put more into modules and less into cmake-lists. Also, things were made more general.