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
in what way is cmake different than configure? aren't cmake's config-time builds also just for testing?