forked from dzhu/keytap
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
48 lines (40 loc) · 1.24 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
cmake_minimum_required(VERSION 3.1.0)
project(sdiol)
set(sources
config.c
devices.c
names.c
networking.c
resolver.c
sdiol.c
server.c
time_util.c
permissions.c
key_action.c
)
add_executable(sdiol ${sources})
# lua dependency
find_path(LUA_INCLUDE NAMES lua.h PATH_SUFFIXES lua lua5.3)
find_library(LUA_LIBRARY NAMES lua lua5.3)
# systemd dependency
find_path(SYSTEMD_INCLUDE NAMES systemd/sd-daemon.h)
find_library(SYSTEMD_LIBRARY NAMES systemd)
target_include_directories(sdiol PRIVATE "${LUA_INCLUDE}" "${SYSTEMD_INCLUDE}")
target_link_libraries(sdiol "${LUA_LIBRARY}" "${SYSTEMD_LIBRARY}")
# complier flags
target_compile_options(sdiol PRIVATE -Wall -Wno-unused-result -Wno-stringop-truncation)
# enable color output from compilier, unless it is explicitly disabled
if("${COLORIZE_OUTPUT}" STREQUAL "")
set(COLORIZE_OUTPUT "yes")
endif()
if("${COLORIZE_OUTPUT}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdiagnostics-color=always")
endif()
if("${CMAKE_BUILD_TYPE}" STREQUAL "debug")
target_compile_options(sdiol PRIVATE -O2)
else()
target_compile_options(sdiol PRIVATE -g)
endif()
# install files
install(TARGETS sdiol RUNTIME DESTINATION bin)
install(FILES sdiol.service DESTINATION /etc/systemd/system)