client: handle tags assignment in awful (FS#441)
[awesome.git] / CMakeLists.txt
bloba6054922f6a47156f5b118fdb575139c21d20168
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}/key.c
49     ${SOURCE_DIR}/keygrabber.c
50     ${SOURCE_DIR}/mousegrabber.c
51     ${SOURCE_DIR}/layout.c
52     ${SOURCE_DIR}/luaa.c
53     ${SOURCE_DIR}/hooks.c
54     ${SOURCE_DIR}/mouse.c
55     ${SOURCE_DIR}/screen.c
56     ${SOURCE_DIR}/stack.c
57     ${SOURCE_DIR}/selection.c
58     ${SOURCE_DIR}/wibox.c
59     ${SOURCE_DIR}/systray.c
60     ${SOURCE_DIR}/tag.c
61     ${SOURCE_DIR}/titlebar.c
62     ${SOURCE_DIR}/widget.c
63     ${SOURCE_DIR}/window.c
64     ${SOURCE_DIR}/image.c
65     ${SOURCE_DIR}/draw.c
66     ${SOURCE_DIR}/swindow.c
67     ${SOURCE_DIR}/common/buffer.c
68     ${SOURCE_DIR}/common/atoms.c
69     ${SOURCE_DIR}/common/socket.c
70     ${SOURCE_DIR}/common/util.c
71     ${SOURCE_DIR}/common/version.c
72     ${SOURCE_DIR}/common/xembed.c
73     ${SOURCE_DIR}/common/xutil.c
74     ${SOURCE_DIR}/common/xcursor.c
75     ${SOURCE_DIR}/widgets/graph.c
76     ${SOURCE_DIR}/widgets/progressbar.c
77     ${SOURCE_DIR}/widgets/textbox.c
78     ${SOURCE_DIR}/widgets/systray.c
79     ${SOURCE_DIR}/widgets/imagebox.c)
81 set(AWE_CLIENT_SRCS
82     ${SOURCE_DIR}/awesome-client.c
83     ${SOURCE_DIR}/common/socket.c
84     ${SOURCE_DIR}/common/util.c
85     ${SOURCE_DIR}/common/version.c)
87 set(AWE_MAN_SRCS
88     ${SOURCE_DIR}/awesome.1.txt
89     ${SOURCE_DIR}/awsetbg.1.txt
90     ${SOURCE_DIR}/awesome-client.1.txt
91     ${SOURCE_DIR}/awesomerc.5.txt)
93 add_executable(${PROJECT_AWE_NAME}
94     ${AWE_SRCS}
95     ${BUILD_DIR}/common/tokenize.c)
97 add_executable(${PROJECT_AWECLIENT_NAME}
98     ${AWE_CLIENT_SRCS}
99     ${BUILD_DIR}/common/tokenize.c)
101 set_target_properties(${PROJECT_AWE_NAME}
102     PROPERTIES
103     LINK_FLAGS -export-dynamic)
105 target_link_libraries(${PROJECT_AWE_NAME}
106     ${AWESOME_COMMON_REQUIRED_LIBRARIES}
107     ${AWESOME_REQUIRED_LIBRARIES}
108     ${AWESOME_OPTIONAL_LIBRARIES})
110 target_link_libraries(${PROJECT_AWECLIENT_NAME}
111     ${AWESOME_COMMON_REQUIRED_LIBRARIES}
112     ${AWESOMECLIENT_LIBRARIES})
114 # {{{ Generated sources
115 add_custom_command(
116     COMMAND ${SOURCE_DIR}/build-utils/widgetgen.sh
117     ARGS    > ${BUILD_DIR}/widgetgen.h
118     OUTPUT  ${BUILD_DIR}/widgetgen.h
119     WORKING_DIRECTORY ${SOURCE_DIR}
120     DEPENDS ${SOURCE_DIR}/widget.h
121     COMMENT "Generating widgetgen.h"
122     VERBATIM)
124 # atoms
125 file(MAKE_DIRECTORY ${BUILD_DIR}/common)
126 add_custom_command(
127     COMMAND ${SOURCE_DIR}/build-utils/atoms-ext.sh ${SOURCE_DIR}/common/atoms.list
128     ARGS    > ${BUILD_DIR}/common/atoms-extern.h
129     OUTPUT  ${BUILD_DIR}/common/atoms-extern.h
130     WORKING_DIRECTORY ${SOURCE_DIR}
131     DEPENDS ${SOURCE_DIR}/common/atoms.list
132     COMMENT "Generating atoms-extern.h"
133     VERBATIM)
135 add_custom_command(
136     COMMAND ${SOURCE_DIR}/build-utils/atoms-int.sh ${SOURCE_DIR}/common/atoms.list
137     ARGS    > ${BUILD_DIR}/common/atoms-intern.h
138     OUTPUT  ${BUILD_DIR}/common/atoms-intern.h
139     WORKING_DIRECTORY ${SOURCE_DIR}
140     DEPENDS ${SOURCE_DIR}/common/atoms.list
141     COMMENT "Generating atoms-intern.h"
142     VERBATIM)
144 # gperf
145 add_custom_command(
146     COMMAND ${SOURCE_DIR}/build-utils/gperf.sh
147     ARGS    ${SOURCE_DIR}/common/tokenize.gperf
148             ${BUILD_DIR}/common/tokenize.h
149     OUTPUT  ${BUILD_DIR}/common/tokenize.h
150     DEPENDS ${SOURCE_DIR}/common/tokenize.gperf
151             ${SOURCE_DIR}/build-utils/gperf.sh
152     COMMENT "Generating common/tokenize.h")
154 add_custom_command(
155     COMMAND ${SOURCE_DIR}/build-utils/gperf.sh
156     ARGS    ${SOURCE_DIR}/common/tokenize.gperf
157             ${BUILD_DIR}/common/tokenize.c
158     OUTPUT  ${BUILD_DIR}/common/tokenize.c
159     DEPENDS ${SOURCE_DIR}/common/tokenize.gperf
160             ${SOURCE_DIR}/build-utils/gperf.sh
161     COMMENT "Generating common/tokenize.c")
163 add_custom_target(generated_sources
164     DEPENDS ${BUILD_DIR}/widgetgen.h
165             ${BUILD_DIR}/common/atoms-intern.h
166             ${BUILD_DIR}/common/atoms-extern.h
167             ${BUILD_DIR}/common/tokenize.c
168             ${BUILD_DIR}/common/tokenize.h)
170 # Default theme directory
171 file(MAKE_DIRECTORY ${BUILD_DIR}/themes/default)
172 file(MAKE_DIRECTORY ${BUILD_DIR}/themes/sky)
173 add_dependencies(${PROJECT_AWE_NAME} generated_sources)
174 add_dependencies(${PROJECT_AWECLIENT_NAME} generated_sources)
175 # }}}
177 # {{{ Version stamp
178 if(BUILD_FROM_GIT)
179     add_custom_target(version_stamp ALL
180         COMMAND ${SOURCE_DIR}/build-utils/git-version-stamp.sh
181                 ${VERSION_STAMP_FILE}
182                 ${BUILD_DIR}/awesome-version-internal.h
183         WORKING_DIRECTORY ${SOURCE_DIR})
185     add_dependencies(${PROJECT_AWE_NAME} version_stamp)
186     add_dependencies(${PROJECT_AWECLIENT_NAME} version_stamp)
187 endif()
188 # }}}
190 # {{{ Manpages
191 if(GENERATE_MANPAGES)
192     foreach(txtfile ${AWE_MAN_SRCS})
193         string(REGEX REPLACE ".txt\$" ".xml" xmlfile ${txtfile})
194         string(REPLACE ${SOURCE_DIR}
195                        ${BUILD_DIR} xmlfile ${xmlfile})
196         string(REGEX REPLACE ".xml\$" ".gz" gzfile ${xmlfile})
197         string(REGEX REPLACE ".gz\$" "" manfile ${gzfile})
199         add_custom_command(
200             COMMAND ${CAT_EXECUTABLE} ${txtfile}
201                     | ${ASCIIDOC_EXECUTABLE} -d manpage -b docbook -o ${xmlfile} -
202             WORKING_DIRECTORY ${BUILD_DIR}
203             OUTPUT  ${xmlfile}
204             DEPENDS ${txtfile}
205             VERBATIM)
206         add_custom_command(
207             COMMAND ${XMLTO_EXECUTABLE} man ${xmlfile}
208             OUTPUT  ${manfile}
209             DEPENDS ${xmlfile})
210         add_custom_command(
211             COMMAND ${CAT_EXECUTABLE} ${manfile}
212                     | ${GZIP_EXECUTABLE}
213                     > ${gzfile}
214             OUTPUT  ${gzfile}
215             DEPENDS ${manfile}
216             VERBATIM)
218         set(MAN_FILES ${MAN_FILES} ${gzfile})
220         # figure out in what section to install to from filename
221         string(REGEX REPLACE "^.*\\.([0-9])\\.gz\$" "\\1" section ${gzfile})
222         set(AWE_MAN${section}_FILES ${AWE_MAN${section}_FILES} ${gzfile})
223     endforeach()
225     add_custom_target(man ALL DEPENDS ${MAN_FILES})
226 endif()
227 # }}}
229 # {{{ Doxygen
230 if(DOXYGEN_EXECUTABLE)
231     add_custom_target(doc
232         COMMAND ${DOXYGEN_EXECUTABLE} awesome.doxygen
233         WORKING_DIRECTORY ${BUILD_DIR})
234 endif()
235 # }}}
237 # {{{ Lua API Documentation
238 if(GENERATE_LUADOC)
240     set(capi_lua ${BUILD_DIR}/lib/capi.lua)
242     if(NOT BUILD_DIR STREQUAL SOURCE_DIR)
243         file(MAKE_DIRECTORY ${BUILD_DIR}/lib)
244     endif()
246     # {{{ setup a command for ${capi_lua}
247     macro(a_file_match infile regex result_var)
248         file(STRINGS ${infile} match REGEX ${regex} LIMIT_COUNT 1)
249         if(match)
250             set(${result_var} TRUE)
251         else()
252             set(${result_var} FALSE)
253         endif()
254     endmacro()
256     set(luadoc_c_srcs "")
258     # find .c files exporting lua functions
259     foreach(cfile ${AWE_SRCS})
260         a_file_match(${cfile} "const struct luaL_reg" result)
261         if(result)
262             set(luadoc_c_srcs ${luadoc_c_srcs} ${cfile})
263         else()
264             a_file_match(${cfile} "luaA_.*_index" result)
265             if(result)
266                 set(luadoc_c_srcs ${luadoc_c_srcs} ${cfile})
267         endif()
268         endif()
269     endforeach()
271     # create fake lua source file to process by luadoc
272     add_custom_command(
273         COMMAND ${CAT_EXECUTABLE} ${luadoc_c_srcs}
274                 | ${LUA_EXECUTABLE} ${SOURCE_DIR}/build-utils/fake-lua-src.lua
275                 > ${capi_lua}
276         OUTPUT  ${capi_lua}
277         DEPENDS ${luadoc_c_srcs}
278         COMMENT "Generating fake lua source."
279         VERBATIM)
280     # }}}
282     # Generate documentation of lib//0lua
283     file(GLOB_RECURSE lua_lib_files ${BUILD_DIR}/lib/*.lua)
284     foreach(filename ${lua_lib_files})
285         file(RELATIVE_PATH filename ${BUILD_DIR}/lib ${filename})
286         set(luadoc_srcs ${luadoc_srcs} ${filename})
287     endforeach()
289     add_custom_target(luadoc ALL
290         COMMAND ${LUADOC_EXECUTABLE} ${luadoc_srcs} -d ${BUILD_DIR}/luadoc
291         WORKING_DIRECTORY ${BUILD_DIR}/lib
292         DEPENDS ${AWE_LUA_FILES} ${capi_lua})
293 endif()
294 # }}}
296 # {{{ Dist tarball
297 if(BUILD_FROM_GIT)
298     add_custom_target(dist
299         COMMAND ${SOURCE_DIR}/build-utils/dist.sh ${VERSION}
300         WORKING_DIRECTORY ${SOURCE_DIR})
301 endif()
302 # }}}
304 # {{{ Installation
305 install(TARGETS ${PROJECT_AWE_NAME} ${PROJECT_AWECLIENT_NAME} RUNTIME DESTINATION bin)
306 install(FILES "utils/awsetbg" DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
307 install(DIRECTORY ${BUILD_DIR}/lib DESTINATION ${AWESOME_DATA_PATH})
308 install(FILES ${AWE_CONF_FILE_DEFAULT} DESTINATION ${AWESOME_SYSCONFDIR}
309         RENAME ${AWE_CONF_FILE})
310 if(GENERATE_MANPAGES)
311     install(FILES ${AWE_MAN1_FILES} DESTINATION ${AWESOME_MAN_PATH}/man1)
312     install(FILES ${AWE_MAN5_FILES} DESTINATION ${AWESOME_MAN_PATH}/man5)
313 endif()
314 install(DIRECTORY ${AWE_ICON_DIR} DESTINATION ${AWESOME_DATA_PATH})
315 install(DIRECTORY ${BUILD_DIR}/themes DESTINATION ${AWESOME_DATA_PATH})
316 install(DIRECTORY ${SOURCE_DIR}/themes DESTINATION ${AWESOME_DATA_PATH}
317     PATTERN "*.in" EXCLUDE)
318 install(FILES ${AWE_DOC_FILES} DESTINATION ${AWESOME_DOC_PATH})
319 install(FILES "awesome.desktop" DESTINATION ${AWESOME_XSESSION_PATH})
320 if(GENERATE_LUADOC)
321     install(DIRECTORY ${BUILD_DIR}/luadoc DESTINATION ${AWESOME_DOC_PATH})
322 endif()
323 # }}}
325 # vim: filetype=cmake:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80