client: fix returned value for non transient windows
[awesome.git] / CMakeLists.txt
blobb45bff1805ce2c78a7aae45a971240ddbbcaf5b5
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}/awsetbg.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 set_target_properties(${PROJECT_AWE_NAME}
106     PROPERTIES
107     LINK_FLAGS -export-dynamic)
109 target_link_libraries(${PROJECT_AWE_NAME}
110     ${AWESOME_COMMON_REQUIRED_LIBRARIES}
111     ${AWESOME_REQUIRED_LIBRARIES}
112     ${AWESOME_OPTIONAL_LIBRARIES})
114 target_link_libraries(${PROJECT_AWECLIENT_NAME}
115     ${AWESOME_COMMON_REQUIRED_LIBRARIES}
116     ${AWESOMECLIENT_LIBRARIES})
118 # {{{ Generated sources
119 file(GLOB LAYOUTGEN_DEPS ${SOURCE_DIR}/layouts/*.h)
120 add_custom_command(
121     COMMAND ${SOURCE_DIR}/build-utils/layoutgen.sh
122     ARGS    > ${BUILD_DIR}/layoutgen.h
123     OUTPUT  ${BUILD_DIR}/layoutgen.h
124     WORKING_DIRECTORY ${SOURCE_DIR}
125     DEPENDS ${LAYOUTGEN_DEPS}
126     COMMENT "Generating layoutgen.h"
127     VERBATIM)
129 add_custom_command(
130     COMMAND ${SOURCE_DIR}/build-utils/widgetgen.sh
131     ARGS    > ${BUILD_DIR}/widgetgen.h
132     OUTPUT  ${BUILD_DIR}/widgetgen.h
133     WORKING_DIRECTORY ${SOURCE_DIR}
134     DEPENDS ${SOURCE_DIR}/widget.h
135     COMMENT "Generating widgetgen.h"
136     VERBATIM)
138 # atoms
139 file(MAKE_DIRECTORY ${BUILD_DIR}/common)
140 add_custom_command(
141     COMMAND ${SOURCE_DIR}/build-utils/atoms-ext.sh ${SOURCE_DIR}/common/atoms.list
142     ARGS    > ${BUILD_DIR}/common/atoms-extern.h
143     OUTPUT  ${BUILD_DIR}/common/atoms-extern.h
144     WORKING_DIRECTORY ${SOURCE_DIR}
145     DEPENDS ${SOURCE_DIR}/common/atoms.list
146     COMMENT "Generating atoms-extern.h"
147     VERBATIM)
149 add_custom_command(
150     COMMAND ${SOURCE_DIR}/build-utils/atoms-int.sh ${SOURCE_DIR}/common/atoms.list
151     ARGS    > ${BUILD_DIR}/common/atoms-intern.h
152     OUTPUT  ${BUILD_DIR}/common/atoms-intern.h
153     WORKING_DIRECTORY ${SOURCE_DIR}
154     DEPENDS ${SOURCE_DIR}/common/atoms.list
155     COMMENT "Generating atoms-intern.h"
156     VERBATIM)
158 # gperf
159 add_custom_command(
160     COMMAND ${SOURCE_DIR}/build-utils/gperf.sh
161     ARGS    ${SOURCE_DIR}/common/tokenize.gperf
162             ${BUILD_DIR}/common/tokenize.h
163     OUTPUT  ${BUILD_DIR}/common/tokenize.h
164     DEPENDS ${SOURCE_DIR}/common/tokenize.gperf
165             ${SOURCE_DIR}/build-utils/gperf.sh
166     COMMENT "Generating common/tokenize.h")
168 add_custom_command(
169     COMMAND ${SOURCE_DIR}/build-utils/gperf.sh
170     ARGS    ${SOURCE_DIR}/common/tokenize.gperf
171             ${BUILD_DIR}/common/tokenize.c
172     OUTPUT  ${BUILD_DIR}/common/tokenize.c
173     DEPENDS ${SOURCE_DIR}/common/tokenize.gperf
174             ${SOURCE_DIR}/build-utils/gperf.sh
175     COMMENT "Generating common/tokenize.c")
177 add_custom_target(generated_sources
178     DEPENDS ${BUILD_DIR}/widgetgen.h
179             ${BUILD_DIR}/layoutgen.h
180             ${BUILD_DIR}/common/atoms-intern.h
181             ${BUILD_DIR}/common/atoms-extern.h
182             ${BUILD_DIR}/common/tokenize.c
183             ${BUILD_DIR}/common/tokenize.h)
185 # Default theme directory
186 file(MAKE_DIRECTORY ${BUILD_DIR}/themes/default)
187 file(MAKE_DIRECTORY ${BUILD_DIR}/themes/sky)
188 add_dependencies(${PROJECT_AWE_NAME} generated_sources)
189 add_dependencies(${PROJECT_AWECLIENT_NAME} generated_sources)
190 # }}}
192 # {{{ Version stamp
193 if(BUILD_FROM_GIT)
194     add_custom_target(version_stamp ALL
195         COMMAND ${SOURCE_DIR}/build-utils/git-version-stamp.sh
196                 ${VERSION_STAMP_FILE}
197                 ${BUILD_DIR}/awesome-version-internal.h
198         WORKING_DIRECTORY ${SOURCE_DIR})
200     add_dependencies(${PROJECT_AWE_NAME} version_stamp)
201     add_dependencies(${PROJECT_AWECLIENT_NAME} version_stamp)
202 endif()
203 # }}}
205 # {{{ Manpages
206 if(GENERATE_MANPAGES)
207     foreach(txtfile ${AWE_MAN_SRCS})
208         string(REGEX REPLACE ".txt\$" ".xml" xmlfile ${txtfile})
209         string(REPLACE ${SOURCE_DIR}
210                        ${BUILD_DIR} xmlfile ${xmlfile})
211         string(REGEX REPLACE ".xml\$" ".gz" gzfile ${xmlfile})
212         string(REGEX REPLACE ".gz\$" "" manfile ${gzfile})
214         add_custom_command(
215             COMMAND ${CAT_EXECUTABLE} ${txtfile}
216                     | ${ASCIIDOC_EXECUTABLE} -d manpage -b docbook -o ${xmlfile} -
217             WORKING_DIRECTORY ${BUILD_DIR}
218             OUTPUT  ${xmlfile}
219             DEPENDS ${txtfile}
220             VERBATIM)
221         add_custom_command(
222             COMMAND ${XMLTO_EXECUTABLE} man ${xmlfile}
223             OUTPUT  ${manfile}
224             DEPENDS ${xmlfile})
225         add_custom_command(
226             COMMAND ${CAT_EXECUTABLE} ${manfile}
227                     | ${GZIP_EXECUTABLE}
228                     > ${gzfile}
229             OUTPUT  ${gzfile}
230             DEPENDS ${manfile}
231             VERBATIM)
233         set(MAN_FILES ${MAN_FILES} ${gzfile})
235         # figure out in what section to install to from filename
236         string(REGEX REPLACE "^.*\\.([0-9])\\.gz\$" "\\1" section ${gzfile})
237         set(AWE_MAN${section}_FILES ${AWE_MAN${section}_FILES} ${gzfile})
238     endforeach()
240     add_custom_target(man ALL DEPENDS ${MAN_FILES})
241 endif()
242 # }}}
244 # {{{ Doxygen
245 if(DOXYGEN_EXECUTABLE)
246     add_custom_target(doc
247         COMMAND ${DOXYGEN_EXECUTABLE} awesome.doxygen
248         WORKING_DIRECTORY ${BUILD_DIR})
249 endif()
250 # }}}
252 # {{{ Lua API Documentation
253 if(GENERATE_LUADOC)
255     set(capi_lua ${BUILD_DIR}/lib/capi.lua)
257     if(NOT BUILD_DIR STREQUAL SOURCE_DIR)
258         file(MAKE_DIRECTORY ${BUILD_DIR}/lib)
259     endif()
261     # {{{ setup a command for ${capi_lua}
262     macro(a_file_match infile regex result_var)
263         file(STRINGS ${infile} match REGEX ${regex} LIMIT_COUNT 1)
264         if(match)
265             set(${result_var} TRUE)
266         else()
267             set(${result_var} FALSE)
268         endif()
269     endmacro()
271     set(luadoc_c_srcs "")
273     # find .c files exporting lua functions
274     foreach(cfile ${AWE_SRCS})
275         a_file_match(${cfile} "const struct luaL_reg" result)
276         if(result)
277             set(luadoc_c_srcs ${luadoc_c_srcs} ${cfile})
278         else()
279             a_file_match(${cfile} "luaA_.*_index" result)
280             if(result)
281                 set(luadoc_c_srcs ${luadoc_c_srcs} ${cfile})
282         endif()
283         endif()
284     endforeach()
286     # create fake lua source file to process by luadoc
287     add_custom_command(
288         COMMAND ${CAT_EXECUTABLE} ${luadoc_c_srcs}
289                 | ${LUA_EXECUTABLE} ${SOURCE_DIR}/build-utils/fake-lua-src.lua
290                 > ${capi_lua}
291         OUTPUT  ${capi_lua}
292         DEPENDS ${luadoc_c_srcs}
293         COMMENT "Generating fake lua source."
294         VERBATIM)
295     # }}}
297     # Generate documentation of lib//0lua
298     file(GLOB_RECURSE lua_lib_files ${BUILD_DIR}/lib/*.lua)
299     foreach(filename ${lua_lib_files})
300         file(RELATIVE_PATH filename ${BUILD_DIR}/lib ${filename})
301         set(luadoc_srcs ${luadoc_srcs} ${filename})
302     endforeach()
304     add_custom_target(luadoc ALL
305         COMMAND ${LUADOC_EXECUTABLE} ${luadoc_srcs} -d ${BUILD_DIR}/luadoc
306         WORKING_DIRECTORY ${BUILD_DIR}/lib
307         DEPENDS ${AWE_LUA_FILES} ${capi_lua})
308 endif()
309 # }}}
311 # {{{ Dist tarball
312 if(BUILD_FROM_GIT)
313     add_custom_target(dist
314         COMMAND ${SOURCE_DIR}/build-utils/dist.sh ${VERSION}
315         WORKING_DIRECTORY ${SOURCE_DIR})
316 endif()
317 # }}}
319 # {{{ Installation
320 install(TARGETS ${PROJECT_AWE_NAME} ${PROJECT_AWECLIENT_NAME} RUNTIME DESTINATION bin)
321 install(FILES "utils/awsetbg" DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
322 install(DIRECTORY ${BUILD_DIR}/lib DESTINATION ${AWESOME_DATA_PATH})
323 install(FILES ${AWE_CONF_FILE_DEFAULT} DESTINATION ${AWESOME_SYSCONFDIR}
324         RENAME ${AWE_CONF_FILE})
325 if(GENERATE_MANPAGES)
326     install(FILES ${AWE_MAN1_FILES} DESTINATION ${AWESOME_MAN_PATH}/man1)
327     install(FILES ${AWE_MAN5_FILES} DESTINATION ${AWESOME_MAN_PATH}/man5)
328 endif()
329 install(DIRECTORY ${AWE_ICON_DIR} DESTINATION ${AWESOME_DATA_PATH})
330 install(DIRECTORY ${BUILD_DIR}/themes DESTINATION ${AWESOME_DATA_PATH})
331 install(DIRECTORY ${SOURCE_DIR}/themes DESTINATION ${AWESOME_DATA_PATH}
332     PATTERN "*.in" EXCLUDE)
333 install(FILES ${AWE_DOC_FILES} DESTINATION ${AWESOME_DOC_PATH})
334 install(FILES "awesome.desktop" DESTINATION ${AWESOME_XSESSION_PATH})
335 if(GENERATE_LUADOC)
336     install(DIRECTORY ${BUILD_DIR}/luadoc DESTINATION ${AWESOME_DOC_PATH})
337 endif()
338 # }}}
340 # vim: filetype=cmake:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80