Improve cmake sdl

This should fix #367 similar to #514.