dbus: only warn, dot not raises an error (FS#713)
[awesome.git] / CMakeLists.txt
blob8042b957429679cf323c459e0249206561836ff5
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)
91 set(AWE_MAN_LANGS es fr de)
93 add_executable(${PROJECT_AWE_NAME}
94     ${AWE_SRCS}
95     ${BUILD_DIR}/common/tokenize.c)
97 set_target_properties(${PROJECT_AWE_NAME}
98     PROPERTIES
99     LINK_FLAGS -export-dynamic)
101 target_link_libraries(${PROJECT_AWE_NAME}
102     ${AWESOME_COMMON_REQUIRED_LIBRARIES}
103     ${AWESOME_REQUIRED_LIBRARIES}
104     ${AWESOME_OPTIONAL_LIBRARIES})
106 # atoms
107 file(MAKE_DIRECTORY ${BUILD_DIR}/common)
108 add_custom_command(
109     COMMAND ${SOURCE_DIR}/build-utils/atoms-ext.sh ${SOURCE_DIR}/common/atoms.list
110     ARGS    > ${BUILD_DIR}/common/atoms-extern.h
111     OUTPUT  ${BUILD_DIR}/common/atoms-extern.h
112     WORKING_DIRECTORY ${SOURCE_DIR}
113     DEPENDS ${SOURCE_DIR}/common/atoms.list
114     COMMENT "Generating atoms-extern.h"
115     VERBATIM)
117 add_custom_command(
118     COMMAND ${SOURCE_DIR}/build-utils/atoms-int.sh ${SOURCE_DIR}/common/atoms.list
119     ARGS    > ${BUILD_DIR}/common/atoms-intern.h
120     OUTPUT  ${BUILD_DIR}/common/atoms-intern.h
121     WORKING_DIRECTORY ${SOURCE_DIR}
122     DEPENDS ${SOURCE_DIR}/common/atoms.list
123     COMMENT "Generating atoms-intern.h"
124     VERBATIM)
126 # gperf
127 add_custom_command(
128     COMMAND ${SOURCE_DIR}/build-utils/gperf.sh
129     ARGS    ${SOURCE_DIR}/common/tokenize.gperf
130             ${BUILD_DIR}/common/tokenize.h
131     OUTPUT  ${BUILD_DIR}/common/tokenize.h
132     DEPENDS ${SOURCE_DIR}/common/tokenize.gperf
133             ${SOURCE_DIR}/build-utils/gperf.sh
134     COMMENT "Generating common/tokenize.h")
136 add_custom_command(
137     COMMAND ${SOURCE_DIR}/build-utils/gperf.sh
138     ARGS    ${SOURCE_DIR}/common/tokenize.gperf
139             ${BUILD_DIR}/common/tokenize.c
140     OUTPUT  ${BUILD_DIR}/common/tokenize.c
141     DEPENDS ${SOURCE_DIR}/common/tokenize.gperf
142             ${SOURCE_DIR}/build-utils/gperf.sh
143     COMMENT "Generating common/tokenize.c")
145 add_custom_target(generated_sources
146     DEPENDS ${BUILD_DIR}/common/atoms-intern.h
147             ${BUILD_DIR}/common/atoms-extern.h
148             ${BUILD_DIR}/common/tokenize.c
149             ${BUILD_DIR}/common/tokenize.h)
151 # Default theme directory
152 file(MAKE_DIRECTORY ${BUILD_DIR}/themes/default)
153 file(MAKE_DIRECTORY ${BUILD_DIR}/themes/sky)
154 file(MAKE_DIRECTORY ${BUILD_DIR}/themes/zenburn)
155 add_dependencies(${PROJECT_AWE_NAME} generated_sources)
156 # }}}
158 # {{{ Version stamp
159 if(BUILD_FROM_GIT)
160     add_custom_target(version_stamp ALL
161         COMMAND ${SOURCE_DIR}/build-utils/git-version-stamp.sh
162                 ${VERSION_STAMP_FILE}
163                 ${BUILD_DIR}/awesome-version-internal.h
164         WORKING_DIRECTORY ${SOURCE_DIR})
166     add_dependencies(${PROJECT_AWE_NAME} version_stamp)
167 endif()
168 # }}}
170 # {{{ Manpages
171 if(GENERATE_MANPAGES)
172     if(NOT BUILD_DIR STREQUAL SOURCE_DIR)
173         file(MAKE_DIRECTORY ${BUILD_DIR}/manpages)
174     endif()
176     # add the default translation to the list of languages
177     set(AWE_MAN_LANGS default ${AWE_MAN_LANGS})
179     foreach(lang ${AWE_MAN_LANGS})
181         foreach(txtfile ${AWE_MAN_SRCS})
182             # figure the base name of the file (ie "awesome.1")
183             GET_FILENAME_COMPONENT(tmpname ${txtfile} NAME)
184             string(REGEX REPLACE ".txt\$" "" basename ${tmpname})
186             # figure the relative path of the file
187             GET_FILENAME_COMPONENT(tmppath ${txtfile} PATH)
188             string(REPLACE ${SOURCE_DIR}/ "" relpath ${tmppath})
190             # figure the manpage section to install to from filename
191             string(REGEX REPLACE "^.*\\.([0-9])$" "\\1" section ${basename})
193             # construct the language specific versions of the basename and path
194             if (lang STREQUAL default)
195                 set(basename2 ${basename})
196                 set(relpath2 ${relpath}/man${section})
197             else()
198                 set(basename2 ${basename}.${lang})
199                 set(relpath2 ${relpath}/${lang}/man${section})
200             endif()
202             # create the build directory (if it does not exist)
203             file(MAKE_DIRECTORY ${BUILD_DIR}/${relpath2})
205             # set the final filenames
206             set(txtfile ${SOURCE_DIR}/${relpath}/${basename2}.txt)
207             set(xmlfile ${BUILD_DIR}/${relpath2}/${basename}.xml)
208             set(gzfile  ${BUILD_DIR}/${relpath2}/${basename}.gz)
209             set(manfile ${BUILD_DIR}/${relpath2}/${basename})
211             add_custom_command(
212                 COMMAND ${ASCIIDOC_EXECUTABLE} -d manpage -b docbook -o ${xmlfile} - < ${txtfile}
213                 WORKING_DIRECTORY ${BUILD_DIR}/${relpath2}
214                 OUTPUT  ${xmlfile}
215                 DEPENDS ${txtfile}
216                 VERBATIM)
217             add_custom_command(
218                 COMMAND ${XMLTO_EXECUTABLE} man ${xmlfile}
219                 OUTPUT  ${manfile}
220                 WORKING_DIRECTORY ${BUILD_DIR}/${relpath2}
221                 DEPENDS ${xmlfile})
223             if(COMPRESS_MANPAGES)
224                 add_custom_command(
225                     COMMAND ${GZIP_EXECUTABLE} < ${manfile} > ${gzfile}
226                     OUTPUT  ${gzfile}
227                     WORKING_DIRECTORY ${BUILD_DIR}/${relpath2}
228                     DEPENDS ${manfile}
229                     VERBATIM)
231                 set(MAN_FILES ${MAN_FILES} ${gzfile})
232             else()
233                 set(MAN_FILES ${MAN_FILES} ${manfile})
234             endif()
235         endforeach()
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     if(NOT BUILD_DIR STREQUAL SOURCE_DIR)
255         file(MAKE_DIRECTORY ${BUILD_DIR}/lib)
256     endif()
258     set(luadoc_c_srcs "")
260     # Generate documentation of lib//0lua
261     file(GLOB_RECURSE lua_lib_files ${BUILD_DIR}/lib/*.lua
262         ${SOURCE_DIR}/luadoc/*.lua)
263     foreach(filename ${lua_lib_files})
264         file(RELATIVE_PATH filename ${BUILD_DIR} ${filename})
265         set(luadoc_srcs ${luadoc_srcs} ${filename})
266     endforeach()
268     add_custom_target(luadoc ALL
269         COMMAND ${LUADOC_EXECUTABLE} ${luadoc_srcs} -d ${BUILD_DIR}/luadoc --nofiles
270         WORKING_DIRECTORY ${BUILD_DIR}
271         DEPENDS ${AWE_LUA_FILES})
272 endif()
273 # }}}
275 # {{{ Theme icons
276 file(GLOB icon_sources ${SOURCE_DIR}/themes/*/titlebar/*.png)
277 set(ALL_ICONS ${icon_sources})
279 macro(a_icon_convert match replacement input)
280     string(REPLACE ${match} ${replacement} output ${input})
282     if(NOT ${input} STREQUAL ${output})
283         if(NOT ${output} MATCHES ${BUILD_DIR})
284             string(REPLACE ${SOURCE_DIR} ${BUILD_DIR} output ${output})
285         endif()
287         set(ALL_ICONS ${ALL_ICONS} ${output})
289         get_filename_component(output_path ${output} PATH)
290         file(MAKE_DIRECTORY ${output_path})
292         add_custom_command(
293             COMMAND ${CONVERT_EXECUTABLE} ${input} ${ARGN} ${output}
294             OUTPUT  ${output}
295             DEPENDS ${input}
296             VERBATIM)
297     endif()
298 endmacro()
300 foreach(icon ${ALL_ICONS})
301     # Make unfocused icons translucent
302     a_icon_convert("_focus" "_normal" ${icon}
303         -gamma 0.6 -channel A -evaluate Multiply 0.4)
304 endforeach()
306 foreach(icon ${ALL_ICONS})
307     # Make inactive icons grayscale
308     a_icon_convert("_active" "_inactive" ${icon}
309         -colorspace Gray)
310 endforeach()
312 add_custom_target(generated_icons ALL DEPENDS ${ALL_ICONS})
313 # }}}
315 # {{{ Dist tarball
316 if(BUILD_FROM_GIT)
317     add_custom_target(dist
318         COMMAND ${SOURCE_DIR}/build-utils/dist.sh ${VERSION}
319         WORKING_DIRECTORY ${SOURCE_DIR})
320 endif()
321 # }}}
323 # {{{ Installation
324 install(TARGETS ${PROJECT_AWE_NAME} RUNTIME DESTINATION bin)
325 install(FILES "utils/awsetbg" DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
326 install(FILES "utils/awesome-client" DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
327 install(DIRECTORY ${BUILD_DIR}/lib DESTINATION ${AWESOME_DATA_PATH}
328     PATTERN "*.in" EXCLUDE)
329 install(FILES ${AWE_CONF_FILE_DEFAULT} DESTINATION ${AWESOME_SYSCONFDIR}
330         RENAME ${AWE_CONF_FILE})
331 if(GENERATE_MANPAGES)
332     if(COMPRESS_MANPAGES)
333         set(regex "\\.(xml|txt|[0-9])$")
334     else()
335         set(regex "\\.(xml|txt|gz)$")
336     endif()
337     install(DIRECTORY ${BUILD_DIR}/${relpath}/ DESTINATION ${AWESOME_MAN_PATH}
338             REGEX ${regex} EXCLUDE )
339 endif()
340 install(DIRECTORY ${AWE_ICON_DIR} DESTINATION ${AWESOME_DATA_PATH})
341 install(DIRECTORY ${BUILD_DIR}/themes DESTINATION ${AWESOME_DATA_PATH}
342     PATTERN "*.in" EXCLUDE)
343 install(DIRECTORY ${SOURCE_DIR}/themes DESTINATION ${AWESOME_DATA_PATH}
344     PATTERN "*.in" EXCLUDE)
345 install(FILES ${AWE_DOC_FILES} DESTINATION ${AWESOME_DOC_PATH})
346 install(FILES "awesome.desktop" DESTINATION ${AWESOME_XSESSION_PATH})
347 if(GENERATE_LUADOC)
348     install(DIRECTORY ${BUILD_DIR}/luadoc DESTINATION ${AWESOME_DOC_PATH})
349 endif()
350 # }}}
352 # vim: filetype=cmake:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80