Compile using dynamic libraries
Fixed some cmake stuff