message: [vcpkg] Fix get_executable_path on BSD
diff: #include <mach-o/dyld.h>
  #endif
  +#if defined(__FreeBSD__)
  +#include <sys/sysctl.h>
  +#endif
  +
  #pragma comment(lib, "Advapi32")
  namespace vcpkg::System
  @@ -35,7 +39,7 @@ namespace vcpkg::System
  const int bytes = GetModuleFileNameW(nullptr, buf, _MAX_PATH);
  if (bytes == 0) std::abort();
  return fs::path(buf, buf + bytes);
  -#elif __APPLE__
  +#elif defined(__APPLE__)
  uint32_t size = 1024 * 32;
  char buf[size] = {};
  bool result = _NSGetExecutablePath(buf, &size);
  @@ -43,6 +47,14 @@ namespace vcpkg::System
  std::unique_ptr<char> canonicalPath(realpath(buf, NULL));
  Checks::check_exit(VCPKG_LINE_INFO, result != -1, "Could not determine current executable path.");
  return fs::path(std::string(canonicalPath.get()));
  +#elif defined(__FreeBSD__)
  + int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1};
  + char exePath[2048];
  + size_t len = sizeof(exePath);
  + auto rcode = sysctl(mib, 4, exePath, &len, NULL, 0);
  + Checks::check_exit(VCPKG_LINE_INFO, rcode == 0, "Could not determine current executable path.");
  + Checks::check_exit(VCPKG_LINE_INFO, len > 0, "Could not determine current executable path.");
  + return fs::path(exePath, exePath + len - 1);
  #else /* LINUX */
  std::array<char, 1024 * 4> buf;
  auto written = readlink("/proc/self/exe", buf.data(), buf.size());
  