Add warning support to CMake

The new CMake option WARNINGS now allows the user to enable warning
support to the compilation. This option is set to OFF as default.
Remove unnecessary code and fix errors

Along with Allan's latest changes, these changes should fix more bugs on
the code.