cmake: make the library a shared lib
cmake: a bit of cleanup and add some program checking