awful.rules: tag clients without flicker (FS#664)
[awesome.git] / CMakeLists.txt
blob3cdf6d9991c542695bb50cebeb3971fddb3bf407
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     ${AWESOME_COMMON_REQUIRED_INCLUDE_DIRS}
21     ${AWESOME_REQUIRED_INCLUDE_DIRS}
22     ${AWESOME_OPTIONAL_INCLUDE_DIRS})
24 file(GLOB_RECURSE AWE_LUA_FILES ${BUILD_DIR}/lib/*.lua ${BUILD_DIR}/luadoc/*.lua)
26 set(AWE_CONF_FILE_DEFAULT ${BUILD_DIR}/awesomerc.lua)
27 set(AWE_CONF_FILE rc.lua)
29 set(AWE_ICON_DIR ${SOURCE_DIR}/icons)
30 set(AWE_THEMES_DIR ${SOURCE_DIR}/themes)
32 set(AWE_DOC_FILES
33     ${SOURCE_DIR}/AUTHORS
34     ${SOURCE_DIR}/BUGS
35     ${SOURCE_DIR}/README
36     ${SOURCE_DIR}/LICENSE)
38 set(AWE_SRCS
39     ${SOURCE_DIR}/awesome.c
40     ${SOURCE_DIR}/client.c
41     ${SOURCE_DIR}/strut.c
42     ${SOURCE_DIR}/dbus.c
43     ${SOURCE_DIR}/root.c
44     ${SOURCE_DIR}/event.c
45     ${SOURCE_DIR}/property.c
46     ${SOURCE_DIR}/ewmh.c
47     ${SOURCE_DIR}/key.c
48     ${SOURCE_DIR}/keygrabber.c
49     ${SOURCE_DIR}/mousegrabber.c
50     ${SOURCE_DIR}/banning.c
51     ${SOURCE_DIR}/luaa.c
52     ${SOURCE_DIR}/spawn.c
53     ${SOURCE_DIR}/hooks.c
54     ${SOURCE_DIR}/mouse.c
55     ${SOURCE_DIR}/button.c
56     ${SOURCE_DIR}/screen.c
57     ${SOURCE_DIR}/stack.c
58     ${SOURCE_DIR}/selection.c
59     ${SOURCE_DIR}/wibox.c
60     ${SOURCE_DIR}/systray.c
61     ${SOURCE_DIR}/tag.c
62     ${SOURCE_DIR}/titlebar.c
63     ${SOURCE_DIR}/widget.c
64     ${SOURCE_DIR}/window.c
65     ${SOURCE_DIR}/image.c
66     ${SOURCE_DIR}/draw.c
67     ${SOURCE_DIR}/font.c
68     ${SOURCE_DIR}/color.c
69     ${SOURCE_DIR}/timer.c
70     ${SOURCE_DIR}/common/buffer.c
71     ${SOURCE_DIR}/common/atoms.c
72     ${SOURCE_DIR}/common/util.c
73     ${SOURCE_DIR}/common/version.c
74     ${SOURCE_DIR}/common/xembed.c
75     ${SOURCE_DIR}/common/xutil.c
76     ${SOURCE_DIR}/common/xcursor.c
77     ${SOURCE_DIR}/common/backtrace.c
78     ${SOURCE_DIR}/common/luaobject.c
79     ${SOURCE_DIR}/common/luaclass.c
80     ${SOURCE_DIR}/widgets/graph.c
81     ${SOURCE_DIR}/widgets/progressbar.c
82     ${SOURCE_DIR}/widgets/textbox.c
83     ${SOURCE_DIR}/widgets/systray.c
84     ${SOURCE_DIR}/widgets/imagebox.c)
86 set(AWE_MAN_SRCS
87     ${SOURCE_DIR}/manpages/awesome.1.txt
88     ${SOURCE_DIR}/manpages/awsetbg.1.txt
89     ${SOURCE_DIR}/manpages/awesome-client.1.txt
90     ${SOURCE_DIR}/manpages/awesomerc.5.txt)
92 add_executable(${PROJECT_AWE_NAME}
93     ${AWE_SRCS}
94     ${BUILD_DIR}/common/tokenize.c)
96 set_target_properties(${PROJECT_AWE_NAME}
97     PROPERTIES
98     LINK_FLAGS -export-dynamic)
100 target_link_libraries(${PROJECT_AWE_NAME}
101     ${AWESOME_COMMON_REQUIRED_LIBRARIES}
102     ${AWESOME_REQUIRED_LIBRARIES}
103     ${AWESOME_OPTIONAL_LIBRARIES})
105 # atoms
106 file(MAKE_DIRECTORY ${BUILD_DIR}/common)
107 add_custom_command(
108     COMMAND ${SOURCE_DIR}/build-utils/atoms-ext.sh ${SOURCE_DIR}/common/atoms.list
109     ARGS    > ${BUILD_DIR}/common/atoms-extern.h
110     OUTPUT  ${BUILD_DIR}/common/atoms-extern.h
111     WORKING_DIRECTORY ${SOURCE_DIR}
112     DEPENDS ${SOURCE_DIR}/common/atoms.list
113     COMMENT "Generating atoms-extern.h"
114     VERBATIM)
116 add_custom_command(
117     COMMAND ${SOURCE_DIR}/build-utils/atoms-int.sh ${SOURCE_DIR}/common/atoms.list
118     ARGS    > ${BUILD_DIR}/common/atoms-intern.h
119     OUTPUT  ${BUILD_DIR}/common/atoms-intern.h
120     WORKING_DIRECTORY ${SOURCE_DIR}
121     DEPENDS ${SOURCE_DIR}/common/atoms.list
122     COMMENT "Generating atoms-intern.h"
123     VERBATIM)
125 # gperf
126 add_custom_command(
127     COMMAND ${SOURCE_DIR}/build-utils/gperf.sh
128     ARGS    ${SOURCE_DIR}/common/tokenize.gperf
129             ${BUILD_DIR}/common/tokenize.h
130     OUTPUT  ${BUILD_DIR}/common/tokenize.h
131     DEPENDS ${SOURCE_DIR}/common/tokenize.gperf
132             ${SOURCE_DIR}/build-utils/gperf.sh
133     COMMENT "Generating common/tokenize.h")
135 add_custom_command(
136     COMMAND ${SOURCE_DIR}/build-utils/gperf.sh
137     ARGS    ${SOURCE_DIR}/common/tokenize.gperf
138             ${BUILD_DIR}/common/tokenize.c
139     OUTPUT  ${BUILD_DIR}/common/tokenize.c
140     DEPENDS ${SOURCE_DIR}/common/tokenize.gperf
141             ${SOURCE_DIR}/build-utils/gperf.sh
142     COMMENT "Generating common/tokenize.c")
144 add_custom_target(generated_sources
145     DEPENDS ${BUILD_DIR}/common/atoms-intern.h
146             ${BUILD_DIR}/common/atoms-extern.h
147             ${BUILD_DIR}/common/tokenize.c
148             ${BUILD_DIR}/common/tokenize.h)
150 # Default theme directory
151 file(MAKE_DIRECTORY ${BUILD_DIR}/themes/default)
152 file(MAKE_DIRECTORY ${BUILD_DIR}/themes/sky)
153 file(MAKE_DIRECTORY ${BUILD_DIR}/themes/zenburn)
154 add_dependencies(${PROJECT_AWE_NAME} generated_sources)
155 # }}}
157 # {{{ Version stamp
158 if(BUILD_FROM_GIT)
159     add_custom_target(version_stamp ALL
160         COMMAND ${SOURCE_DIR}/build-utils/git-version-stamp.sh
161                 ${VERSION_STAMP_FILE}
162                 ${BUILD_DIR}/awesome-version-internal.h
163         WORKING_DIRECTORY ${SOURCE_DIR})
165     add_dependencies(${PROJECT_AWE_NAME} version_stamp)
166 endif()
167 # }}}
169 # {{{ Manpages
170 if(GENERATE_MANPAGES)
171     if(NOT BUILD_DIR STREQUAL SOURCE_DIR)
172         file(MAKE_DIRECTORY ${BUILD_DIR}/manpages)
173     endif()
174     foreach(txtfile ${AWE_MAN_SRCS})
175         string(REGEX REPLACE ".txt\$" ".xml" xmlfile ${txtfile})
176         string(REPLACE ${SOURCE_DIR}
177                        ${BUILD_DIR} xmlfile ${xmlfile})
178         string(REGEX REPLACE ".xml\$" ".gz" gzfile ${xmlfile})
179         string(REGEX REPLACE ".gz\$" "" manfile ${gzfile})
181         add_custom_command(
182             COMMAND ${ASCIIDOC_EXECUTABLE} -d manpage -b docbook -o ${xmlfile} - < ${txtfile}
183             WORKING_DIRECTORY ${BUILD_DIR}/manpages
184             OUTPUT  ${xmlfile}
185             DEPENDS ${txtfile}
186             VERBATIM)
187         add_custom_command(
188             COMMAND ${XMLTO_EXECUTABLE} man ${xmlfile}
189             OUTPUT  ${manfile}
190             WORKING_DIRECTORY ${BUILD_DIR}/manpages
191             DEPENDS ${xmlfile})
193         if(COMPRESS_MANPAGES)
194             add_custom_command(
195                 COMMAND ${GZIP_EXECUTABLE} < ${manfile} > ${gzfile}
196                 OUTPUT  ${gzfile}
197                 WORKING_DIRECTORY ${BUILD_DIR}/manpages
198                 DEPENDS ${manfile}
199                 VERBATIM)
201             set(MAN_FILES ${MAN_FILES} ${gzfile})
202         else()
203             set(MAN_FILES ${MAN_FILES} ${manfile})
204         endif()
206         # figure out in what section to install to from filename
207         string(REGEX REPLACE "^.*\\.([0-9])\\.gz\$" "\\1" section ${gzfile})
208         if(COMPRESS_MANPAGES)
209             set(AWE_MAN${section}_FILES ${AWE_MAN${section}_FILES} ${gzfile})
210         else()
211             set(AWE_MAN${section}_FILES ${AWE_MAN${section}_FILES} ${manfile})
212         endif()
213     endforeach()
215     add_custom_target(man ALL DEPENDS ${MAN_FILES})
216 endif()
217 # }}}
219 # {{{ Doxygen
220 if(DOXYGEN_EXECUTABLE)
221     add_custom_target(doc
222         COMMAND ${DOXYGEN_EXECUTABLE} awesome.doxygen
223         WORKING_DIRECTORY ${BUILD_DIR})
224 endif()
225 # }}}
227 # {{{ Lua API Documentation
228 if(GENERATE_LUADOC)
230     if(NOT BUILD_DIR STREQUAL SOURCE_DIR)
231         file(MAKE_DIRECTORY ${BUILD_DIR}/lib)
232     endif()
234     set(luadoc_c_srcs "")
236     # Generate documentation of lib//0lua
237     file(GLOB_RECURSE lua_lib_files ${BUILD_DIR}/lib/*.lua
238         ${SOURCE_DIR}/luadoc/*.lua)
239     foreach(filename ${lua_lib_files})
240         file(RELATIVE_PATH filename ${BUILD_DIR} ${filename})
241         set(luadoc_srcs ${luadoc_srcs} ${filename})
242     endforeach()
244     add_custom_target(luadoc ALL
245         COMMAND ${LUADOC_EXECUTABLE} ${luadoc_srcs} -d ${BUILD_DIR}/luadoc --nofiles
246         WORKING_DIRECTORY ${BUILD_DIR}
247         DEPENDS ${AWE_LUA_FILES})
248 endif()
249 # }}}
251 # {{{ Theme icons
252 file(GLOB icon_sources ${SOURCE_DIR}/themes/*/titlebar/*.png)
253 set(ALL_ICONS ${icon_sources})
255 macro(a_icon_convert match replacement input)
256     string(REPLACE ${match} ${replacement} output ${input})
258     if(NOT ${input} STREQUAL ${output})
259         if(NOT ${output} MATCHES ${BUILD_DIR})
260             string(REPLACE ${SOURCE_DIR} ${BUILD_DIR} output ${output})
261         endif()
263         set(ALL_ICONS ${ALL_ICONS} ${output})
265         get_filename_component(output_path ${output} PATH)
266         file(MAKE_DIRECTORY ${output_path})
268         add_custom_command(
269             COMMAND ${CONVERT_EXECUTABLE} ${input} ${ARGN} ${output}
270             OUTPUT  ${output}
271             DEPENDS ${input}
272             VERBATIM)
273     endif()
274 endmacro()
276 foreach(icon ${ALL_ICONS})
277     # Make unfocused icons translucent
278     a_icon_convert("_focus" "_normal" ${icon}
279         -gamma 0.6 -channel A -evaluate Multiply 0.4)
280 endforeach()
282 foreach(icon ${ALL_ICONS})
283     # Make inactive icons grayscale
284     a_icon_convert("_active" "_inactive" ${icon}
285         -colorspace Gray)
286 endforeach()
288 add_custom_target(generated_icons ALL DEPENDS ${ALL_ICONS})
289 # }}}
291 # {{{ Dist tarball
292 if(BUILD_FROM_GIT)
293     add_custom_target(dist
294         COMMAND ${SOURCE_DIR}/build-utils/dist.sh ${VERSION}
295         WORKING_DIRECTORY ${SOURCE_DIR})
296 endif()
297 # }}}
299 # {{{ Installation
300 install(TARGETS ${PROJECT_AWE_NAME} RUNTIME DESTINATION bin)
301 install(FILES "utils/awsetbg" DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
302 install(FILES "utils/awesome-client" DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
303 install(DIRECTORY ${BUILD_DIR}/lib DESTINATION ${AWESOME_DATA_PATH}
304     PATTERN "*.in" EXCLUDE)
305 install(FILES ${AWE_CONF_FILE_DEFAULT} DESTINATION ${AWESOME_SYSCONFDIR}
306         RENAME ${AWE_CONF_FILE})
307 if(GENERATE_MANPAGES)
308     install(FILES ${AWE_MAN1_FILES} DESTINATION ${AWESOME_MAN_PATH}/man1)
309     install(FILES ${AWE_MAN5_FILES} DESTINATION ${AWESOME_MAN_PATH}/man5)
310 endif()
311 install(DIRECTORY ${AWE_ICON_DIR} DESTINATION ${AWESOME_DATA_PATH})
312 install(DIRECTORY ${BUILD_DIR}/themes DESTINATION ${AWESOME_DATA_PATH}
313     PATTERN "*.in" EXCLUDE)
314 install(DIRECTORY ${SOURCE_DIR}/themes DESTINATION ${AWESOME_DATA_PATH}
315     PATTERN "*.in" EXCLUDE)
316 install(FILES ${AWE_DOC_FILES} DESTINATION ${AWESOME_DOC_PATH})
317 install(FILES "awesome.desktop" DESTINATION ${AWESOME_XSESSION_PATH})
318 if(GENERATE_LUADOC)
319     install(DIRECTORY ${BUILD_DIR}/luadoc DESTINATION ${AWESOME_DOC_PATH})
320 endif()
321 # }}}
323 # vim: filetype=cmake:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80