Refactoring of CMake files

Added dependent libraries as TARGET_LINK_LIBRARIES to library targets.
Fixed generation and compilation on Ubuntu