I have run into this problem before but forgot about it. The instructions on the KDE for FreeBSD site says to use portmaster to install the packages for some reason: https://freebsd.kde.org/ports.php
This should work because that is what the -PP option in portmaster is for. This must be one of those extremely rare bugs in FreeBSD software. In any case, pkg works fine and compiling it I'm sure works fine too. I decided to install by packages to one computer and wait it out to compile on another computer.