Portability overhaul (no functionality changes)

* Created CMake build system for library and apps
* Separated functions out into more traditional library,app,header locations
* Compatible with GCC and MSVC
* Can detect if it's part of a larger build, only builds library in that case