Full rewrite of all CMakeLists

CMake now works on all platforms
Fix building on non-MSVC compilers

This function is inline, and QVariant uses a copy-on-write like copying mechanism, like most datatypes in Qt.