-
Notifications
You must be signed in to change notification settings - Fork 12
/
CMakeLists.txt
134 lines (110 loc) · 5.04 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
cmake_minimum_required (VERSION 3.1.3)
project (luastatus C)
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE Release)
endif ()
set (CMAKE_C_STANDARD 99)
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wpedantic -Wall -Wextra")
endif ()
#------------------------------------------------------------------------------
find_package (PkgConfig REQUIRED)
if (WITH_LUA_LIBRARY)
pkg_search_module (LUA REQUIRED "${WITH_LUA_LIBRARY}")
else ()
pkg_search_module (LUA REQUIRED
lua54 lua-5.4 lua5.4
lua53 lua-5.3 lua5.3
lua52 lua-5.2 lua5.2
lua51 lua-5.1 lua5.1
luajit
lua)
endif ()
function (luastatus_target_compile_with target var)
target_include_directories (${target} SYSTEM PUBLIC
${${var}_INCLUDE_DIRS})
target_compile_options (${target} PUBLIC
${${var}_CFLAGS_OTHER})
endfunction ()
function (luastatus_target_build_with target var)
luastatus_target_compile_with ("${target}" "${var}")
target_link_libraries (${target} PUBLIC ${${var}_LIBRARIES})
endfunction ()
#------------------------------------------------------------------------------
include (GNUInstallDirs)
set (BARLIBS_DIR "${CMAKE_INSTALL_FULL_LIBDIR}/luastatus/barlibs")
set (PLUGINS_DIR "${CMAKE_INSTALL_FULL_LIBDIR}/luastatus/plugins")
set (LUA_PLUGINS_DIR "${CMAKE_INSTALL_FULL_DATAROOTDIR}/luastatus/plugins")
function (luastatus_add_barlib_or_plugin destdir name)
set (sources ${ARGV})
list (REMOVE_AT sources 0 1)
add_library ("${name}" MODULE ${sources})
set_target_properties ("${name}" PROPERTIES PREFIX "")
if (destdir)
install (TARGETS "${name}" DESTINATION "${destdir}")
endif ()
endfunction ()
function (luastatus_add_barlib)
luastatus_add_barlib_or_plugin ("${BARLIBS_DIR}" ${ARGV})
endfunction ()
function (luastatus_add_plugin)
luastatus_add_barlib_or_plugin ("${PLUGINS_DIR}" ${ARGV})
endfunction ()
function (luastatus_add_barlib_noinstall)
luastatus_add_barlib_or_plugin ("" ${ARGV})
endfunction ()
function (luastatus_add_plugin_noinstall)
luastatus_add_barlib_or_plugin ("" ${ARGV})
endfunction ()
option (BUILD_DOCS "build man pages" ON)
function (luastatus_add_man_page src basename section)
if (NOT BUILD_DOCS)
return ()
endif ()
set (dest "${basename}.${section}")
add_custom_command (
OUTPUT "${dest}"
COMMAND "${PROJECT_SOURCE_DIR}/generate-man.sh" ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${src}" "${dest}"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
MAIN_DEPENDENCY "${src}"
VERBATIM)
add_custom_target ("man${section}-${basename}" ALL DEPENDS "${dest}")
install (
FILES "${CMAKE_CURRENT_BINARY_DIR}/${dest}"
DESTINATION "${CMAKE_INSTALL_MANDIR}/man${section}")
endfunction ()
#------------------------------------------------------------------------------
add_subdirectory (libls)
add_subdirectory (libmoonvisit)
add_subdirectory (luastatus)
#------------------------------------------------------------------------------
macro (DEF_OPT optname subdir defvalue)
option (${optname} "build ${subdir}" ${defvalue})
if (${optname})
add_subdirectory (${subdir})
endif ()
endmacro ()
DEF_OPT (BUILD_BARLIB_DWM "barlibs/dwm" ON)
DEF_OPT (BUILD_BARLIB_I3 "barlibs/i3" ON)
DEF_OPT (BUILD_BARLIB_LEMONBAR "barlibs/lemonbar" ON)
DEF_OPT (BUILD_BARLIB_STDOUT "barlibs/stdout" ON)
DEF_OPT (BUILD_PLUGIN_ALSA "plugins/alsa" ON)
DEF_OPT (BUILD_PLUGIN_BACKLIGHT_LINUX "plugins/backlight-linux" ON)
DEF_OPT (BUILD_PLUGIN_BATTERY_LINUX "plugins/battery-linux" ON)
DEF_OPT (BUILD_PLUGIN_CPU_USAGE_LINUX "plugins/cpu-usage-linux" ON)
DEF_OPT (BUILD_PLUGIN_DBUS "plugins/dbus" ON)
DEF_OPT (BUILD_PLUGIN_FILE_CONTENTS_LINUX "plugins/file-contents-linux" ON)
DEF_OPT (BUILD_PLUGIN_FS "plugins/fs" ON)
DEF_OPT (BUILD_PLUGIN_IMAP "plugins/imap" ON)
DEF_OPT (BUILD_PLUGIN_INOTIFY "plugins/inotify" ON)
DEF_OPT (BUILD_PLUGIN_MEM_USAGE_LINUX "plugins/mem-usage-linux" ON)
DEF_OPT (BUILD_PLUGIN_MPD "plugins/mpd" ON)
DEF_OPT (BUILD_PLUGIN_NETWORK_LINUX "plugins/network-linux" ON)
DEF_OPT (BUILD_PLUGIN_PIPE "plugins/pipe" ON)
DEF_OPT (BUILD_PLUGIN_PULSE "plugins/pulse" OFF)
DEF_OPT (BUILD_PLUGIN_TIMER "plugins/timer" ON)
DEF_OPT (BUILD_PLUGIN_UDEV "plugins/udev" ON)
DEF_OPT (BUILD_PLUGIN_UNIXSOCK "plugins/unixsock" OFF)
DEF_OPT (BUILD_PLUGIN_XKB "plugins/xkb" ON)
DEF_OPT (BUILD_PLUGIN_XTITLE "plugins/xtitle" ON)
DEF_OPT (BUILD_TESTS "tests" OFF)