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
48 ${SOURCE_DIR}/keygrabber.c
49 ${SOURCE_DIR}/mousegrabber.c
50 ${SOURCE_DIR}/layout.c
54 ${SOURCE_DIR}/screen.c
57 ${SOURCE_DIR}/systray.c
59 ${SOURCE_DIR}/titlebar.c
60 ${SOURCE_DIR}/widget.c
61 ${SOURCE_DIR}/window.c
64 ${SOURCE_DIR}/swindow.c
65 ${SOURCE_DIR}/common/buffer.c
66 ${SOURCE_DIR}/common/atoms.c
67 ${SOURCE_DIR}/common/socket.c
68 ${SOURCE_DIR}/common/util.c
69 ${SOURCE_DIR}/common/version.c
70 ${SOURCE_DIR}/common/xembed.c
71 ${SOURCE_DIR}/common/xutil.c
72 ${SOURCE_DIR}/common/xcursor.c
73 ${SOURCE_DIR}/widgets/graph.c
74 ${SOURCE_DIR}/widgets/progressbar.c
75 ${SOURCE_DIR}/widgets/textbox.c
76 ${SOURCE_DIR}/widgets/systray.c
77 ${SOURCE_DIR}/widgets/imagebox.c)
80 ${SOURCE_DIR}/awesome-client.c
81 ${SOURCE_DIR}/common/socket.c
82 ${SOURCE_DIR}/common/util.c
83 ${SOURCE_DIR}/common/version.c)
86 ${SOURCE_DIR}/awesome.1.txt
87 ${SOURCE_DIR}/awsetbg.1.txt
88 ${SOURCE_DIR}/awesome-client.1.txt
89 ${SOURCE_DIR}/awesomerc.5.txt)
91 add_executable(${PROJECT_AWE_NAME}
93 ${BUILD_DIR}/common/tokenize.c)
95 add_executable(${PROJECT_AWECLIENT_NAME}
97 ${BUILD_DIR}/common/tokenize.c)
99 set_target_properties(${PROJECT_AWE_NAME}
101 LINK_FLAGS -export-dynamic)
103 target_link_libraries(${PROJECT_AWE_NAME}
104 ${AWESOME_COMMON_REQUIRED_LIBRARIES}
105 ${AWESOME_REQUIRED_LIBRARIES}
106 ${AWESOME_OPTIONAL_LIBRARIES})
108 target_link_libraries(${PROJECT_AWECLIENT_NAME}
109 ${AWESOME_COMMON_REQUIRED_LIBRARIES}
110 ${AWESOMECLIENT_LIBRARIES})
112 # {{{ Generated sources
114 COMMAND ${SOURCE_DIR}/build-utils/widgetgen.sh
115 ARGS > ${BUILD_DIR}/widgetgen.h
116 OUTPUT ${BUILD_DIR}/widgetgen.h
117 WORKING_DIRECTORY ${SOURCE_DIR}
118 DEPENDS ${SOURCE_DIR}/widget.h
119 COMMENT "Generating widgetgen.h"
123 file(MAKE_DIRECTORY ${BUILD_DIR}/common)
125 COMMAND ${SOURCE_DIR}/build-utils/atoms-ext.sh ${SOURCE_DIR}/common/atoms.list
126 ARGS > ${BUILD_DIR}/common/atoms-extern.h
127 OUTPUT ${BUILD_DIR}/common/atoms-extern.h
128 WORKING_DIRECTORY ${SOURCE_DIR}
129 DEPENDS ${SOURCE_DIR}/common/atoms.list
130 COMMENT "Generating atoms-extern.h"
134 COMMAND ${SOURCE_DIR}/build-utils/atoms-int.sh ${SOURCE_DIR}/common/atoms.list
135 ARGS > ${BUILD_DIR}/common/atoms-intern.h
136 OUTPUT ${BUILD_DIR}/common/atoms-intern.h
137 WORKING_DIRECTORY ${SOURCE_DIR}
138 DEPENDS ${SOURCE_DIR}/common/atoms.list
139 COMMENT "Generating atoms-intern.h"
144 COMMAND ${SOURCE_DIR}/build-utils/gperf.sh
145 ARGS ${SOURCE_DIR}/common/tokenize.gperf
146 ${BUILD_DIR}/common/tokenize.h
147 OUTPUT ${BUILD_DIR}/common/tokenize.h
148 DEPENDS ${SOURCE_DIR}/common/tokenize.gperf
149 ${SOURCE_DIR}/build-utils/gperf.sh
150 COMMENT "Generating common/tokenize.h")
153 COMMAND ${SOURCE_DIR}/build-utils/gperf.sh
154 ARGS ${SOURCE_DIR}/common/tokenize.gperf
155 ${BUILD_DIR}/common/tokenize.c
156 OUTPUT ${BUILD_DIR}/common/tokenize.c
157 DEPENDS ${SOURCE_DIR}/common/tokenize.gperf
158 ${SOURCE_DIR}/build-utils/gperf.sh
159 COMMENT "Generating common/tokenize.c")
161 add_custom_target(generated_sources
162 DEPENDS ${BUILD_DIR}/widgetgen.h
163 ${BUILD_DIR}/common/atoms-intern.h
164 ${BUILD_DIR}/common/atoms-extern.h
165 ${BUILD_DIR}/common/tokenize.c
166 ${BUILD_DIR}/common/tokenize.h)
168 # Default theme directory
169 file(MAKE_DIRECTORY ${BUILD_DIR}/themes/default)
170 file(MAKE_DIRECTORY ${BUILD_DIR}/themes/sky)
171 add_dependencies(${PROJECT_AWE_NAME} generated_sources)
172 add_dependencies(${PROJECT_AWECLIENT_NAME} generated_sources)
177 add_custom_target(version_stamp ALL
178 COMMAND ${SOURCE_DIR}/build-utils/git-version-stamp.sh
179 ${VERSION_STAMP_FILE}
180 ${BUILD_DIR}/awesome-version-internal.h
181 WORKING_DIRECTORY ${SOURCE_DIR})
183 add_dependencies(${PROJECT_AWE_NAME} version_stamp)
184 add_dependencies(${PROJECT_AWECLIENT_NAME} version_stamp)
189 if(GENERATE_MANPAGES)
190 foreach(txtfile ${AWE_MAN_SRCS})
191 string(REGEX REPLACE ".txt\$" ".xml" xmlfile ${txtfile})
192 string(REPLACE ${SOURCE_DIR}
193 ${BUILD_DIR} xmlfile ${xmlfile})
194 string(REGEX REPLACE ".xml\$" ".gz" gzfile ${xmlfile})
195 string(REGEX REPLACE ".gz\$" "" manfile ${gzfile})
198 COMMAND ${CAT_EXECUTABLE} ${txtfile}
199 | ${ASCIIDOC_EXECUTABLE} -d manpage -b docbook -o ${xmlfile} -
200 WORKING_DIRECTORY ${BUILD_DIR}
205 COMMAND ${XMLTO_EXECUTABLE} man ${xmlfile}
209 COMMAND ${CAT_EXECUTABLE} ${manfile}
216 set(MAN_FILES ${MAN_FILES} ${gzfile})
218 # figure out in what section to install to from filename
219 string(REGEX REPLACE "^.*\\.([0-9])\\.gz\$" "\\1" section ${gzfile})
220 set(AWE_MAN${section}_FILES ${AWE_MAN${section}_FILES} ${gzfile})
223 add_custom_target(man ALL DEPENDS ${MAN_FILES})
228 if(DOXYGEN_EXECUTABLE)
229 add_custom_target(doc
230 COMMAND ${DOXYGEN_EXECUTABLE} awesome.doxygen
231 WORKING_DIRECTORY ${BUILD_DIR})
235 # {{{ Lua API Documentation
238 set(capi_lua ${BUILD_DIR}/lib/capi.lua)
240 if(NOT BUILD_DIR STREQUAL SOURCE_DIR)
241 file(MAKE_DIRECTORY ${BUILD_DIR}/lib)
244 # {{{ setup a command for ${capi_lua}
245 macro(a_file_match infile regex result_var)
246 file(STRINGS ${infile} match REGEX ${regex} LIMIT_COUNT 1)
248 set(${result_var} TRUE)
250 set(${result_var} FALSE)
254 set(luadoc_c_srcs "")
256 # find .c files exporting lua functions
257 foreach(cfile ${AWE_SRCS})
258 a_file_match(${cfile} "const struct luaL_reg" result)
260 set(luadoc_c_srcs ${luadoc_c_srcs} ${cfile})
262 a_file_match(${cfile} "luaA_.*_index" result)
264 set(luadoc_c_srcs ${luadoc_c_srcs} ${cfile})
269 # create fake lua source file to process by luadoc
271 COMMAND ${CAT_EXECUTABLE} ${luadoc_c_srcs}
272 | ${LUA_EXECUTABLE} ${SOURCE_DIR}/build-utils/fake-lua-src.lua
275 DEPENDS ${luadoc_c_srcs}
276 COMMENT "Generating fake lua source."
280 # Generate documentation of lib//0lua
281 file(GLOB_RECURSE lua_lib_files ${BUILD_DIR}/lib/*.lua)
282 foreach(filename ${lua_lib_files})
283 file(RELATIVE_PATH filename ${BUILD_DIR}/lib ${filename})
284 set(luadoc_srcs ${luadoc_srcs} ${filename})
287 add_custom_target(luadoc ALL
288 COMMAND ${LUADOC_EXECUTABLE} ${luadoc_srcs} -d ${BUILD_DIR}/luadoc
289 WORKING_DIRECTORY ${BUILD_DIR}/lib
290 DEPENDS ${AWE_LUA_FILES} ${capi_lua})
296 add_custom_target(dist
297 COMMAND ${SOURCE_DIR}/build-utils/dist.sh ${VERSION}
298 WORKING_DIRECTORY ${SOURCE_DIR})
303 install(TARGETS ${PROJECT_AWE_NAME} ${PROJECT_AWECLIENT_NAME} RUNTIME DESTINATION bin)
304 install(FILES "utils/awsetbg" DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
305 install(DIRECTORY ${BUILD_DIR}/lib DESTINATION ${AWESOME_DATA_PATH})
306 install(FILES ${AWE_CONF_FILE_DEFAULT} DESTINATION ${AWESOME_SYSCONFDIR}
307 RENAME ${AWE_CONF_FILE})
308 if(GENERATE_MANPAGES)
309 install(FILES ${AWE_MAN1_FILES} DESTINATION ${AWESOME_MAN_PATH}/man1)
310 install(FILES ${AWE_MAN5_FILES} DESTINATION ${AWESOME_MAN_PATH}/man5)
312 install(DIRECTORY ${AWE_ICON_DIR} DESTINATION ${AWESOME_DATA_PATH})
313 install(DIRECTORY ${BUILD_DIR}/themes DESTINATION ${AWESOME_DATA_PATH})
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})
319 install(DIRECTORY ${BUILD_DIR}/luadoc DESTINATION ${AWESOME_DOC_PATH})
323 # vim: filetype=cmake:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80