FreeBSD (as well as DragonFly BSD) uses GNU ld for linking, but is not captured in the conditional on Linux or MinGW when setting LIB_NAMES. This causes a shared library with no symbols on FreeBSD. This patch simply adds a check for whether the CMake system name is FreeBSD or DragonFly in addition to the existing checks for Linux and MinGW.
This patch is based on that used by the FreeBSD LLVM 3.9 port, revision 426189. The majority of the diff is by Koop Mast (kwm). Alex Arslan (ararslan) updated it for use on the current LLVM trunk.