Install the Xcode command line tools if you don’t need a full install of Xcode.
If you need Xcode command line tools without the HUGE Xcode application and environment, the preferred alternative for many developers is to simply install the Xcode command line tools like this:
When you run that command from the Terminal, a macOS software installation pop-up will appear asking you to install the Xcode command line tools. Of course, go ahead and install those.
And when that is done, try
sudo port again. It should be working as expected.
The Xcode command line tools are basically just the core basics Xcode needs to operate from the command line. It’s the same command line tools you would get from a full Xcode install, but in a much smaller—and in my humble opinion—more reasonable package.
Homebrew is—in my humble opinion/experience—the better and more stable macOS package installer; opt for that over MacPorts methods if possible.
If that doesn’t work, I would recommend you undo what you have done, install Xcode again, uninstall pretty much all of the tools you installed with MacPorts and ditch MacPorts as well. Instead I would highly recommend installing and using Homebrew instead.
Homebrew is a package installer/management system for macOS—much like MacPorts—but in my experience it is cleaner, easier to use and understand and much better supported.
In fact, this answer on Stack Exchange seems to address your requirements of getting
cairo install in macOS but using Homebrew.