fix bugs and rewrite GLEW finding code to be more clear.

fix cmake GLEW bugs, for issue #246