forked from herbstluftwm/herbstluftwm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
335 lines (274 loc) · 9.63 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
# vim: set ts=4 sw=4 et:
cmake_minimum_required(VERSION 3.1)
set(CMAKE_BUILD_TYPE_INIT "Release")
cmake_policy(SET CMP0005 NEW) # Escape preprocessor strings
cmake_policy(SET CMP0010 NEW) # So syntax problems are errors
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 11)
# redirect output
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin CACHE INTERNAL "" FORCE)
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib CACHE INTERNAL "" FORCE)
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR "In-source builds aren't supported. Remove the CMakeCache.txt and run from another directory.")
endif()
project(Herbstluftwm)
# ----------------------------------------------------------------------------
# Options
option(WITH_DOCUMENTATION "Build with documentation" ON)
option(WITH_XINERAMA "Use multi-monitor support" ON)
set(DESTDIR "" CACHE PATH "Root directory, prefix for CMAKE_INSTALL_PREFIX and CMAKE_INSTALL_SYSCONF_PREFIX when set")
set(CMAKE_INSTALL_SYSCONF_PREFIX "/etc" CACHE PATH "Directory to install configuration files")
set(SYSCONFDIR "${DESTDIR}/etc")
set(CONFIGDIR "${SYSCONFDIR}/xdg/herbstluftwm")
if(CMAKE_COMPILER_IS_GNUCC)
set(CMAKE_C_FLAGS "-pedantic -Wall")
set(CMAKE_CXX_FLAGS "-pedantic -Wall -Wno-sign-compare -Wno-narrowing -Wno-deprecated-register")
endif()
# ----------------------------------------------------------------------------
# Find Libraries
include(FindPkgConfig)
pkg_check_modules(GLIB2 REQUIRED glib-2.0)
if(WITH_XINERAMA)
find_package(X11 REQUIRED)
if(NOT X11_Xinerama_FOUND)
set(WITH_XINERAMA OFF)
endif()
endif()
# ----------------------------------------------------------------------------
# Find Vars
# VERSION_GIT
set(VERSION_GIT " (unknown)")
if(EXISTS ${CMAKE_SOURCE_DIR}/.git)
find_package(Git)
if(GIT_FOUND)
execute_process(
COMMAND git rev-parse --short HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE VERSION_GIT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(VERSION_GIT " (${VERSION_GIT})")
endif()
endif()
# VERSION_* from 'version.mk'
file(STRINGS "${CMAKE_SOURCE_DIR}/version.mk" _contents REGEX "^VERSION_.*$")
string(REGEX REPLACE ".*VERSION_MAJOR[ \t]*=[ \t]*([0-9]+).*" "\\1" VERSION_MAJOR "${_contents}")
string(REGEX REPLACE ".*VERSION_MINOR[ \t]*=[ \t]*([0-9]+).*" "\\1" VERSION_MINOR "${_contents}")
string(REGEX REPLACE ".*VERSION_PATCH[ \t]*=[ \t]*([0-9]+).*" "\\1" VERSION_PATCH "${_contents}")
string(REGEX REPLACE ".*VERSION_SUFFIX[ \t]*=[ \t]*\"(.*)\".*" "\\1" VERSION_SUFFIX "${_contents}")
set(SHORTVERSION "${VERSION_MAJOR}\.${VERSION_MINOR}\.${VERSION_PATCH}${VERSION_SUFFIX}")
set(VERSION "${SHORTVERSION}${VERSION_GIT}")
unset(_contents)
# ----------------------------------------------------------------------------
# Program: 'herbstluftwm'
set(SRC
src/clientlist.cpp src/clientlist.h
src/command.cpp src/command.h
src/decoration.cpp src/decoration.h
src/desktopwindow.cpp src/desktopwindow.h
src/ewmh.cpp src/ewmh.h
src/floating.cpp src/floating.h
src/glib-backports.h
src/globals.h
src/hook.cpp src/hook.h
src/ipc-protocol.h
src/ipc-server.cpp src/ipc-server.h
src/key.cpp src/key.h
src/layout.cpp src/layout.h
src/main.cpp
src/monitor.cpp src/monitor.h
src/mouse.cpp src/mouse.h
src/object.cpp src/object.h
src/rules.cpp src/rules.h
src/settings.cpp src/settings.h
src/stack.cpp src/stack.h
src/tag.cpp src/tag.h
src/utils.cpp src/utils.h
src/x11-types.h
src/x11-utils.cpp src/x11-utils.h
)
set(INC_SYS
${X11_X11_INCLUDE_PATH}
${GLIB2_INCLUDE_DIRS}
)
set(DEF
-D_XOPEN_SOURCE=600
-DHERBSTLUFT_VERSION=\"${VERSION}\"
-DHERBSTLUFT_VERSION_MAJOR=\"${VERSION_MAJOR}\"
-DHERBSTLUFT_VERSION_MINOR=\"${VERSION_MINOR}\"
-DHERBSTLUFT_VERSION_PATCH=\"${VERSION_PATCH}\"
-DHERBSTLUFT_GLOBAL_AUTOSTART="${CONFIGDIR}/autostart"
)
set(LIB
${X11_X11_LIB}
# for Xshape
${X11_Xext_LIB}
${GLIB2_LIBRARIES}
)
if(WITH_XINERAMA)
list(APPEND INC_SYS ${X11_Xinerama_INCLUDE_PATH})
list(APPEND DEF -DXINERAMA)
list(APPEND LIB ${X11_Xinerama_LIB})
endif()
add_executable(herbstluftwm ${SRC})
target_include_directories(herbstluftwm SYSTEM PUBLIC ${INC_SYS})
target_compile_definitions(herbstluftwm PUBLIC ${DEF})
target_link_libraries(herbstluftwm ${LIB})
# ----------------------------------------------------------------------------
# Program: 'herbstclient'
set(INC_SYS
${X11_X11_INCLUDE_PATH}
${GLIB2_INCLUDE_DIRS}
)
set(DEF
-D_XOPEN_SOURCE=600
-DHERBSTLUFT_VERSION=\"${VERSION}\"
-DHERBSTLUFT_VERSION_MAJOR=\"${VERSION_MAJOR}\"
-DHERBSTLUFT_VERSION_MINOR=\"${VERSION_MINOR}\"
-DHERBSTLUFT_VERSION_PATCH=\"${VERSION_PATCH}\"
)
set(LIB
${X11_X11_LIB}
${GLIB2_LIBRARIES}
)
set(SRC
ipc-client/client-utils.c ipc-client/client-utils.h
ipc-client/ipc-client.c ipc-client/ipc-client.h
ipc-client/main.c
)
add_executable(herbstclient ${SRC})
target_include_directories(herbstclient SYSTEM PUBLIC ${INC_SYS})
target_compile_definitions(herbstclient PUBLIC ${DEF})
target_link_libraries(herbstclient ${LIB})
# ----------------------------------------------------------------------------
# Install
set(BINDIR ${DESTDIR}${CMAKE_INSTALL_PREFIX}/bin)
set(DATADIR ${DESTDIR}${CMAKE_INSTALL_PREFIX}/share)
set(MANDIR ${DATADIR}/man)
set(DOCDIR ${DATADIR}/doc/herbstluftwm)
set(EXAMPLESDIR ${DOCDIR}/examples)
set(LICENSEDIR ${DOCDIR})
set(XSESSIONSDIR ${DATADIR}/xsessions)
set(ZSHCOMPLETIONDIR ${DATADIR}/zsh/functions/Completion/X)
set(BASHCOMPLETIONDIR ${SYSCONFDIR}/bash_completion.d)
install(
TARGETS
herbstluftwm
herbstclient
DESTINATION
${BINDIR}
)
install(
PROGRAMS
${CMAKE_SOURCE_DIR}/share/dmenu_run_hlwm
DESTINATION
${BINDIR}
)
install(
FILES
${CMAKE_SOURCE_DIR}/BUGS
${CMAKE_SOURCE_DIR}/NEWS
${CMAKE_SOURCE_DIR}/INSTALL
DESTINATION
${DOCDIR}
)
install(
FILES
${CMAKE_SOURCE_DIR}/LICENSE
DESTINATION
${LICENSEDIR}
)
install(
PROGRAMS
${CMAKE_SOURCE_DIR}/share/autostart
${CMAKE_SOURCE_DIR}/share/panel.sh
${CMAKE_SOURCE_DIR}/share/restartpanels.sh
DESTINATION
${CONFIGDIR}
)
install(
FILES
${CMAKE_SOURCE_DIR}/share/herbstclient-completion
DESTINATION
${BASHCOMPLETIONDIR}
)
install(
FILES
${CMAKE_SOURCE_DIR}/share/_herbstclient
DESTINATION
${ZSHCOMPLETIONDIR}
)
install(
FILES
${CMAKE_SOURCE_DIR}/share/herbstluftwm.desktop
DESTINATION
${XSESSIONSDIR}
)
install(
FILES
${CMAKE_SOURCE_DIR}/scripts/README
DESTINATION
${EXAMPLESDIR}
)
install(
PROGRAMS
${CMAKE_SOURCE_DIR}/scripts/dmenu.sh
${CMAKE_SOURCE_DIR}/scripts/dumpbeautify.sh
${CMAKE_SOURCE_DIR}/scripts/exec_on_tag.sh
${CMAKE_SOURCE_DIR}/scripts/execwith.sh
${CMAKE_SOURCE_DIR}/scripts/floatmon.sh
${CMAKE_SOURCE_DIR}/scripts/herbstcommander.sh
${CMAKE_SOURCE_DIR}/scripts/keychain.sh
${CMAKE_SOURCE_DIR}/scripts/lasttag.sh
${CMAKE_SOURCE_DIR}/scripts/layout.sh
${CMAKE_SOURCE_DIR}/scripts/loadstate.sh
${CMAKE_SOURCE_DIR}/scripts/q3terminal.sh
${CMAKE_SOURCE_DIR}/scripts/savestate.sh
${CMAKE_SOURCE_DIR}/scripts/scratchpad.sh
${CMAKE_SOURCE_DIR}/scripts/wselect.sh
DESTINATION
${EXAMPLESDIR}
)
if(WITH_DOCUMENTATION)
find_program(ASCIIDOC_A2X NAMES a2x DOC "Path to AsciiDoc a2x command")
find_program(ASCIIDOC NAMES asciidoc DOC "Path to AsciiDoc command")
function(doc_manpage_gen sourcefile man_nr)
set(sourcefile_target "doc_man_${sourcefile}")
set(src_orig "${CMAKE_SOURCE_DIR}/doc/${sourcefile}.txt")
set(src "${CMAKE_BINARY_DIR}/doc/${sourcefile}.txt")
set(dst "${CMAKE_BINARY_DIR}/doc/${sourcefile}.${man_nr}")
add_custom_target(${sourcefile_target} ALL DEPENDS ${dst})
add_custom_command(
OUTPUT ${dst}
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/doc/"
# asciidoc doesn't support destination directory for manpages
COMMAND ${CMAKE_COMMAND} -E copy ${src_orig} ${src}
COMMAND ${ASCIIDOC_A2X}
-f manpage
-a \"herbstluftwmversion=herbstluftwm ${VERSION}\"
-a \"date=`date +%Y-%m-%d`\"
${src}
DEPENDS ${src_orig}
)
install(FILES ${dst} DESTINATION "${MANDIR}/man${man_nr}")
endfunction()
function(doc_html_gen sourcefile)
set(sourcefile_target "doc_html_${sourcefile}")
set(src "${CMAKE_SOURCE_DIR}/doc/${sourcefile}.txt")
set(dst "${CMAKE_BINARY_DIR}/doc/${sourcefile}.html")
add_custom_target(${sourcefile_target} ALL DEPENDS ${dst})
add_custom_command(
OUTPUT ${dst}
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/doc/"
COMMAND ${ASCIIDOC} -o ${dst} ${src}
DEPENDS ${src}
)
install(FILES ${dst} DESTINATION ${DOCDIR})
endfunction()
doc_manpage_gen(herbstclient 1)
doc_manpage_gen(herbstluftwm 1)
doc_manpage_gen(herbstluftwm-tutorial 7)
doc_html_gen(herbstclient)
doc_html_gen(herbstluftwm)
doc_html_gen(herbstluftwm-tutorial)
endif()