Added CMake rules and addressed uncaught exceptions.