remove systemd dependency (#3)
This commit is contained in:
@@ -29,7 +29,6 @@ endif()
|
|||||||
|
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
find_package(Vulkan REQUIRED)
|
find_package(Vulkan REQUIRED)
|
||||||
pkg_check_modules(systemd IMPORTED_TARGET systemd)
|
|
||||||
|
|
||||||
if (WIVRN_BUILD_SERVER)
|
if (WIVRN_BUILD_SERVER)
|
||||||
find_package(CUDAToolkit)
|
find_package(CUDAToolkit)
|
||||||
|
|||||||
@@ -111,7 +111,6 @@ target_link_libraries(
|
|||||||
xrt-external-openxr
|
xrt-external-openxr
|
||||||
xrt-interfaces
|
xrt-interfaces
|
||||||
|
|
||||||
PkgConfig::systemd
|
|
||||||
Boost::pfr
|
Boost::pfr
|
||||||
PkgConfig::AVAHI
|
PkgConfig::AVAHI
|
||||||
PkgConfig::libpulse
|
PkgConfig::libpulse
|
||||||
|
|||||||
+7
-29
@@ -1,35 +1,13 @@
|
|||||||
#include "hostname.h"
|
#include "hostname.h"
|
||||||
|
|
||||||
#include <systemd/sd-bus.h>
|
#include <string>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
std::string hostname()
|
std::string hostname()
|
||||||
{
|
{
|
||||||
sd_bus * bus;
|
char buf[256];
|
||||||
if (sd_bus_default_system(&bus) < 0)
|
int code = gethostname(buf, 256);
|
||||||
return "";
|
if (code == 0)
|
||||||
|
return std::string(buf);
|
||||||
for (auto property: {"PrettyHostname", "StaticHostname", "Hostname"})
|
return "unknown";
|
||||||
{
|
|
||||||
char * hostname = nullptr;
|
|
||||||
sd_bus_error error = SD_BUS_ERROR_NULL;
|
|
||||||
|
|
||||||
if (sd_bus_get_property_string(bus, "org.freedesktop.hostname1", "/org/freedesktop/hostname1", "org.freedesktop.hostname1", property, &error, &hostname) < 0)
|
|
||||||
{
|
|
||||||
sd_bus_error_free(&error);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
sd_bus_error_free(&error);
|
|
||||||
if (hostname && strcmp(hostname, ""))
|
|
||||||
{
|
|
||||||
std::string s = hostname;
|
|
||||||
free(hostname);
|
|
||||||
sd_bus_unref(bus);
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sd_bus_unref(bus);
|
|
||||||
|
|
||||||
return "Unknown";
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user