Added tools building with CMake.

And a small fix. Some tools are crashing but they build at least now.