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)
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")
15 include(awesomeConfig.cmake)
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)
36 ${SOURCE_DIR}/LICENSE)
39 ${SOURCE_DIR}/awesome.c
40 ${SOURCE_DIR}/client.c
45 ${SOURCE_DIR}/property.c
48 ${SOURCE_DIR}/keygrabber.c
49 ${SOURCE_DIR}/mousegrabber.c
50 ${SOURCE_DIR}/banning.c
55 ${SOURCE_DIR}/button.c
56 ${SOURCE_DIR}/screen.c
58 ${SOURCE_DIR}/selection.c
60 ${SOURCE_DIR}/systray.c
62 ${SOURCE_DIR}/titlebar.c
63 ${SOURCE_DIR}/widget.c
64 ${SOURCE_DIR}/window.c
69 ${SOURCE_DIR}/common/buffer.c
70 ${SOURCE_DIR}/common/atoms.c
71 ${SOURCE_DIR}/common/util.c
72 ${SOURCE_DIR}/common/version.c
73 ${SOURCE_DIR}/common/xembed.c
74 ${SOURCE_DIR}/common/xutil.c
75 ${SOURCE_DIR}/common/xcursor.c
76 ${SOURCE_DIR}/common/backtrace.c
77 ${SOURCE_DIR}/common/luaobject.c
78 ${SOURCE_DIR}/common/luaclass.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)
86 ${SOURCE_DIR}/manpages/awesome.1.txt
87 ${SOURCE_DIR}/manpages/awsetbg.1.txt
88 ${SOURCE_DIR}/manpages/awesome-client.1.txt
89 ${SOURCE_DIR}/manpages/awesomerc.5.txt)
91 add_executable(${PROJECT_AWE_NAME}
93 ${BUILD_DIR}/common/tokenize.c)
95 set_target_properties(${PROJECT_AWE_NAME}
97 LINK_FLAGS -export-dynamic)
99 target_link_libraries(${PROJECT_AWE_NAME}
100 ${AWESOME_COMMON_REQUIRED_LIBRARIES}
101 ${AWESOME_REQUIRED_LIBRARIES}
102 ${AWESOME_OPTIONAL_LIBRARIES})
105 file(MAKE_DIRECTORY ${BUILD_DIR}/common)
107 COMMAND ${SOURCE_DIR}/build-utils/atoms-ext.sh ${SOURCE_DIR}/common/atoms.list
108 ARGS > ${BUILD_DIR}/common/atoms-extern.h
109 OUTPUT ${BUILD_DIR}/common/atoms-extern.h
110 WORKING_DIRECTORY ${SOURCE_DIR}
111 DEPENDS ${SOURCE_DIR}/common/atoms.list
112 COMMENT "Generating atoms-extern.h"
116 COMMAND ${SOURCE_DIR}/build-utils/atoms-int.sh ${SOURCE_DIR}/common/atoms.list
117 ARGS > ${BUILD_DIR}/common/atoms-intern.h
118 OUTPUT ${BUILD_DIR}/common/atoms-intern.h
119 WORKING_DIRECTORY ${SOURCE_DIR}
120 DEPENDS ${SOURCE_DIR}/common/atoms.list
121 COMMENT "Generating atoms-intern.h"
126 COMMAND ${SOURCE_DIR}/build-utils/gperf.sh
127 ARGS ${SOURCE_DIR}/common/tokenize.gperf
128 ${BUILD_DIR}/common/tokenize.h
129 OUTPUT ${BUILD_DIR}/common/tokenize.h
130 DEPENDS ${SOURCE_DIR}/common/tokenize.gperf
131 ${SOURCE_DIR}/build-utils/gperf.sh
132 COMMENT "Generating common/tokenize.h")
135 COMMAND ${SOURCE_DIR}/build-utils/gperf.sh
136 ARGS ${SOURCE_DIR}/common/tokenize.gperf
137 ${BUILD_DIR}/common/tokenize.c
138 OUTPUT ${BUILD_DIR}/common/tokenize.c
139 DEPENDS ${SOURCE_DIR}/common/tokenize.gperf
140 ${SOURCE_DIR}/build-utils/gperf.sh
141 COMMENT "Generating common/tokenize.c")
143 add_custom_target(generated_sources
144 DEPENDS ${BUILD_DIR}/common/atoms-intern.h
145 ${BUILD_DIR}/common/atoms-extern.h
146 ${BUILD_DIR}/common/tokenize.c
147 ${BUILD_DIR}/common/tokenize.h)
149 # Default theme directory
150 file(MAKE_DIRECTORY ${BUILD_DIR}/themes/default)
151 file(MAKE_DIRECTORY ${BUILD_DIR}/themes/sky)
152 add_dependencies(${PROJECT_AWE_NAME} generated_sources)
157 add_custom_target(version_stamp ALL
158 COMMAND ${SOURCE_DIR}/build-utils/git-version-stamp.sh
159 ${VERSION_STAMP_FILE}
160 ${BUILD_DIR}/awesome-version-internal.h
161 WORKING_DIRECTORY ${SOURCE_DIR})
163 add_dependencies(${PROJECT_AWE_NAME} version_stamp)
168 if(GENERATE_MANPAGES)
169 if(NOT BUILD_DIR STREQUAL SOURCE_DIR)
170 file(MAKE_DIRECTORY ${BUILD_DIR}/manpages)
172 foreach(txtfile ${AWE_MAN_SRCS})
173 string(REGEX REPLACE ".txt\$" ".xml" xmlfile ${txtfile})
174 string(REPLACE ${SOURCE_DIR}
175 ${BUILD_DIR} xmlfile ${xmlfile})
176 string(REGEX REPLACE ".xml\$" ".gz" gzfile ${xmlfile})
177 string(REGEX REPLACE ".gz\$" "" manfile ${gzfile})
180 COMMAND ${ASCIIDOC_EXECUTABLE} -d manpage -b docbook -o ${xmlfile} - < ${txtfile}
181 WORKING_DIRECTORY ${BUILD_DIR}/manpages
186 COMMAND ${XMLTO_EXECUTABLE} man ${xmlfile}
188 WORKING_DIRECTORY ${BUILD_DIR}/manpages
191 COMMAND ${GZIP_EXECUTABLE} < ${manfile} > ${gzfile}
193 WORKING_DIRECTORY ${BUILD_DIR}/manpages
197 set(MAN_FILES ${MAN_FILES} ${gzfile})
199 # figure out in what section to install to from filename
200 string(REGEX REPLACE "^.*\\.([0-9])\\.gz\$" "\\1" section ${gzfile})
201 set(AWE_MAN${section}_FILES ${AWE_MAN${section}_FILES} ${gzfile})
204 add_custom_target(man ALL DEPENDS ${MAN_FILES})
209 if(DOXYGEN_EXECUTABLE)
210 add_custom_target(doc
211 COMMAND ${DOXYGEN_EXECUTABLE} awesome.doxygen
212 WORKING_DIRECTORY ${BUILD_DIR})
216 # {{{ Lua API Documentation
219 if(NOT BUILD_DIR STREQUAL SOURCE_DIR)
220 file(MAKE_DIRECTORY ${BUILD_DIR}/lib)
223 set(luadoc_c_srcs "")
225 # Generate documentation of lib//0lua
226 file(GLOB_RECURSE lua_lib_files ${BUILD_DIR}/lib/*.lua
227 ${SOURCE_DIR}/luadoc/*.lua)
228 foreach(filename ${lua_lib_files})
229 file(RELATIVE_PATH filename ${BUILD_DIR} ${filename})
230 set(luadoc_srcs ${luadoc_srcs} ${filename})
233 add_custom_target(luadoc ALL
234 COMMAND ${LUADOC_EXECUTABLE} ${luadoc_srcs} -d ${BUILD_DIR}/luadoc --nofiles
235 WORKING_DIRECTORY ${BUILD_DIR}
236 DEPENDS ${AWE_LUA_FILES})
241 file(GLOB icon_sources ${SOURCE_DIR}/themes/*/titlebar/*.png)
242 set(ALL_ICONS ${icon_sources})
244 macro(a_icon_convert match replacement input)
245 string(REPLACE ${match} ${replacement} output ${input})
247 if(NOT ${input} STREQUAL ${output})
248 if(NOT ${output} MATCHES ${BUILD_DIR})
249 string(REPLACE ${SOURCE_DIR} ${BUILD_DIR} output ${output})
252 set(ALL_ICONS ${ALL_ICONS} ${output})
254 get_filename_component(output_path ${output} PATH)
255 file(MAKE_DIRECTORY ${output_path})
258 COMMAND ${CONVERT_EXECUTABLE} ${input} ${ARGN} ${output}
265 foreach(icon ${ALL_ICONS})
266 # Make unfocused icons translucent
267 a_icon_convert("_focus" "_normal" ${icon}
268 -gamma 0.6 -channel A -evaluate Multiply 0.4)
271 foreach(icon ${ALL_ICONS})
272 # Make inactive icons grayscale
273 a_icon_convert("_active" "_inactive" ${icon}
277 add_custom_target(generated_icons ALL DEPENDS ${ALL_ICONS})
282 add_custom_target(dist
283 COMMAND ${SOURCE_DIR}/build-utils/dist.sh ${VERSION}
284 WORKING_DIRECTORY ${SOURCE_DIR})
289 install(TARGETS ${PROJECT_AWE_NAME} RUNTIME DESTINATION bin)
290 install(FILES "utils/awsetbg" DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
291 install(FILES "utils/awesome-client" DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
292 install(DIRECTORY ${BUILD_DIR}/lib DESTINATION ${AWESOME_DATA_PATH})
293 install(FILES ${AWE_CONF_FILE_DEFAULT} DESTINATION ${AWESOME_SYSCONFDIR}
294 RENAME ${AWE_CONF_FILE})
295 if(GENERATE_MANPAGES)
296 install(FILES ${AWE_MAN1_FILES} DESTINATION ${AWESOME_MAN_PATH}/man1)
297 install(FILES ${AWE_MAN5_FILES} DESTINATION ${AWESOME_MAN_PATH}/man5)
299 install(DIRECTORY ${AWE_ICON_DIR} DESTINATION ${AWESOME_DATA_PATH})
300 install(DIRECTORY ${BUILD_DIR}/themes DESTINATION ${AWESOME_DATA_PATH})
301 install(DIRECTORY ${SOURCE_DIR}/themes DESTINATION ${AWESOME_DATA_PATH}
302 PATTERN "*.in" EXCLUDE)
303 install(FILES ${AWE_DOC_FILES} DESTINATION ${AWESOME_DOC_PATH})
304 install(FILES "awesome.desktop" DESTINATION ${AWESOME_XSESSION_PATH})
306 install(DIRECTORY ${BUILD_DIR}/luadoc DESTINATION ${AWESOME_DOC_PATH})
310 # vim: filetype=cmake:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80