Fix unstandardized CMakeLists

Also improved compatibility with OS X.
http://stackoverflow.com/questions/7724569/debug-vs-release-in-cmake
Fix inconsistency in definition
Fix return type inconsistency