diff --git a/CMakeLists.txt b/CMakeLists.txt index b676edd..fd908b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,6 +72,9 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "OpenBSD") message(STATUS "OpenBSD detected") message(WARNING "OpenBSD is still experimental!") set(METER_SOURCES "openbsd/memory.cc" "openbsd/cpu.cc" "openbsd/load.cc") + if(CMAKE_SYSTEM_VERSION VERSION_LESS 5.7) + add_definitions(-DOPENBSD_WORKAROUND=1) + endif() else() message(FATAL_ERROR "Cannot be compiled on this system") endif() diff --git a/openbsd/memory.cc b/openbsd/memory.cc index 5724303..832cbbf 100644 --- a/openbsd/memory.cc +++ b/openbsd/memory.cc @@ -18,9 +18,22 @@ #include #include + +// Ugly fix to compilation on OpenBSD 5.6 +// these need to be before include sys/mount.h +// and be in this exact order. Otherwise compiling on +// OpenBSD 5.6 will fail with missing NGROUPS define +// or missing gid_t typedefs +#ifdef OPENBSD_WORKAROUND +#include // typedefs +#include // missing NGROUPS +#include +#else +#include +#endif + #include // VFS_* which we use to get cache #include -#include #include // vmtotal struct #include "error.h"