Fixing issue with dynamic linking and cmake