Improve cmake for sdl2

Adds more support to CMake so that building SDL2 via CMakeLists.txt works with minimal changes. See https://github.com/gsathya/SDL-emscripten/issues/3
otherwise, lgtm