CMake project structuring and library fixes