hwinfo
hwinfo copied to clipboard
cross platform C++ library for hardware information (CPU, RAM, GPU, ...)
hwinfo
hwinfo provides an easy-to-use and modern C++ API for retrieving hardware information of your systems components such as CPU, RAM, GPU, Disks, Mainboard, ...
Content
- Functionality
- Build hwinfo
- Example
- Include hwinfo to cmake project
Functionality
| Component | Info | Linux | Apple | Windows |
|---|---|---|---|---|
| CPU | Vendor | ✔️ | ✔️ | ✔️ |
| Model | ✔️ | ✔️ | ✔️ | |
| Frequency | ✔️ | ✔️ | ✔️ | |
| Physical Cores | ✔️ | ✔️ | ✔️ | |
| Logical Cores | ✔️ | ✔️ | ✔️ | |
| Cache Size | ✔️ | ✔️ | ✔️ | |
| GPU | Vendor | ✔️ | ✔️ | ✔️ |
| Model | ✔️ | ✔️ | ✔️ | |
| Memory Size | ❌ | ❌ | ✔️ | |
| Memory (RAM) | Vendor | ❌ | ❌ | ✔️ |
| Model | ❌ | ❌ | ✔️ | |
| Name | ❌ | ❌ | ✔️ | |
| Serial Number | ❌ | ❌ | ✔️ | |
| Total Memory Size | ✔️ | ✔️ | ✔️ | |
| Free Memory Size | ❌ | ❌ | ❌ | |
| Mainboard | Vendor | ✔️ | ❌ | ✔️ |
| Model | ✔️ | ❌ | ✔️ | |
| Version | ✔️ | ❌ | ✔️ | |
| Serial-Number | ❌ | ❌ | ✔️ | |
| Bios | ❌ | ❌ | ❌ | |
| Disk | Vendor | ✔️ | ❌ | ❌ |
| Model | ✔️ | ❌ | ❌ | |
| Serial-Number | ❌ | ❌ | ❌ | |
| Size | ❌ | ❌ | ❌ | |
| Operating System | Name | ✔️ | ✔️ | ✔️ |
| Short Name | ✔️ | ✔️ | ✔️ | |
| Version | ✔️ | ✔️ | ❌ | |
| Kernel | ✔️ | ❌ | ❌ | |
| Architecture (Bit) | ✔️ | ✔️ | ✔️ | |
| Endianess | ✔️ | ✔️ | ✔️ |
Build hwinfo
Requirements: git, cmake, c++ compiler (gcc, clang, MSVC)
- Download repository:
git clone https://github.com/lfreist/hwinfo - Build using cmake:
mkdir build cd build cmake -DCMAKE_BUILD_TYPE=Release .. && make -j $(nproc)
Example
See example.cpp
Include hwinfo in your cmake project
- Download
hwinfointo your project (e.g. in<project-root>/third_party/hwinfo)mkdir third_party cd third_party git clone https://github.com/lfreist/hwinfo - Simply add the following to your
<project-root>/CMakeLists.txtfile:# file: <project-root>/CMakeLists.txt add_subdirectory(third_party/hwinfo) include_directories(third_party/hwinfo/include) - Include
hwinfointo your.cpp/.hfiles:// file: your_benchmarks.cpp #include "hwinfo/hwinfo.h" - Link it in cmake
add_executable(your_executable your_executable.cpp) target_link_libraries(your_executable PUBLIC hwinfo::HWinfo)