1 cmake_minimum_required(VERSION 2.4.7)
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)
21 ${AWESOME_REQUIRED_INCLUDE_DIRS}
22 ${AWESOME_OPTIONAL_INCLUDE_DIRS})
25 ${SOURCE_DIR}/lib/tabulous.lua
26 ${SOURCE_DIR}/lib/beautiful.lua)
27 set(awful_lua ${BUILD_DIR}/lib/awful.lua)
29 set(AWE_CONF_FILE_DEFAULT ${BUILD_DIR}/awesomerc.lua)
30 set(AWE_CONF_FILE rc.lua)
32 set(AWE_ICON_DIR ${SOURCE_DIR}/icons)
33 set(AWE_THEMES_DIR ${SOURCE_DIR}/themes)
39 ${SOURCE_DIR}/LICENSE)
42 ${SOURCE_DIR}/awesome.c
43 ${SOURCE_DIR}/client.c
48 ${SOURCE_DIR}/keybinding.c
49 ${SOURCE_DIR}/keygrabber.c
50 ${SOURCE_DIR}/layout.c
53 ${SOURCE_DIR}/placement.c
54 ${SOURCE_DIR}/screen.c
56 ${SOURCE_DIR}/statusbar.c
57 ${SOURCE_DIR}/systray.c
59 ${SOURCE_DIR}/titlebar.c
60 ${SOURCE_DIR}/widget.c
61 ${SOURCE_DIR}/window.c
62 ${SOURCE_DIR}/common/buffer.c
63 ${SOURCE_DIR}/common/atoms.c
64 ${SOURCE_DIR}/common/draw.c
65 ${SOURCE_DIR}/common/markup.c
66 ${SOURCE_DIR}/common/socket.c
67 ${SOURCE_DIR}/common/swindow.c
68 ${SOURCE_DIR}/common/util.c
69 ${SOURCE_DIR}/common/version.c
70 ${SOURCE_DIR}/common/xembed.c
71 ${SOURCE_DIR}/common/xscreen.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/max.c
77 ${SOURCE_DIR}/layouts/tile.c
78 ${SOURCE_DIR}/widgets/graph.c
79 ${SOURCE_DIR}/widgets/progressbar.c
80 ${SOURCE_DIR}/widgets/taglist.c
81 ${SOURCE_DIR}/widgets/tasklist.c
82 ${SOURCE_DIR}/widgets/textbox.c
83 ${SOURCE_DIR}/widgets/systray.c
84 ${SOURCE_DIR}/widgets/appicon.c)
87 ${SOURCE_DIR}/awesome-client.c
88 ${SOURCE_DIR}/common/socket.c
89 ${SOURCE_DIR}/common/util.c
90 ${SOURCE_DIR}/common/version.c)
93 ${SOURCE_DIR}/awesome.1.txt
94 ${SOURCE_DIR}/awesome-client.1.txt
95 ${SOURCE_DIR}/awesomerc.5.txt)
97 add_executable(${PROJECT_AWE_NAME}
99 ${BUILD_DIR}/common/tokenize.c)
101 add_executable(${PROJECT_AWECLIENT_NAME}
103 ${BUILD_DIR}/common/tokenize.c)
105 target_link_libraries(${PROJECT_AWE_NAME}
106 ${AWESOME_REQUIRED_LIBRARIES}
107 ${AWESOME_OPTIONAL_LIBRARIES})
109 target_link_libraries(${PROJECT_AWECLIENT_NAME}
110 ${AWESOMECLIENT_LIBRARIES})
112 # {{{ Generated sources
113 file(GLOB LAYOUTGEN_DEPS ${SOURCE_DIR}/layouts/*.h)
115 COMMAND ${SOURCE_DIR}/build-utils/layoutgen.sh
116 ARGS > ${BUILD_DIR}/layoutgen.h
117 OUTPUT ${BUILD_DIR}/layoutgen.h
118 WORKING_DIRECTORY ${SOURCE_DIR}
119 DEPENDS ${LAYOUTGEN_DEPS}
120 COMMENT "Generating layoutgen.h"
124 COMMAND ${SOURCE_DIR}/build-utils/widgetgen.sh
125 ARGS > ${BUILD_DIR}/widgetgen.h
126 OUTPUT ${BUILD_DIR}/widgetgen.h
127 WORKING_DIRECTORY ${SOURCE_DIR}
128 DEPENDS ${SOURCE_DIR}/widget.h
129 COMMENT "Generating widgetgen.h"
133 file(MAKE_DIRECTORY ${BUILD_DIR}/common)
135 COMMAND ${SOURCE_DIR}/build-utils/atoms-ext.sh ${SOURCE_DIR}/common/atoms.list
136 ARGS > ${BUILD_DIR}/common/atoms-extern.h
137 OUTPUT ${BUILD_DIR}/common/atoms-extern.h
138 WORKING_DIRECTORY ${SOURCE_DIR}
139 DEPENDS ${SOURCE_DIR}/common/atoms.list
140 COMMENT "Generating atoms-extern.h"
144 COMMAND ${SOURCE_DIR}/build-utils/atoms-int.sh ${SOURCE_DIR}/common/atoms.list
145 ARGS > ${BUILD_DIR}/common/atoms-intern.h
146 OUTPUT ${BUILD_DIR}/common/atoms-intern.h
147 WORKING_DIRECTORY ${SOURCE_DIR}
148 DEPENDS ${SOURCE_DIR}/common/atoms.list
149 COMMENT "Generating atoms-intern.h"
154 COMMAND ${SOURCE_DIR}/build-utils/gperf.sh
155 ARGS ${SOURCE_DIR}/common/tokenize.gperf
156 ${BUILD_DIR}/common/tokenize.h
157 OUTPUT ${BUILD_DIR}/common/tokenize.h
158 DEPENDS ${SOURCE_DIR}/common/tokenize.gperf
159 ${SOURCE_DIR}/build-utils/gperf.sh
160 COMMENT "Generating common/tokenize.h")
163 COMMAND ${SOURCE_DIR}/build-utils/gperf.sh
164 ARGS ${SOURCE_DIR}/common/tokenize.gperf
165 ${BUILD_DIR}/common/tokenize.c
166 OUTPUT ${BUILD_DIR}/common/tokenize.c
167 DEPENDS ${SOURCE_DIR}/common/tokenize.gperf
168 ${SOURCE_DIR}/build-utils/gperf.sh
169 COMMENT "Generating common/tokenize.c")
171 add_custom_target(generated_sources
172 DEPENDS ${BUILD_DIR}/widgetgen.h
173 ${BUILD_DIR}/layoutgen.h
174 ${BUILD_DIR}/common/atoms-intern.h
175 ${BUILD_DIR}/common/atoms-extern.h
176 ${BUILD_DIR}/common/tokenize.c
177 ${BUILD_DIR}/common/tokenize.h)
179 add_dependencies(${PROJECT_AWE_NAME} generated_sources)
180 add_dependencies(${PROJECT_AWECLIENT_NAME} generated_sources)
185 add_custom_target(version_stamp ALL
186 COMMAND ${SOURCE_DIR}/build-utils/git-version-stamp.sh
187 ${VERSION_STAMP_FILE}
188 ${BUILD_DIR}/awesome-version-internal.h
189 WORKING_DIRECTORY ${SOURCE_DIR})
191 add_dependencies(${PROJECT_AWE_NAME} version_stamp)
192 add_dependencies(${PROJECT_AWECLIENT_NAME} version_stamp)
197 if(GENERATE_MANPAGES)
198 foreach(txtfile ${AWE_MAN_SRCS})
199 string(REGEX REPLACE ".txt\$" ".xml" xmlfile ${txtfile})
200 string(REPLACE ${SOURCE_DIR}
201 ${BUILD_DIR} xmlfile ${xmlfile})
202 string(REGEX REPLACE ".xml\$" ".gz" gzfile ${xmlfile})
203 string(REGEX REPLACE ".gz\$" "" manfile ${gzfile})
206 COMMAND ${CAT_EXECUTABLE} ${txtfile}
207 | ${ASCIIDOC_EXECUTABLE} -d manpage -b docbook -o ${xmlfile} -
208 WORKING_DIRECTORY ${BUILD_DIR}
213 COMMAND ${XMLTO_EXECUTABLE} man ${xmlfile}
217 COMMAND ${CAT_EXECUTABLE} ${manfile}
224 set(MAN_FILES ${MAN_FILES} ${gzfile})
226 # figure out in what section to install to from filename
227 string(REGEX REPLACE "^.*\\.([0-9])\\.gz\$" "\\1" section ${gzfile})
228 set(AWE_MAN${section}_FILES ${AWE_MAN${section}_FILES} ${gzfile})
231 add_custom_target(man ALL DEPENDS ${MAN_FILES})
236 if(DOXYGEN_EXECUTABLE)
237 add_custom_target(doc
238 COMMAND ${DOXYGEN_EXECUTABLE} awesome.doxygen
239 WORKING_DIRECTORY ${BUILD_DIR})
243 # {{{ Lua API Documentation
246 set(capi_lua ${BUILD_DIR}/lib/capi.lua)
248 if(NOT BUILD_DIR STREQUAL SOURCE_DIR)
249 file(MAKE_DIRECTORY ${BUILD_DIR}/lib)
250 # setup symlink so everything is in one directory
251 foreach(lua_file ${AWE_LUA_FILES})
252 execute_process(COMMAND ${LN_EXECUTABLE} -s -f ${lua_file}
253 WORKING_DIRECTORY ${BUILD_DIR}/lib)
257 # {{{ setup a command for ${capi_lua}
258 macro(a_file_match infile regex result_var)
259 if(CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION LESS 6)
260 # cmake < 2.6 doesn't know FILE(STRINGS ...)
262 COMMAND ${GREP_EXECUTABLE} -l ${regex} ${infile}
263 RESULT_VARIABLE exit_code
265 if(exit_code EQUAL 0)
266 set(${result_var} TRUE)
268 set(${result_var} FALSE)
271 file(STRINGS ${infile} match REGEX ${regex} LIMIT_COUNT 1)
273 set(${result_var} TRUE)
275 set(${result_var} FALSE)
280 set(luadoc_c_srcs "")
282 # find .c files exporting lua functions
283 foreach(cfile ${AWE_SRCS})
284 a_file_match(${cfile} "const struct luaL_reg" result)
286 set(luadoc_c_srcs ${luadoc_c_srcs} ${cfile})
288 a_file_match(${cfile} "luaA_.*_index" result)
290 set(luadoc_c_srcs ${luadoc_c_srcs} ${cfile})
295 # create fake lua source file to process by luadoc
297 COMMAND ${CAT_EXECUTABLE} ${luadoc_c_srcs}
298 | ${LUA_EXECUTABLE} ${SOURCE_DIR}/build-utils/fake-lua-src.lua
301 DEPENDS ${luadoc_c_srcs}
302 COMMENT "Generating fake lua source."
306 # dont include full path names in documentation
307 foreach(filename ${AWE_LUA_FILES} ${capi_lua} ${awful_lua})
308 get_filename_component(filename ${filename} NAME)
309 set(luadoc_srcs ${luadoc_srcs} ${filename})
312 add_custom_target(luadoc ALL
313 COMMAND ${LUADOC_EXECUTABLE} ${luadoc_srcs} -d ${BUILD_DIR}/luadoc
314 WORKING_DIRECTORY ${BUILD_DIR}/lib
315 DEPENDS ${AWE_LUA_FILES} ${capi_lua} ${awful_lua})
319 # {{{ Compile Lua libs
321 foreach(luafile ${AWE_LUA_FILES})
322 string(REGEX REPLACE ".lua\$" ".luac" luacfile ${luafile})
323 string(REPLACE ${SOURCE_DIR} ${BUILD_DIR} luacfile ${luacfile})
326 COMMAND ${LUAC_EXECUTABLE} -o ${luacfile} ${luafile}
330 set(AWE_LUAC_FILES ${AWE_LUAC_FILES} ${luacfile})
333 # Special case for awful.lua
334 string(REGEX REPLACE ".lua\$" ".luac" luacfile ${awful_lua})
336 COMMAND ${LUAC_EXECUTABLE} -o ${luacfile} ${awful_lua}
338 DEPENDS ${awful_lua})
340 set(AWE_LUAC_FILES ${AWE_LUAC_FILES} ${luacfile})
342 if(NOT EXISTS ${BUILD_DIR}/lib)
343 FILE(MAKE_DIRECTORY ${BUILD_DIR}/lib)
346 add_custom_target(compile_lua ALL DEPENDS ${AWE_LUAC_FILES})
352 add_custom_target(dist
353 COMMAND ${SOURCE_DIR}/build-utils/dist.sh ${VERSION}
354 WORKING_DIRECTORY ${SOURCE_DIR})
359 install(TARGETS ${PROJECT_AWE_NAME} ${PROJECT_AWECLIENT_NAME} RUNTIME DESTINATION bin)
360 install(FILES ${AWE_LUA_FILES} ${awful_lua} ${AWE_LUAC_FILES} DESTINATION ${AWESOME_LUA_LIB_PATH})
361 install(FILES ${AWE_CONF_FILE_DEFAULT} DESTINATION ${AWESOME_SYSCONFDIR}
362 RENAME ${AWE_CONF_FILE})
363 if(GENERATE_MANPAGES)
364 install(FILES ${AWE_MAN1_FILES} DESTINATION ${AWESOME_MAN_PATH}/man1)
365 install(FILES ${AWE_MAN5_FILES} DESTINATION ${AWESOME_MAN_PATH}/man5)
367 install(DIRECTORY ${AWE_ICON_DIR} DESTINATION ${AWESOME_DATA_PATH})
368 install(DIRECTORY ${AWE_THEMES_DIR} DESTINATION ${AWESOME_DATA_PATH})
369 install(FILES ${AWE_DOC_FILES} DESTINATION ${AWESOME_DOC_PATH})
370 install(FILES "awesome.desktop" DESTINATION ${AWESOME_XSESSION_PATH})
372 install(DIRECTORY ${BUILD_DIR}/luadoc DESTINATION ${AWESOME_DOC_PATH})
376 # vim: filetype=cmake:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80