11#include <OpenMS/build_config.h>
22#elif defined(__APPLE__)
23 #include <sys/types.h>
24 #include <sys/sysctl.h>
37 inline const std::string
OpenMS_OSNames[] = {
"unknown",
"MacOS",
"Windows",
"Linux"};
46 typedef NTSTATUS (WINAPI* RtlGetVersionPtr)(PRTL_OSVERSIONINFOW);
47 HMODULE hMod = GetModuleHandleW(L
"ntdll.dll");
50 auto fxPtr =
reinterpret_cast<RtlGetVersionPtr
>(GetProcAddress(hMod,
"RtlGetVersion"));
53 RTL_OSVERSIONINFOW rovi{};
54 rovi.dwOSVersionInfoSize =
sizeof(rovi);
55 if (fxPtr(&rovi) == 0)
57 return std::to_string(rovi.dwMajorVersion) +
"." + std::to_string(rovi.dwMinorVersion)
58 +
"." + std::to_string(rovi.dwBuildNumber);
63#elif defined(__APPLE__)
64 char version[64] = {};
65 size_t len =
sizeof(version);
66 if (sysctlbyname(
"kern.osproductversion", version, &len,
nullptr, 0) == 0)
68 return std::string(version);
71#elif defined(__unix__)
73 std::ifstream ifs(
"/etc/os-release");
75 while (std::getline(ifs, line))
77 if (line.compare(0, 11,
"VERSION_ID=") == 0)
79 std::string val = line.substr(11);
81 if (val.size() >= 2 && val.front() ==
'"' && val.back() ==
'"')
83 val = val.substr(1, val.size() - 2);
103 os_version_(
"unknown"),
128 size_t bytes =
sizeof(size_t);
132 return OpenMS_ArchNames[
static_cast<size_t>(OpenMS_Architecture::ARCH_32BIT)];
134 return OpenMS_ArchNames[
static_cast<size_t>(OpenMS_Architecture::ARCH_64BIT)];
136 return OpenMS_ArchNames[
static_cast<size_t>(OpenMS_Architecture::ARCH_UNKNOWN)];
148 info.
os_ = OpenMS_OS::OS_WINDOWS;
149 #elif (defined(__MACH__) && defined(__APPLE__))
150 info.
os_ = OpenMS_OS::OS_MACOS;
151 #elif (defined(__unix__))
152 info.
os_ = OpenMS_OS::OS_LINUX;
159 if (
sizeof(
void*) == 4)
161 info.
arch_ = OpenMS_Architecture::ARCH_32BIT;
165 info.
arch_ = OpenMS_Architecture::ARCH_64BIT;
191 return OPENMS_BUILD_TYPE;
200 return omp_get_max_threads();
210 omp_set_num_threads(num_threads);
Definition BuildInfo.h:95
static String getActiveSIMDExtensions()
Obtain a list of SIMD extensions which are currently in use (i.e. used by the compiler during optimiz...
static String getBinaryArchitecture()
Get Architecture of this binary (simply by looking at size of a pointer, i.e. size_t).
Definition BuildInfo.h:126
String os_version_
Definition BuildInfo.h:97
OpenMS_Architecture arch_
Definition BuildInfo.h:98
OpenMSOSInfo()
Definition BuildInfo.h:101
String getOSVersionAsString() const
Get the OS version (e.g. 10.15 for macOS or 10 for Windows)
Definition BuildInfo.h:120
static OpenMSOSInfo getOSInfo()
Constructs and returns an OpenMSOSInfo object.
Definition BuildInfo.h:144
OpenMS_OS os_
Definition BuildInfo.h:96
String getArchAsString() const
Get the current architecture (32-bit or 64-bit)
Definition BuildInfo.h:114
String getOSAsString() const
Get the current operating system (Windows, MacOS, Linux)
Definition BuildInfo.h:108
A more convenient string class.
Definition String.h:34
int Int
Signed integer type.
Definition Types.h:72
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition Types.h:97
std::string getOSVersionString_()
Helper: get OS version string using platform APIs.
Definition BuildInfo.h:42
const std::string OpenMS_ArchNames[]
Definition BuildInfo.h:39
OpenMS_Architecture
Definition BuildInfo.h:38
@ SIZE_OF_OPENMS_ARCHITECTURE
OpenMS_OS
Definition BuildInfo.h:36
const std::string OpenMS_OSNames[]
Definition BuildInfo.h:37
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
Struct with some static methods to get informations on the build configuration.
Definition BuildInfo.h:175
static String getBuildType()
Get the build type used during building the OpenMS library.
Definition BuildInfo.h:189
static Size getOpenMPMaxNumThreads()
Get the maximum number of threads that OpenMP will use (including hyperthreads) Note: This could also...
Definition BuildInfo.h:197
static void setOpenMPNumThreads(Int num_threads)
Set the number of threads that OpenMP will use (including hyperthreads) Note: Can be initialized by t...
Definition BuildInfo.h:207
static bool isOpenMPEnabled()
Checks if OpenMP was enabled during build, based on the _OPENMP macro.
Definition BuildInfo.h:179