awful: switch screen focus even, don't care for windows
[awesome.git] / CMakeLists.txt
blob6116af9aced0295a9939a96442eeb25f7003be06
1 cmake_minimum_required(VERSION 2.4.7)
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_REQUIRED_INCLUDE_DIRS}
22     ${AWESOME_OPTIONAL_INCLUDE_DIRS})
24 set(AWE_LUA_FILES
25     ${SOURCE_DIR}/lib/tabulous.lua
26     ${SOURCE_DIR}/lib/beautiful.lua)
27 set(awful_lua ${BUILD_DIR}/lib/awful.lua)
29 set(AWE_CONF_FILE_DEFAULT ${BUILD_DIR}/awesomerc.lua)
30 set(AWE_CONF_FILE rc.lua)
32 set(AWE_ICON_DIR ${SOURCE_DIR}/icons)
33 set(AWE_THEMES_DIR ${SOURCE_DIR}/themes)
35 set(AWE_DOC_FILES
36     ${SOURCE_DIR}/AUTHORS
37     ${SOURCE_DIR}/BUGS
38     ${SOURCE_DIR}/README
39     ${SOURCE_DIR}/LICENSE)
41 set(AWE_SRCS
42     ${SOURCE_DIR}/awesome.c
43     ${SOURCE_DIR}/client.c
44     ${SOURCE_DIR}/cnode.c
45     ${SOURCE_DIR}/dbus.c
46     ${SOURCE_DIR}/event.c
47     ${SOURCE_DIR}/ewmh.c
48     ${SOURCE_DIR}/keybinding.c
49     ${SOURCE_DIR}/keygrabber.c
50     ${SOURCE_DIR}/layout.c
51     ${SOURCE_DIR}/lua.c
52     ${SOURCE_DIR}/mouse.c
53     ${SOURCE_DIR}/placement.c
54     ${SOURCE_DIR}/screen.c
55     ${SOURCE_DIR}/stack.c
56     ${SOURCE_DIR}/statusbar.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}/common/buffer.c
63     ${SOURCE_DIR}/common/atoms.c
64     ${SOURCE_DIR}/common/draw.c
65     ${SOURCE_DIR}/common/markup.c
66     ${SOURCE_DIR}/common/socket.c
67     ${SOURCE_DIR}/common/swindow.c
68     ${SOURCE_DIR}/common/util.c
69     ${SOURCE_DIR}/common/version.c
70     ${SOURCE_DIR}/common/xembed.c
71     ${SOURCE_DIR}/common/xscreen.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/max.c
77     ${SOURCE_DIR}/layouts/tile.c
78     ${SOURCE_DIR}/widgets/graph.c
79     ${SOURCE_DIR}/widgets/progressbar.c
80     ${SOURCE_DIR}/widgets/taglist.c
81     ${SOURCE_DIR}/widgets/tasklist.c
82     ${SOURCE_DIR}/widgets/textbox.c
83     ${SOURCE_DIR}/widgets/systray.c
84     ${SOURCE_DIR}/widgets/appicon.c)
86 set(AWE_CLIENT_SRCS
87     ${SOURCE_DIR}/awesome-client.c
88     ${SOURCE_DIR}/common/socket.c
89     ${SOURCE_DIR}/common/util.c
90     ${SOURCE_DIR}/common/version.c)
92 set(AWE_MAN_SRCS
93     ${SOURCE_DIR}/awesome.1.txt
94     ${SOURCE_DIR}/awesome-client.1.txt
95     ${SOURCE_DIR}/awesomerc.5.txt)
97 add_executable(${PROJECT_AWE_NAME}
98     ${AWE_SRCS}
99     ${BUILD_DIR}/common/tokenize.c)
101 add_executable(${PROJECT_AWECLIENT_NAME}
102     ${AWE_CLIENT_SRCS}
103     ${BUILD_DIR}/common/tokenize.c)
105 target_link_libraries(${PROJECT_AWE_NAME}
106     ${AWESOME_REQUIRED_LIBRARIES}
107     ${AWESOME_OPTIONAL_LIBRARIES})
109 target_link_libraries(${PROJECT_AWECLIENT_NAME}
110     ${AWESOMECLIENT_LIBRARIES})
112 # {{{ Generated sources
113 file(GLOB LAYOUTGEN_DEPS ${SOURCE_DIR}/layouts/*.h)
114 add_custom_command(
115     COMMAND ${SOURCE_DIR}/build-utils/layoutgen.sh
116     ARGS    > ${BUILD_DIR}/layoutgen.h
117     OUTPUT  ${BUILD_DIR}/layoutgen.h
118     WORKING_DIRECTORY ${SOURCE_DIR}
119     DEPENDS ${LAYOUTGEN_DEPS}
120     COMMENT "Generating layoutgen.h"
121     VERBATIM)
123 add_custom_command(
124     COMMAND ${SOURCE_DIR}/build-utils/widgetgen.sh
125     ARGS    > ${BUILD_DIR}/widgetgen.h
126     OUTPUT  ${BUILD_DIR}/widgetgen.h
127     WORKING_DIRECTORY ${SOURCE_DIR}
128     DEPENDS ${SOURCE_DIR}/widget.h
129     COMMENT "Generating widgetgen.h"
130     VERBATIM)
132 # atoms
133 file(MAKE_DIRECTORY ${BUILD_DIR}/common)
134 add_custom_command(
135     COMMAND ${SOURCE_DIR}/build-utils/atoms-ext.sh ${SOURCE_DIR}/common/atoms.list
136     ARGS    > ${BUILD_DIR}/common/atoms-extern.h
137     OUTPUT  ${BUILD_DIR}/common/atoms-extern.h
138     WORKING_DIRECTORY ${SOURCE_DIR}
139     DEPENDS ${SOURCE_DIR}/common/atoms.list
140     COMMENT "Generating atoms-extern.h"
141     VERBATIM)
143 add_custom_command(
144     COMMAND ${SOURCE_DIR}/build-utils/atoms-int.sh ${SOURCE_DIR}/common/atoms.list
145     ARGS    > ${BUILD_DIR}/common/atoms-intern.h
146     OUTPUT  ${BUILD_DIR}/common/atoms-intern.h
147     WORKING_DIRECTORY ${SOURCE_DIR}
148     DEPENDS ${SOURCE_DIR}/common/atoms.list
149     COMMENT "Generating atoms-intern.h"
150     VERBATIM)
152 # gperf
153 add_custom_command(
154     COMMAND ${SOURCE_DIR}/build-utils/gperf.sh
155     ARGS    ${SOURCE_DIR}/common/tokenize.gperf
156             ${BUILD_DIR}/common/tokenize.h
157     OUTPUT  ${BUILD_DIR}/common/tokenize.h
158     DEPENDS ${SOURCE_DIR}/common/tokenize.gperf
159             ${SOURCE_DIR}/build-utils/gperf.sh
160     COMMENT "Generating common/tokenize.h")
162 add_custom_command(
163     COMMAND ${SOURCE_DIR}/build-utils/gperf.sh
164     ARGS    ${SOURCE_DIR}/common/tokenize.gperf
165             ${BUILD_DIR}/common/tokenize.c
166     OUTPUT  ${BUILD_DIR}/common/tokenize.c
167     DEPENDS ${SOURCE_DIR}/common/tokenize.gperf
168             ${SOURCE_DIR}/build-utils/gperf.sh
169     COMMENT "Generating common/tokenize.c")
171 add_custom_target(generated_sources
172     DEPENDS ${BUILD_DIR}/widgetgen.h
173             ${BUILD_DIR}/layoutgen.h
174             ${BUILD_DIR}/common/atoms-intern.h
175             ${BUILD_DIR}/common/atoms-extern.h
176             ${BUILD_DIR}/common/tokenize.c
177             ${BUILD_DIR}/common/tokenize.h)
179 add_dependencies(${PROJECT_AWE_NAME} generated_sources)
180 add_dependencies(${PROJECT_AWECLIENT_NAME} generated_sources)
181 # }}}
183 # {{{ Version stamp
184 if(BUILD_FROM_GIT)
185     add_custom_target(version_stamp ALL
186         COMMAND ${SOURCE_DIR}/build-utils/git-version-stamp.sh
187                 ${VERSION_STAMP_FILE}
188                 ${BUILD_DIR}/awesome-version-internal.h
189         WORKING_DIRECTORY ${SOURCE_DIR})
191     add_dependencies(${PROJECT_AWE_NAME} version_stamp)
192     add_dependencies(${PROJECT_AWECLIENT_NAME} version_stamp)
193 endif()
194 # }}}
196 # {{{ Manpages
197 if(GENERATE_MANPAGES)
198     foreach(txtfile ${AWE_MAN_SRCS})
199         string(REGEX REPLACE ".txt\$" ".xml" xmlfile ${txtfile})
200         string(REPLACE ${SOURCE_DIR}
201                        ${BUILD_DIR} xmlfile ${xmlfile})
202         string(REGEX REPLACE ".xml\$" ".gz" gzfile ${xmlfile})
203         string(REGEX REPLACE ".gz\$" "" manfile ${gzfile})
205         add_custom_command(
206             COMMAND ${CAT_EXECUTABLE} ${txtfile}
207                     | ${ASCIIDOC_EXECUTABLE} -d manpage -b docbook -o ${xmlfile} -
208             WORKING_DIRECTORY ${BUILD_DIR}
209             OUTPUT  ${xmlfile}
210             DEPENDS ${txtfile}
211             VERBATIM)
212         add_custom_command(
213             COMMAND ${XMLTO_EXECUTABLE} man ${xmlfile}
214             OUTPUT  ${manfile}
215             DEPENDS ${xmlfile})
216         add_custom_command(
217             COMMAND ${CAT_EXECUTABLE} ${manfile}
218                     | ${GZIP_EXECUTABLE}
219                     > ${gzfile}
220             OUTPUT  ${gzfile}
221             DEPENDS ${manfile}
222             VERBATIM)
224         set(MAN_FILES ${MAN_FILES} ${gzfile})
226         # figure out in what section to install to from filename
227         string(REGEX REPLACE "^.*\\.([0-9])\\.gz\$" "\\1" section ${gzfile})
228         set(AWE_MAN${section}_FILES ${AWE_MAN${section}_FILES} ${gzfile})
229     endforeach()
231     add_custom_target(man ALL DEPENDS ${MAN_FILES})
232 endif()
233 # }}}
235 # {{{ Doxygen
236 if(DOXYGEN_EXECUTABLE)
237     add_custom_target(doc
238         COMMAND ${DOXYGEN_EXECUTABLE} awesome.doxygen
239         WORKING_DIRECTORY ${BUILD_DIR})
240 endif()
241 # }}}
243 # {{{ Lua API Documentation
244 if(GENERATE_LUADOC)
246     set(capi_lua ${BUILD_DIR}/lib/capi.lua)
248     if(NOT BUILD_DIR STREQUAL SOURCE_DIR)
249         file(MAKE_DIRECTORY ${BUILD_DIR}/lib)
250         # setup symlink so everything is in one directory
251         foreach(lua_file ${AWE_LUA_FILES})
252             execute_process(COMMAND ${LN_EXECUTABLE} -s -f ${lua_file}
253                             WORKING_DIRECTORY ${BUILD_DIR}/lib)
254         endforeach()
255     endif()
257     # {{{ setup a command for ${capi_lua}
258     macro(a_file_match infile regex result_var)
259         if(CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION LESS 6)
260             # cmake < 2.6 doesn't know FILE(STRINGS ...)
261             execute_process(
262                 COMMAND ${GREP_EXECUTABLE} -l ${regex} ${infile}
263                 RESULT_VARIABLE exit_code
264                 OUTPUT_QUIET)
265             if(exit_code EQUAL 0)
266                 set(${result_var} TRUE)
267             else()
268                 set(${result_var} FALSE)
269             endif()
270         else()
271             file(STRINGS ${infile} match REGEX ${regex} LIMIT_COUNT 1)
272             if(match)
273                 set(${result_var} TRUE)
274             else()
275                 set(${result_var} FALSE)
276             endif()
277         endif()
278     endmacro()
280     set(luadoc_c_srcs "")
282     # find .c files exporting lua functions
283     foreach(cfile ${AWE_SRCS})
284         a_file_match(${cfile} "const struct luaL_reg" result)
285         if(result)
286             set(luadoc_c_srcs ${luadoc_c_srcs} ${cfile})
287         else()
288             a_file_match(${cfile} "luaA_.*_index" result)
289             if(result)
290                 set(luadoc_c_srcs ${luadoc_c_srcs} ${cfile})
291         endif()
292         endif()
293     endforeach()
295     # create fake lua source file to process by luadoc
296     add_custom_command(
297         COMMAND ${CAT_EXECUTABLE} ${luadoc_c_srcs}
298                 | ${LUA_EXECUTABLE} ${SOURCE_DIR}/build-utils/fake-lua-src.lua
299                 > ${capi_lua}
300         OUTPUT  ${capi_lua}
301         DEPENDS ${luadoc_c_srcs}
302         COMMENT "Generating fake lua source."
303         VERBATIM)
304     # }}}
306     # dont include full path names in documentation
307     foreach(filename ${AWE_LUA_FILES} ${capi_lua} ${awful_lua})
308         get_filename_component(filename ${filename} NAME)
309         set(luadoc_srcs ${luadoc_srcs} ${filename})
310     endforeach()
312     add_custom_target(luadoc ALL
313         COMMAND ${LUADOC_EXECUTABLE} ${luadoc_srcs} -d ${BUILD_DIR}/luadoc
314         WORKING_DIRECTORY ${BUILD_DIR}/lib
315         DEPENDS ${AWE_LUA_FILES} ${capi_lua} ${awful_lua})
316 endif()
317 # }}}
319 # {{{ Compile Lua libs
320 if(LUAC_EXECUTABLE)
321     foreach(luafile ${AWE_LUA_FILES})
322         string(REGEX REPLACE ".lua\$" ".luac" luacfile ${luafile})
323         string(REPLACE ${SOURCE_DIR} ${BUILD_DIR} luacfile ${luacfile})
325         add_custom_command(
326             COMMAND ${LUAC_EXECUTABLE} -o ${luacfile} ${luafile}
327             OUTPUT ${luacfile}
328             DEPENDS ${luafile})
330         set(AWE_LUAC_FILES ${AWE_LUAC_FILES} ${luacfile})
331     endforeach()
333     # Special case for awful.lua
334     string(REGEX REPLACE ".lua\$" ".luac" luacfile ${awful_lua})
335     add_custom_command(
336         COMMAND ${LUAC_EXECUTABLE} -o ${luacfile} ${awful_lua}
337         OUTPUT ${luacfile}
338         DEPENDS ${awful_lua})
340     set(AWE_LUAC_FILES ${AWE_LUAC_FILES} ${luacfile})
342     if(NOT EXISTS ${BUILD_DIR}/lib)
343         FILE(MAKE_DIRECTORY ${BUILD_DIR}/lib)
344     endif()
346     add_custom_target(compile_lua ALL DEPENDS ${AWE_LUAC_FILES})
347 endif()
348 # }}}
350 # {{{ Dist tarball
351 if(BUILD_FROM_GIT)
352     add_custom_target(dist
353         COMMAND ${SOURCE_DIR}/build-utils/dist.sh ${VERSION}
354         WORKING_DIRECTORY ${SOURCE_DIR})
355 endif()
356 # }}}
358 # {{{ Installation
359 install(TARGETS ${PROJECT_AWE_NAME} ${PROJECT_AWECLIENT_NAME} RUNTIME DESTINATION bin)
360 install(FILES ${AWE_LUA_FILES} ${awful_lua} ${AWE_LUAC_FILES} DESTINATION ${AWESOME_LUA_LIB_PATH})
361 install(FILES ${AWE_CONF_FILE_DEFAULT} DESTINATION ${AWESOME_SYSCONFDIR}
362         RENAME ${AWE_CONF_FILE})
363 if(GENERATE_MANPAGES)
364     install(FILES ${AWE_MAN1_FILES} DESTINATION ${AWESOME_MAN_PATH}/man1)
365     install(FILES ${AWE_MAN5_FILES} DESTINATION ${AWESOME_MAN_PATH}/man5)
366 endif()
367 install(DIRECTORY ${AWE_ICON_DIR} DESTINATION ${AWESOME_DATA_PATH})
368 install(DIRECTORY ${AWE_THEMES_DIR} DESTINATION ${AWESOME_DATA_PATH})
369 install(FILES ${AWE_DOC_FILES} DESTINATION ${AWESOME_DOC_PATH})
370 install(FILES "awesome.desktop" DESTINATION ${AWESOME_XSESSION_PATH})
371 if(GENERATE_LUADOC)
372     install(DIRECTORY ${BUILD_DIR}/luadoc DESTINATION ${AWESOME_DOC_PATH})
373 endif()
374 # }}}
376 # vim: filetype=cmake:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80