-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
64 lines (51 loc) · 1.44 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
cmake_minimum_required(VERSION 3.7)
set(CMAKE_CXX_STANDARD_REQUIRED 11)
project("Raspberry Pi fan control"
VERSION 1.0
LANGUAGES CXX
)
option(INSTALL_SYSTEMD_SERVICE "Whether to install a systemd service to start fanctrl" ON)
add_executable(fanctrl fanctrl.cpp)
find_path(
WIRING_PI_INCLUDE_PATH
"wiringPi.h"
)
if(NOT WIRING_PI_INCLUDE_PATH)
message(ERROR "Couldn't find the WiringPi headers. See the README on how to install WiringPi.")
endif()
target_include_directories(fanctrl
PRIVATE
${WIRING_PI_INCLUDE_PATH}
)
find_library(WIRING_PI_LIBRARY
"wiringPi"
)
if(NOT WIRING_PI_LIBRARY)
message(ERROR "Couln't find the WiringPi library. See the README on how to install WinringPi.")
endif()
target_link_libraries(fanctrl
PRIVATE
${WIRING_PI_LIBRARY}
)
find_package(Threads REQUIRED)
target_link_libraries(fanctrl
PRIVATE
Threads::Threads
)
include(GNUInstallDirs)
install(TARGETS fanctrl
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
)
if(INSTALL_SYSTEMD_SERVICE)
set(FANCTRL_EXECUTABLE "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/fanctrl")
configure_file(fanctrl.service.in ${CMAKE_BINARY_DIR}/fanctrl.service)
install(FILES ${CMAKE_BINARY_DIR}/fanctrl.service
DESTINATION /lib/systemd/system
PERMISSIONS OWNER_READ OWNER_WRITE
GROUP_READ
WORLD_READ
)
endif()