Fixed up broken CMake setup.

Rebase into this when the library mess has been sorted out