Skip to content
This repository has been archived by the owner on Sep 8, 2024. It is now read-only.

Commit

Permalink
- Fixed service not warning of requiring root
Browse files Browse the repository at this point in the history
- Removed unnecessary build options
- Added build type message
- Further broke down protobuf type specific definitions

Signed-off-by: Hayden Briese <[email protected]>
  • Loading branch information
hbriese committed Jul 22, 2020
1 parent a4f5473 commit 335617f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 26 deletions.
14 changes: 6 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,24 @@ if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif ()

message("Build type: ${CMAKE_BUILD_TYPE}")

## Release flags
set(OPTIMIZATION_FLAG "-O3")
if (CMAKE_BUILD_TYPE STREQUAL "Release")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${OPTIMIZATION_FLAG}")
endif ()

## Debug flags
option(OPTIMIZE_DEBUG "Optimize debug build - useful for profiling" OFF)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wextra -Wpedantic")
if (OPTIMIZE_DEBUG)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${OPTIMIZATION_FLAG}")
endif ()
endif ()

## Generate protobuf source files
execute_process(COMMAND "./gen_proto.sh" WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
RESULT_VARIABLE GENPROTO_RES OUTPUT_VARIABLE GENPROTO_OUT ERROR_VARIABLE GENPROTO_OUT)
if (${GENPROTO_RES} STREQUAL "0")
message("Generated protobuf files ${GENPROTO_OUT}")
message("Protobuf files generated ${GENPROTO_OUT}")
else ()
message("Failed to generate protobuf files: ${GENPROTO_OUT}")
endif ()
Expand Down Expand Up @@ -82,7 +80,7 @@ include_directories(${SENSORS_INCLUDE_DIR})
set(LIBS ${LIBS} ${SENSORS_LIBRARY})

## NVIDIA Support
option(NVIDIA_SUPPORT "Build with NVIDIA GPU support" ON)
option(NVIDIA_SUPPORT "Support for NVIDIA GPUs" ON)
if (NVIDIA_SUPPORT)
find_package(X11)
find_package(NVCtrl)
Expand Down Expand Up @@ -124,7 +122,7 @@ include_directories(${GRPC_INCLUDE_DIRS})
set(LIBS ${LIBS} ${GRPC_LIBRARIES})

## Google Perf Tools profiling
option(PROFILE "Build debug release with support for CPU and heap profiling - REQUIRES Google Perf Tools" OFF)
option(PROFILE "Support for Google Perf Tools CPU & heap profilers" OFF)
if (PROFILE AND CMAKE_BUILD_TYPE STREQUAL "Debug")
find_package(Profiler REQUIRED)
find_package(TCMalloc REQUIRED)
Expand Down Expand Up @@ -152,7 +150,7 @@ if (CMAKE_INSTALL_BINDIR)
endif ()

## Run lint if debug build
option(LINT "Run linter with debug build" OFF)
option(LINT "Run Clang-Tidy" OFF)
if (CMAKE_BUILD_TYPE STREQUAL "Debug" AND LINT)
set(LINT_CXX_FLAGS "${CMAKE_CXX_FLAGS_DEBUG} -std=c++${CMAKE_CXX_STANDARD}")
set(LINT_CHECKS "*,-clang-diagnostic-unused-command-line-argument,\
Expand Down
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,20 +167,19 @@ https://wiki.archlinux.org/index.php/Running_GUI_applications_as_root
sudo apt install clang cmake lm-sensors libsensors5 libsensors4-dev libboost-system-dev libboost-filesystem-dev libboost-log-dev libpthread-stubs0-dev libpstreams-dev libprotobuf-dev protobuf-compiler libgrpc++-dev protobuf-compiler protobuf-compiler-grpc libxnvctrl-dev libx11-dev

git clone https://github.com/hbriese/fancon.git && cd fancon; mkdir build; cd build
cmake -DCMAKE_BUILD_TYPE=Release -DNVIDIA_SUPPORT=ON .. && make -j && sudo make install
cmake -DNVIDIA_SUPPORT=ON .. && make -j && sudo make install
```

##### Without NVIDIA support:
```bash
sudo apt install clang cmake lm-sensors libsensors5 libsensors4-dev libboost-system-dev libboost-filesystem-dev libboost-log-dev libpthread-stubs0-dev libpstreams-dev libprotobuf-dev protobuf-compiler libgrpc++-dev protobuf-compiler protobuf-compiler-grpc

git clone https://github.com/hbriese/fancon.git && cd fancon; mkdir build; cd build
cmake -DCMAKE_BUILD_TYPE=Release -DNVIDIA_SUPPORT=OFF .. && make -j && sudo make install
cmake -DNVIDIA_SUPPORT=OFF .. && make -j && sudo make install
```

| CMake Option | Default | Description |
|:-----------------|:-------:| :-------------------------------------------------------------------------------------------|
| NVIDIA_SUPPORT | ON | Support for NVIDIA GPUs |
| OPTIMIZE_DEBUG | OFF | Enable compiler optimizations on debug build |
| PROFILE | OFF | Support for Google Perf Tools CPU & heap profilers; only recommended for debug builds |
| LINT | OFF | Run lint checker (Clang-Tidy) |
| CMake Option | Default | Description |
|:-----------------|:-------:| :--------------------------------------------------|
| NVIDIA_SUPPORT | ON | Support for NVIDIA GPUs |
| PROFILE | OFF | Support for Google Perf Tools CPU & heap profilers |
| LINT | OFF | Run Clang-Tidy |
6 changes: 4 additions & 2 deletions proto/DevicesSpec.proto
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ message Fan {
uint64 interval = 7;
bool ignore = 8;

// SYS
// SYS & DELL
string pwm_path = 10;
string rpm_path = 11;
string enable_path = 12;

// SYS
string enable_path = 12;
int32 driver_flag = 13;

// NV
Expand Down
7 changes: 0 additions & 7 deletions src/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,6 @@ bool fc::Client::Test(bool forced) {
}

return true;

// for (auto &t : threads) {
// if (t.joinable())
// t.join();
// }
//
// return true;
}

bool fc::Client::Test(const string &fan_label, bool forced) {
Expand Down
4 changes: 3 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ int main(int argc, char *argv[]) {

// SERVICE
if (args.service) {
if (!is_root())
if (!is_root()) {
LOG(llvl::error) << "Service must be run as root";
return EXIT_FAILURE;
}

fc::Service service(config_path, args.daemon);
service.run();
Expand Down

0 comments on commit 335617f

Please sign in to comment.