Updated CMakeLists.txt

Added more user options and resolved an issue with switching between
static and dynamic builds.