Added CMake support

This branch adds support for CMake. It's based on the existing PR #1 and #2 and has been tested with MinGW-w64 GCC 4.9.1 and Visual Studio 2013.