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)
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)
37 ${SOURCE_DIR}/LICENSE)
40 ${SOURCE_DIR}/awesome.c
41 ${SOURCE_DIR}/client.c
45 ${SOURCE_DIR}/property.c
47 ${SOURCE_DIR}/keybinding.c
49 ${SOURCE_DIR}/keygrabber.c
50 ${SOURCE_DIR}/mousegrabber.c
51 ${SOURCE_DIR}/layout.c
55 ${SOURCE_DIR}/screen.c
57 ${SOURCE_DIR}/selection.c
59 ${SOURCE_DIR}/systray.c
61 ${SOURCE_DIR}/titlebar.c
62 ${SOURCE_DIR}/widget.c
63 ${SOURCE_DIR}/window.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)
82 ${SOURCE_DIR}/awesome-client.c
83 ${SOURCE_DIR}/common/socket.c
84 ${SOURCE_DIR}/common/util.c
85 ${SOURCE_DIR}/common/version.c)
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}
95 ${BUILD_DIR}/common/tokenize.c)
97 add_executable(${PROJECT_AWECLIENT_NAME}
99 ${BUILD_DIR}/common/tokenize.c)
101 set_target_properties(${PROJECT_AWE_NAME}
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
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"
125 file(MAKE_DIRECTORY ${BUILD_DIR}/common)
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"
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"
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")
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)
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)
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})
200 COMMAND ${CAT_EXECUTABLE} ${txtfile}
201 | ${ASCIIDOC_EXECUTABLE} -d manpage -b docbook -o ${xmlfile} -
202 WORKING_DIRECTORY ${BUILD_DIR}
207 COMMAND ${XMLTO_EXECUTABLE} man ${xmlfile}
211 COMMAND ${CAT_EXECUTABLE} ${manfile}
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})
225 add_custom_target(man ALL DEPENDS ${MAN_FILES})
230 if(DOXYGEN_EXECUTABLE)
231 add_custom_target(doc
232 COMMAND ${DOXYGEN_EXECUTABLE} awesome.doxygen
233 WORKING_DIRECTORY ${BUILD_DIR})
237 # {{{ Lua API Documentation
240 set(capi_lua ${BUILD_DIR}/lib/capi.lua)
242 if(NOT BUILD_DIR STREQUAL SOURCE_DIR)
243 file(MAKE_DIRECTORY ${BUILD_DIR}/lib)
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)
250 set(${result_var} TRUE)
252 set(${result_var} FALSE)
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)
262 set(luadoc_c_srcs ${luadoc_c_srcs} ${cfile})
264 a_file_match(${cfile} "luaA_.*_index" result)
266 set(luadoc_c_srcs ${luadoc_c_srcs} ${cfile})
271 # create fake lua source file to process by luadoc
273 COMMAND ${CAT_EXECUTABLE} ${luadoc_c_srcs}
274 | ${LUA_EXECUTABLE} ${SOURCE_DIR}/build-utils/fake-lua-src.lua
277 DEPENDS ${luadoc_c_srcs}
278 COMMENT "Generating fake lua source."
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})
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})
298 add_custom_target(dist
299 COMMAND ${SOURCE_DIR}/build-utils/dist.sh ${VERSION}
300 WORKING_DIRECTORY ${SOURCE_DIR})
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)
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})
321 install(DIRECTORY ${BUILD_DIR}/luadoc DESTINATION ${AWESOME_DOC_PATH})
325 # vim: filetype=cmake:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80