beautiful: merge awful.beautiful, stop registering system
[awesome.git] / CMakeLists.txt
blobc73b5fbb8181609259e32e599e9894e30f7d696c
1 cmake_minimum_required(VERSION 2.6.0)
2 set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS  TRUE)
4 if(COMMAND cmake_policy)
5     cmake_policy(VERSION 2.6)
6 endif()
8 set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
9 set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})
11 if(NOT EXISTS ${SOURCE_DIR}/awesomeConfig.cmake)
12     message(FATAL_ERROR "Please provide awesomeConfig.cmake")
13 endif()
15 include(awesomeConfig.cmake)
17 include_directories(
18     ${SOURCE_DIR}
19     ${BUILD_DIR}
20     ${BUILD_DIR}/common
21     ${AWESOME_COMMON_REQUIRED_INCLUDE_DIRS}
22     ${AWESOME_REQUIRED_INCLUDE_DIRS}
23     ${AWESOME_OPTIONAL_INCLUDE_DIRS})
25 file(GLOB_RECURSE AWE_LUA_FILES ${BUILD_DIR}/lib/*.lua)
27 set(AWE_CONF_FILE_DEFAULT ${BUILD_DIR}/awesomerc.lua)
28 set(AWE_CONF_FILE rc.lua)
30 set(AWE_ICON_DIR ${SOURCE_DIR}/icons)
31 set(AWE_THEMES_DIR ${SOURCE_DIR}/themes)
33 set(AWE_DOC_FILES
34     ${SOURCE_DIR}/AUTHORS
35     ${SOURCE_DIR}/BUGS
36     ${SOURCE_DIR}/README
37     ${SOURCE_DIR}/LICENSE)
39 set(AWE_SRCS
40     ${SOURCE_DIR}/awesome.c
41     ${SOURCE_DIR}/client.c
42     ${SOURCE_DIR}/cnode.c
43     ${SOURCE_DIR}/dbus.c
44     ${SOURCE_DIR}/event.c
45     ${SOURCE_DIR}/property.c
46     ${SOURCE_DIR}/ewmh.c
47     ${SOURCE_DIR}/keybinding.c
48     ${SOURCE_DIR}/keygrabber.c
49     ${SOURCE_DIR}/layout.c
50     ${SOURCE_DIR}/luaa.c
51     ${SOURCE_DIR}/hooks.c
52     ${SOURCE_DIR}/mouse.c
53     ${SOURCE_DIR}/screen.c
54     ${SOURCE_DIR}/stack.c
55     ${SOURCE_DIR}/statusbar.c
56     ${SOURCE_DIR}/wibox.c
57     ${SOURCE_DIR}/systray.c
58     ${SOURCE_DIR}/tag.c
59     ${SOURCE_DIR}/titlebar.c
60     ${SOURCE_DIR}/widget.c
61     ${SOURCE_DIR}/window.c
62     ${SOURCE_DIR}/image.c
63     ${SOURCE_DIR}/draw.c
64     ${SOURCE_DIR}/swindow.c
65     ${SOURCE_DIR}/common/buffer.c
66     ${SOURCE_DIR}/common/atoms.c
67     ${SOURCE_DIR}/common/markup.c
68     ${SOURCE_DIR}/common/socket.c
69     ${SOURCE_DIR}/common/util.c
70     ${SOURCE_DIR}/common/version.c
71     ${SOURCE_DIR}/common/xembed.c
72     ${SOURCE_DIR}/common/xutil.c
73     ${SOURCE_DIR}/layouts/fibonacci.c
74     ${SOURCE_DIR}/layouts/floating.c
75     ${SOURCE_DIR}/layouts/magnifier.c
76     ${SOURCE_DIR}/layouts/fair.c
77     ${SOURCE_DIR}/layouts/max.c
78     ${SOURCE_DIR}/layouts/tile.c
79     ${SOURCE_DIR}/widgets/graph.c
80     ${SOURCE_DIR}/widgets/progressbar.c
81     ${SOURCE_DIR}/widgets/textbox.c
82     ${SOURCE_DIR}/widgets/systray.c
83     ${SOURCE_DIR}/widgets/imagebox.c)
85 set(AWE_CLIENT_SRCS
86     ${SOURCE_DIR}/awesome-client.c
87     ${SOURCE_DIR}/common/socket.c
88     ${SOURCE_DIR}/common/util.c
89     ${SOURCE_DIR}/common/version.c)
91 set(AWE_MAN_SRCS
92     ${SOURCE_DIR}/awesome.1.txt
93     ${SOURCE_DIR}/awesome-client.1.txt
94     ${SOURCE_DIR}/awesomerc.5.txt)
96 add_executable(${PROJECT_AWE_NAME}
97     ${AWE_SRCS}
98     ${BUILD_DIR}/common/tokenize.c)
100 add_executable(${PROJECT_AWECLIENT_NAME}
101     ${AWE_CLIENT_SRCS}
102     ${BUILD_DIR}/common/tokenize.c)
104 set_target_properties(${PROJECT_AWE_NAME}
105     PROPERTIES
106     LINK_FLAGS -export-dynamic)
108 target_link_libraries(${PROJECT_AWE_NAME}
109     ${AWESOME_COMMON_REQUIRED_LIBRARIES}
110     ${AWESOME_REQUIRED_LIBRARIES}
111     ${AWESOME_OPTIONAL_LIBRARIES})
113 target_link_libraries(${PROJECT_AWECLIENT_NAME}
114     ${AWESOME_COMMON_REQUIRED_LIBRARIES}
115     ${AWESOMECLIENT_LIBRARIES})
117 # {{{ Generated sources
118 file(GLOB LAYOUTGEN_DEPS ${SOURCE_DIR}/layouts/*.h)
119 add_custom_command(
120     COMMAND ${SOURCE_DIR}/build-utils/layoutgen.sh
121     ARGS    > ${BUILD_DIR}/layoutgen.h
122     OUTPUT  ${BUILD_DIR}/layoutgen.h
123     WORKING_DIRECTORY ${SOURCE_DIR}
124     DEPENDS ${LAYOUTGEN_DEPS}
125     COMMENT "Generating layoutgen.h"
126     VERBATIM)
128 add_custom_command(
129     COMMAND ${SOURCE_DIR}/build-utils/widgetgen.sh
130     ARGS    > ${BUILD_DIR}/widgetgen.h
131     OUTPUT  ${BUILD_DIR}/widgetgen.h
132     WORKING_DIRECTORY ${SOURCE_DIR}
133     DEPENDS ${SOURCE_DIR}/widget.h
134     COMMENT "Generating widgetgen.h"
135     VERBATIM)
137 # atoms
138 file(MAKE_DIRECTORY ${BUILD_DIR}/common)
139 add_custom_command(
140     COMMAND ${SOURCE_DIR}/build-utils/atoms-ext.sh ${SOURCE_DIR}/common/atoms.list
141     ARGS    > ${BUILD_DIR}/common/atoms-extern.h
142     OUTPUT  ${BUILD_DIR}/common/atoms-extern.h
143     WORKING_DIRECTORY ${SOURCE_DIR}
144     DEPENDS ${SOURCE_DIR}/common/atoms.list
145     COMMENT "Generating atoms-extern.h"
146     VERBATIM)
148 add_custom_command(
149     COMMAND ${SOURCE_DIR}/build-utils/atoms-int.sh ${SOURCE_DIR}/common/atoms.list
150     ARGS    > ${BUILD_DIR}/common/atoms-intern.h
151     OUTPUT  ${BUILD_DIR}/common/atoms-intern.h
152     WORKING_DIRECTORY ${SOURCE_DIR}
153     DEPENDS ${SOURCE_DIR}/common/atoms.list
154     COMMENT "Generating atoms-intern.h"
155     VERBATIM)
157 # gperf
158 add_custom_command(
159     COMMAND ${SOURCE_DIR}/build-utils/gperf.sh
160     ARGS    ${SOURCE_DIR}/common/tokenize.gperf
161             ${BUILD_DIR}/common/tokenize.h
162     OUTPUT  ${BUILD_DIR}/common/tokenize.h
163     DEPENDS ${SOURCE_DIR}/common/tokenize.gperf
164             ${SOURCE_DIR}/build-utils/gperf.sh
165     COMMENT "Generating common/tokenize.h")
167 add_custom_command(
168     COMMAND ${SOURCE_DIR}/build-utils/gperf.sh
169     ARGS    ${SOURCE_DIR}/common/tokenize.gperf
170             ${BUILD_DIR}/common/tokenize.c
171     OUTPUT  ${BUILD_DIR}/common/tokenize.c
172     DEPENDS ${SOURCE_DIR}/common/tokenize.gperf
173             ${SOURCE_DIR}/build-utils/gperf.sh
174     COMMENT "Generating common/tokenize.c")
176 add_custom_target(generated_sources
177     DEPENDS ${BUILD_DIR}/widgetgen.h
178             ${BUILD_DIR}/layoutgen.h
179             ${BUILD_DIR}/common/atoms-intern.h
180             ${BUILD_DIR}/common/atoms-extern.h
181             ${BUILD_DIR}/common/tokenize.c
182             ${BUILD_DIR}/common/tokenize.h)
184 # Default theme directory
185 file(MAKE_DIRECTORY ${BUILD_DIR}/themes/default)
186 file(MAKE_DIRECTORY ${BUILD_DIR}/themes/sky)
187 add_dependencies(${PROJECT_AWE_NAME} generated_sources)
188 add_dependencies(${PROJECT_AWECLIENT_NAME} generated_sources)
189 # }}}
191 # {{{ Version stamp
192 if(BUILD_FROM_GIT)
193     add_custom_target(version_stamp ALL
194         COMMAND ${SOURCE_DIR}/build-utils/git-version-stamp.sh
195                 ${VERSION_STAMP_FILE}
196                 ${BUILD_DIR}/awesome-version-internal.h
197         WORKING_DIRECTORY ${SOURCE_DIR})
199     add_dependencies(${PROJECT_AWE_NAME} version_stamp)
200     add_dependencies(${PROJECT_AWECLIENT_NAME} version_stamp)
201 endif()
202 # }}}
204 # {{{ Manpages
205 if(GENERATE_MANPAGES)
206     foreach(txtfile ${AWE_MAN_SRCS})
207         string(REGEX REPLACE ".txt\$" ".xml" xmlfile ${txtfile})
208         string(REPLACE ${SOURCE_DIR}
209                        ${BUILD_DIR} xmlfile ${xmlfile})
210         string(REGEX REPLACE ".xml\$" ".gz" gzfile ${xmlfile})
211         string(REGEX REPLACE ".gz\$" "" manfile ${gzfile})
213         add_custom_command(
214             COMMAND ${CAT_EXECUTABLE} ${txtfile}
215                     | ${ASCIIDOC_EXECUTABLE} -d manpage -b docbook -o ${xmlfile} -
216             WORKING_DIRECTORY ${BUILD_DIR}
217             OUTPUT  ${xmlfile}
218             DEPENDS ${txtfile}
219             VERBATIM)
220         add_custom_command(
221             COMMAND ${XMLTO_EXECUTABLE} man ${xmlfile}
222             OUTPUT  ${manfile}
223             DEPENDS ${xmlfile})
224         add_custom_command(
225             COMMAND ${CAT_EXECUTABLE} ${manfile}
226                     | ${GZIP_EXECUTABLE}
227                     > ${gzfile}
228             OUTPUT  ${gzfile}
229             DEPENDS ${manfile}
230             VERBATIM)
232         set(MAN_FILES ${MAN_FILES} ${gzfile})
234         # figure out in what section to install to from filename
235         string(REGEX REPLACE "^.*\\.([0-9])\\.gz\$" "\\1" section ${gzfile})
236         set(AWE_MAN${section}_FILES ${AWE_MAN${section}_FILES} ${gzfile})
237     endforeach()
239     add_custom_target(man ALL DEPENDS ${MAN_FILES})
240 endif()
241 # }}}
243 # {{{ Doxygen
244 if(DOXYGEN_EXECUTABLE)
245     add_custom_target(doc
246         COMMAND ${DOXYGEN_EXECUTABLE} awesome.doxygen
247         WORKING_DIRECTORY ${BUILD_DIR})
248 endif()
249 # }}}
251 # {{{ Lua API Documentation
252 if(GENERATE_LUADOC)
254     set(capi_lua ${BUILD_DIR}/lib/capi.lua)
256     if(NOT BUILD_DIR STREQUAL SOURCE_DIR)
257         file(MAKE_DIRECTORY ${BUILD_DIR}/lib)
258     endif()
260     # {{{ setup a command for ${capi_lua}
261     macro(a_file_match infile regex result_var)
262         file(STRINGS ${infile} match REGEX ${regex} LIMIT_COUNT 1)
263         if(match)
264             set(${result_var} TRUE)
265         else()
266             set(${result_var} FALSE)
267         endif()
268     endmacro()
270     set(luadoc_c_srcs "")
272     # find .c files exporting lua functions
273     foreach(cfile ${AWE_SRCS})
274         a_file_match(${cfile} "const struct luaL_reg" result)
275         if(result)
276             set(luadoc_c_srcs ${luadoc_c_srcs} ${cfile})
277         else()
278             a_file_match(${cfile} "luaA_.*_index" result)
279             if(result)
280                 set(luadoc_c_srcs ${luadoc_c_srcs} ${cfile})
281         endif()
282         endif()
283     endforeach()
285     # create fake lua source file to process by luadoc
286     add_custom_command(
287         COMMAND ${CAT_EXECUTABLE} ${luadoc_c_srcs}
288                 | ${LUA_EXECUTABLE} ${SOURCE_DIR}/build-utils/fake-lua-src.lua
289                 > ${capi_lua}
290         OUTPUT  ${capi_lua}
291         DEPENDS ${luadoc_c_srcs}
292         COMMENT "Generating fake lua source."
293         VERBATIM)
294     # }}}
296     # Generate documentation of lib//0lua
297     file(GLOB_RECURSE lua_lib_files ${BUILD_DIR}/lib/*.lua)
298     foreach(filename ${lua_lib_files})
299         file(RELATIVE_PATH filename ${BUILD_DIR}/lib ${filename})
300         set(luadoc_srcs ${luadoc_srcs} ${filename})
301     endforeach()
303     add_custom_target(luadoc ALL
304         COMMAND ${LUADOC_EXECUTABLE} ${luadoc_srcs} -d ${BUILD_DIR}/luadoc
305         WORKING_DIRECTORY ${BUILD_DIR}/lib
306         DEPENDS ${AWE_LUA_FILES} ${capi_lua})
307 endif()
308 # }}}
310 # {{{ Dist tarball
311 if(BUILD_FROM_GIT)
312     add_custom_target(dist
313         COMMAND ${SOURCE_DIR}/build-utils/dist.sh ${VERSION}
314         WORKING_DIRECTORY ${SOURCE_DIR})
315 endif()
316 # }}}
318 # {{{ Installation
319 install(TARGETS ${PROJECT_AWE_NAME} ${PROJECT_AWECLIENT_NAME} RUNTIME DESTINATION bin)
320 install(FILES "utils/awsetbg" DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
321 install(DIRECTORY ${BUILD_DIR}/lib DESTINATION ${AWESOME_DATA_PATH})
322 install(FILES ${AWE_CONF_FILE_DEFAULT} DESTINATION ${AWESOME_SYSCONFDIR}
323         RENAME ${AWE_CONF_FILE})
324 if(GENERATE_MANPAGES)
325     install(FILES ${AWE_MAN1_FILES} DESTINATION ${AWESOME_MAN_PATH}/man1)
326     install(FILES ${AWE_MAN5_FILES} DESTINATION ${AWESOME_MAN_PATH}/man5)
327 endif()
328 install(DIRECTORY ${AWE_ICON_DIR} DESTINATION ${AWESOME_DATA_PATH})
329 install(DIRECTORY ${BUILD_DIR}/themes DESTINATION ${AWESOME_DATA_PATH})
330 install(DIRECTORY ${SOURCE_DIR}/themes DESTINATION ${AWESOME_DATA_PATH}
331     PATTERN "*.in" EXCLUDE)
332 install(FILES ${AWE_DOC_FILES} DESTINATION ${AWESOME_DOC_PATH})
333 install(FILES "awesome.desktop" DESTINATION ${AWESOME_XSESSION_PATH})
334 if(GENERATE_LUADOC)
335     install(DIRECTORY ${BUILD_DIR}/luadoc DESTINATION ${AWESOME_DOC_PATH})
336 endif()
337 # }}}
339 # vim: filetype=cmake:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80