lfreist / hwinfo

cross platform C++ library for hardware information (CPU, RAM, GPU, ...)
MIT License
459 stars 79 forks source link

Make HWinfo modular #94

Closed lfreist closed 2 months ago

lfreist commented 3 months ago

I would suggest removing GPU information from the library entirely. If people need information about the GPU, getting it from Vulkan, DirectX, OpenGL, or OpenCL is already really well documented. Those standards [and similar] are really the only places people would need it anyhow.

I would suggest removing GPU information from the library entirely. If people need information about the GPU, getting it from Vulkan, DirectX, OpenGL, or OpenCL is already really well documented. Those standards [and similar] are really the only places people would need it anyhow.

I'm not trying to be rude, but there really is zero reason to include it. For people who are already using one of these frameworks, adding OpenCL on top of it is unacceptable in most cases especially considering OpenCL is on its way out the door to be replaced with other alternative frameworks.

Edit: Had a quick think. It'd probably be better to make the entire library modular. You already have the library well divided as appropriate, making it modular seems like a very safe next step. In other words, I mean making the motherboard, battery, CPU, etc. dependent on user choice.

original post by @F35H in https://github.com/lfreist/hwinfo/issues/54#issuecomment-2212381153

aminya commented 3 months ago

There are still benefits to providing this information in an abstracted way. That's the point of giving a cross-platform way to know the hardware information.

However, we can provide separate CMake targets (libraries) and in the super-target, we can guard these features using CMake compile flags that set up the dependencies. This provides granular access for those interested as well as providing an easy way to access all the info in one target.

CMakeLists.txt

add_library(hwinfo_gpu)
add_library(hwinfo_cpu)
# etc.

add_library(hwinfo)

option(HWINFO_GPU "Provide GPU information" ON)
if (HWINFO_GPU)
    target_link_libraries(hwinfo PUBLIC hwinfo_gpu)
    target_compile_definitions(hwinfo PUBLIC "HWINFO_GPU")
endif()

# etc.

hwinfo.h

#pragma once

#ifdef HWINFO_GPU
#include <hwinfo/gpu.h> // IWYU pragma: export
#endif

// etc.

Those who only need hwinfo_cpu for example, can only link that target. Those who use the hwinfo target directly, can use CMake flags to customize the features.

lfreist commented 2 months ago

Yes, the plan is to continue supporting GPU using OpenCL (and maybe also other backends...) but provide the information of the hardware components in modules (as CMake targets hwinfo_[gpu|cpu|ram|disk|mainboard|...])