cross platform C++ library for hardware information (CPU, RAM, GPU, ...)
cross platform C++ library for hardware information (CPU, RAM, GPU, ...)
Warning hwinfo.io is not affiliated with this repository. Any claim that this is the official product repository of hwinfo.io is false.
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, ...
Note
If you face any issues, find bugs or if your platform is not supported yet, do not hesitate to create an issue.
Note
The listed components that are not yet implemented (indicated with ❌) are in development and will be supported in future releases. You are welcome to start contributing and help improving this library!
| 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 | ✔️ | ✔️ | ✔️ | |
| Free Size | ✔️ | ✔️ | ✔️ | |
| Volumes | ✔️ | ✔️ | ✔️ | |
| Operating System | Name | ✔️ | ✔️ | ✔️ |
| Short Name | ✔️ | ✔️ | ✔️ | |
| Version | ✔️ | ✔️ | ❌ | |
| Kernel | ✔️ | ✔️ | ❌ | |
| Architecture (Bit) | ✔️ | ✔️ | ✔️ | |
| Endianess | ✔️ | ✔️ | ✔️ | |
| Battery | Vendor | ✔️ | ❌️ | ❌ |
| Model | ✔️ | ❌ | ❌ | |
| Serial Number | ✔️ | ✔️ | ❌ | |
| Technology | ✔️ | ❌ | ❌ | |
| Capacity | ✔️ | ✔️ | ️❌ | |
| Charging | ✔️ | ✔️ | ❌ |
All components are available via the hwinfo::hwinfo target, or via individual CMake targets, which you can choose and
link against depending on your needs.
target_link_libraries(your_target PRIVATE hwinfo::hwinfo)or
target_link_libraries(
your_target
PRIVATE hwinfo::cpu
hwinfo::gpu
hwinfo::ram
hwinfo::mainboard
hwinfo::disk
hwinfo::os
hwinfo::battery)The CMake options control which components will be built and available in the library:
HWINFO_OS "Enable OS detection" (default to ON)HWINFO_MAINBOARD "Enable mainboard detection" (default to ON)HWINFO_CPU "Enable CPU detection" (default to ON)HWINFO_DISK "Enable disk detection" (default to ON)HWINFO_RAM "Enable RAM detection" (default to ON)HWINFO_GPU "Enable GPU detection" (default to ON)HWINFO_GPU_OPENCL "Enable usage of OpenCL in GPU information" (default to OFF)HWINFO_BATTERY "Enable battery detection" (default to ON)hwinfoRequirements: git, cmake, c++ compiler (gcc, clang, MSVC)
git clone https://github.com/lfreist/hwinfomkdir build
cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_CONFIGURATION_TYPES=Release
cmake --build build --config Release_static (e.g. hwinfo_static)The output should look similar to this one:
…git clone https://github.com/lfreist/hwinfo && cd hwinfo
mkdir build
cmake -B build && cmake --build build
cmake --install buildCMakeLists.txt file:# file: CMakeLists.txt
find_package(hwinfo REQUIRED)hwinfo into your .cpp/.h files:// file: your_executable.cpp
#include
int main(int argc, char** argv) {
// Your code
}add_executable(your_executable your_executable.cpp)
target_link_libraries(your_executable PUBLIC lfreist-hwinfo::hwinfo)hwinfo into your project (e.g. in /third_party/hwinfo)mkdir third_party
cd third_party
git clone https://github.com/lfreist/hwinfo/CMakeLists.txt file:# file: /CMakeLists.txt
# define the HWINFO_* options if you want to change the default values
add_subdirectory(third_party/hwinfo)hwinfo into your .cpp/.h files:// file: your_executable.cpp
#include "hwinfo/hwinfo.h"
int main(int argc, char** argv) {
// Your code
}add_executable(your_executable your_executable.cpp)
target_link_libraries(your_executable PUBLIC lfreist-hwinfo::hwinfo)No open issues yet, or sync has not completed.