1 Commits

Author SHA1 Message Date
Wilde Simon
b4e234f307 Add handling for missing nvml lib 2022-10-19 10:27:06 +02:00
10 changed files with 58 additions and 29 deletions

View File

@@ -1,5 +1,5 @@
pkgname=fantasize pkgname=fantasize
pkgver=0.1.8 pkgver=0.1.7
pkgrel=1 pkgrel=1
pkgdesc='C++ fan control for Linux' pkgdesc='C++ fan control for Linux'
url='https://github.com/Tabascl/fantasize.git' url='https://github.com/Tabascl/fantasize.git'

1
app/.clang-format Normal file
View File

@@ -0,0 +1 @@
BasedOnStyle: Google

View File

@@ -1,18 +1,32 @@
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.0)
project(fantasize VERSION 0.1.8) project(fantasize VERSION 0.1.7)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
find_package(nlohmann_json 3.11.2 REQUIRED) find_package(nlohmann_json 3.7 REQUIRED)
find_package(Boost 1.74 COMPONENTS program_options log log_setup date_time REQUIRED) find_package(Boost 1.80 COMPONENTS program_options log log_setup date_time REQUIRED)
find_library(NVML_LIB nvidia-ml)
set(ADDITIONAL_LIBS)
if (NVML_LIB)
set(HAVE_NVML)
add_library(nvidia-sensor-lib STATIC
src/sensor/NvidiaSensor.cxx
src/sensor/GPUSensorsFacade.cxx)
target_link_libraries(nvidia-sensor-lib PUBLIC NVML_LIB)
list(APPEND ADDITIONAL_LIBS nvidia-sensor-lib)
endif()
add_executable(${PROJECT_NAME} add_executable(${PROJECT_NAME}
src/main.cxx src/main.cxx
src/sensor/LMSensorsFacade.cxx src/sensor/LMSensorsFacade.cxx
src/sensor/GPUSensorsFacade.cxx
src/sensor/Sensor.cxx src/sensor/Sensor.cxx
src/sensor/NvidiaSensor.cxx
src/sensor/LMSensor.cxx src/sensor/LMSensor.cxx
src/pwm/PWMControl.cxx src/pwm/PWMControl.cxx
src/pwm/PWMControlFacade.cxx src/pwm/PWMControlFacade.cxx
@@ -30,7 +44,8 @@ add_executable(${PROJECT_NAME}
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 20) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 20)
target_include_directories(${PROJECT_NAME} PUBLIC include /opt/cuda) target_include_directories(${PROJECT_NAME} PUBLIC include /opt/cuda)
target_link_libraries(${PROJECT_NAME} PUBLIC sensors nvidia-ml nlohmann_json::nlohmann_json tbb ${Boost_LIBRARIES})
target_link_libraries(${PROJECT_NAME} PUBLIC sensors nlohmann_json::nlohmann_json tbb ${Boost_LIBRARIES} ${ADDITIONAL_LIBS})
install(TARGETS ${PROJECT_NAME} DESTINATION usr/local/bin) install(TARGETS ${PROJECT_NAME} DESTINATION usr/local/bin)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/unit/fantasize.service DESTINATION usr/lib/systemd/system) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/unit/fantasize.service DESTINATION usr/lib/systemd/system)

View File

@@ -4,6 +4,8 @@
#include <chrono> #include <chrono>
#include <memory> #include <memory>
#include <boost/json/object.hpp>
#include <fan/Fan.h> #include <fan/Fan.h>
#include <pwm/PWMControl.h> #include <pwm/PWMControl.h>
#include <sensor/Sensor.h> #include <sensor/Sensor.h>

View File

@@ -1,6 +1,7 @@
#ifndef PWMCONTROL_H_ #ifndef PWMCONTROL_H_
#define PWMCONTROL_H_ #define PWMCONTROL_H_
#include <boost/json/object.hpp>
#include <string> #include <string>
#include <Printable.h> #include <Printable.h>

View File

@@ -1,10 +1,9 @@
#include <boost/log/attributes/named_scope.hpp>
#include <iostream>
#include <boost/log/trivial.hpp>
#include <fan/FanCurve.h> #include <fan/FanCurve.h>
#include <boost/log/attributes/named_scope.hpp>
#include <boost/log/trivial.hpp>
#include <sstream>
using namespace std; using namespace std;
FanCurve::FanCurve(std::vector<FanStep> steps, FanCurve::FanCurve(std::vector<FanStep> steps,

View File

@@ -20,7 +20,7 @@
#include <App.h> #include <App.h>
#define PROJECT_VERSION "v0.1.8" #define PROJECT_VERSION "v0.1.6"
namespace po = boost::program_options; namespace po = boost::program_options;
namespace logging = boost::log; namespace logging = boost::log;

View File

@@ -1,7 +1,10 @@
#include <include/nvml.h> #ifdef HAVE_NVML
#include <include/nvml.h>
#include <sensor/NvidiaSensor.h> #include <sensor/NvidiaSensor.h>
#include <boost/json/object.hpp>
using namespace std; using namespace std;
NvidiaSensor::NvidiaSensor() { nvmlInit_v2(); } NvidiaSensor::NvidiaSensor() { nvmlInit_v2(); }
@@ -24,3 +27,5 @@ json NvidiaSensor::toJson() const {
json obj = {"NvidiaSensor", toString()}; json obj = {"NvidiaSensor", toString()};
return obj; return obj;
} }
#endif

View File

@@ -3,20 +3,26 @@
using namespace std; using namespace std;
SensorManager::SensorManager() SensorManager::SensorManager()
: mLMSensorsFacade(make_unique<LMSensorsFacade>()), : mLMSensorsFacade(make_unique<LMSensorsFacade>())
mGPUSensorsFacade(make_unique<GPUSensorsFacade>()) {} , mGPUSensorsFacade(make_unique<GPUSensorsFacade>())
{
vector<shared_ptr<Sensor>> SensorManager::TemperatureSensors() {
vector<shared_ptr<Sensor>> tempSensors;
tempSensors = mLMSensorsFacade->TemperatureSensors();
auto gpuSensors = mGPUSensorsFacade->TemperatureSensors();
tempSensors.insert(tempSensors.end(), gpuSensors.begin(), gpuSensors.end());
return tempSensors;
} }
vector<shared_ptr<Sensor>> SensorManager::RPMSensors() { vector<shared_ptr<Sensor>> SensorManager::TemperatureSensors()
return mLMSensorsFacade->RPMSensors(); {
vector<shared_ptr<Sensor>> tempSensors;
tempSensors = mLMSensorsFacade->TemperatureSensors();
#ifdef HAVE_NVML
auto gpuSensors = mGPUSensorsFacade->TemperatureSensors();
tempSensors.insert(tempSensors.end(), gpuSensors.begin(), gpuSensors.end());
#endif
return tempSensors;
}
vector<shared_ptr<Sensor>> SensorManager::RPMSensors()
{
return mLMSensorsFacade->RPMSensors();
} }

View File

@@ -7,4 +7,4 @@ ExecStart=/usr/local/bin/fantasize
Restart=always Restart=always
[Install] [Install]
WantedBy=graphical.target WantedBy=multi-user.target