1 cmake_minimum_required(VERSION 2.8.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}/banning.c
46 ${SOURCE_DIR}/keygrabber.c
47 ${SOURCE_DIR}/keyresolv.c
50 ${SOURCE_DIR}/mousegrabber.c
51 ${SOURCE_DIR}/property.c
53 ${SOURCE_DIR}/screen.c
54 ${SOURCE_DIR}/selection.c
58 ${SOURCE_DIR}/systray.c
59 ${SOURCE_DIR}/xwindow.c
60 ${SOURCE_DIR}/common/atoms.c
61 ${SOURCE_DIR}/common/backtrace.c
62 ${SOURCE_DIR}/common/buffer.c
63 ${SOURCE_DIR}/common/luaclass.c
64 ${SOURCE_DIR}/common/lualib.c
65 ${SOURCE_DIR}/common/luaobject.c
66 ${SOURCE_DIR}/common/util.c
67 ${SOURCE_DIR}/common/version.c
68 ${SOURCE_DIR}/common/xcursor.c
69 ${SOURCE_DIR}/common/xembed.c
70 ${SOURCE_DIR}/common/xutil.c
71 ${SOURCE_DIR}/objects/button.c
72 ${SOURCE_DIR}/objects/client.c
73 ${SOURCE_DIR}/objects/drawin.c
74 ${SOURCE_DIR}/objects/key.c
75 ${SOURCE_DIR}/objects/tag.c
76 ${SOURCE_DIR}/objects/timer.c
77 ${SOURCE_DIR}/objects/window.c)
80 ${SOURCE_DIR}/manpages/awesome.1.txt
81 ${SOURCE_DIR}/manpages/awesome-client.1.txt
82 ${SOURCE_DIR}/manpages/awesomerc.5.txt)
83 set(AWE_MAN_LANGS it es fr de ru)
85 # Don't strip RPATH if compiling on Solaris
86 if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
87 set(CMAKE_SKIP_BUILD_RPATH FALSE)
88 set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
89 set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
92 add_executable(${PROJECT_AWE_NAME}
95 set_target_properties(${PROJECT_AWE_NAME}
97 LINK_FLAGS -export-dynamic)
99 target_link_libraries(${PROJECT_AWE_NAME}
100 ${AWESOME_COMMON_REQUIRED_LDFLAGS}
101 ${AWESOME_REQUIRED_LDFLAGS}
102 ${AWESOME_OPTIONAL_LDFLAGS})
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"
124 add_custom_target(generated_sources
125 DEPENDS ${BUILD_DIR}/common/atoms-intern.h
126 ${BUILD_DIR}/common/atoms-extern.h)
128 # Default theme directory
129 file(MAKE_DIRECTORY ${BUILD_DIR}/themes/default)
130 file(MAKE_DIRECTORY ${BUILD_DIR}/themes/sky)
131 file(MAKE_DIRECTORY ${BUILD_DIR}/themes/zenburn)
132 add_dependencies(${PROJECT_AWE_NAME} generated_sources)
137 add_custom_target(version_stamp ALL
138 COMMAND ${SOURCE_DIR}/build-utils/git-version-stamp.sh
139 ${VERSION_STAMP_FILE}
140 ${BUILD_DIR}/awesome-version-internal.h
141 WORKING_DIRECTORY ${SOURCE_DIR})
143 add_dependencies(${PROJECT_AWE_NAME} version_stamp)
148 if(GENERATE_MANPAGES)
149 if(NOT BUILD_DIR STREQUAL SOURCE_DIR)
150 file(MAKE_DIRECTORY ${BUILD_DIR}/manpages)
153 # add the default translation to the list of languages
154 set(AWE_MAN_LANGS default ${AWE_MAN_LANGS})
156 foreach(lang ${AWE_MAN_LANGS})
158 foreach(txtfile ${AWE_MAN_SRCS})
159 # figure the base name of the file (ie "awesome.1")
160 GET_FILENAME_COMPONENT(tmpname ${txtfile} NAME)
161 string(REGEX REPLACE ".txt\$" "" basename ${tmpname})
163 # figure the relative path of the file
164 GET_FILENAME_COMPONENT(tmppath ${txtfile} PATH)
165 string(REPLACE ${SOURCE_DIR}/ "" relpath ${tmppath})
167 # figure the manpage section to install to from filename
168 string(REGEX REPLACE "^.*\\.([0-9])$" "\\1" section ${basename})
170 # construct the language specific versions of the basename and path
171 if (lang STREQUAL default)
172 set(basename2 ${basename})
173 set(relpath2 ${relpath}/man${section})
175 set(basename2 ${basename}.${lang})
176 set(relpath2 ${relpath}/${lang}/man${section})
179 # create the build directory (if it does not exist)
180 file(MAKE_DIRECTORY ${BUILD_DIR}/${relpath2})
182 # set the final filenames
183 set(txtfile ${SOURCE_DIR}/${relpath}/${basename2}.txt)
184 set(xmlfile ${BUILD_DIR}/${relpath2}/${basename}.xml)
185 set(gzfile ${BUILD_DIR}/${relpath2}/${basename}.gz)
186 set(manfile ${BUILD_DIR}/${relpath2}/${basename})
189 COMMAND ${ASCIIDOC_EXECUTABLE} -d manpage -b docbook -o ${xmlfile} - < ${txtfile}
190 WORKING_DIRECTORY ${BUILD_DIR}/${relpath2}
195 COMMAND ${XMLTO_EXECUTABLE} man ${xmlfile}
197 WORKING_DIRECTORY ${BUILD_DIR}/${relpath2}
200 if(COMPRESS_MANPAGES)
202 COMMAND ${GZIP_EXECUTABLE} < ${manfile} > ${gzfile}
204 WORKING_DIRECTORY ${BUILD_DIR}/${relpath2}
208 set(MAN_FILES ${MAN_FILES} ${gzfile})
210 set(MAN_FILES ${MAN_FILES} ${manfile})
216 add_custom_target(man ALL DEPENDS ${MAN_FILES})
221 if(DOXYGEN_EXECUTABLE)
222 add_custom_target(doc
223 COMMAND ${DOXYGEN_EXECUTABLE} awesome.doxygen
224 WORKING_DIRECTORY ${BUILD_DIR})
228 # {{{ Lua API Documentation
231 if(NOT BUILD_DIR STREQUAL SOURCE_DIR)
232 file(MAKE_DIRECTORY ${BUILD_DIR}/lib)
235 set(luadoc_c_srcs "")
237 # Generate documentation of lib//0lua
238 file(GLOB_RECURSE lua_lib_files ${BUILD_DIR}/lib/*.lua
239 ${SOURCE_DIR}/luadoc/*.lua)
240 foreach(filename ${lua_lib_files})
241 file(RELATIVE_PATH filename ${BUILD_DIR} ${filename})
242 set(luadoc_srcs ${luadoc_srcs} ${filename})
245 add_custom_target(luadoc ALL
246 COMMAND ${LUADOC_EXECUTABLE} ${luadoc_srcs} -d ${BUILD_DIR}/luadoc --nofiles
247 WORKING_DIRECTORY ${BUILD_DIR}
248 DEPENDS ${AWE_LUA_FILES})
253 file(GLOB icon_sources RELATIVE ${SOURCE_DIR} ${SOURCE_DIR}/themes/*/titlebar/*.png)
255 foreach(icon ${icon_sources})
256 # Copy all icons to the build dir to simplify the following code.
257 # Source paths are interpreted relative to ${SOURCE_DIR}, target paths
258 # relative to ${BUILD_DIR}.
259 get_filename_component(icon_path ${icon} PATH)
260 get_filename_component(icon_name ${icon} NAME)
261 file(COPY ${icon} DESTINATION ${icon_path})
262 set(ALL_ICONS ${ALL_ICONS} "${icon_path}/${icon_name}")
265 macro(a_icon_convert match replacement input)
266 string(REPLACE ${match} ${replacement} output ${input})
268 if(NOT ${input} STREQUAL ${output})
269 set(ALL_ICONS ${ALL_ICONS} ${output})
272 COMMAND ${CONVERT_EXECUTABLE} ${input} ${ARGN} ${output}
279 foreach(icon ${ALL_ICONS})
280 # Make unfocused icons translucent
281 a_icon_convert("_focus" "_normal" ${icon}
282 -gamma 0.6 -channel A -evaluate Multiply 0.4)
285 foreach(icon ${ALL_ICONS})
286 # Make inactive icons grayscale
287 a_icon_convert("_active" "_inactive" ${icon}
291 add_custom_target(generated_icons ALL DEPENDS ${ALL_ICONS})
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} RUNTIME DESTINATION bin)
304 install(FILES "utils/awesome-client" 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 PATTERN "*.in" EXCLUDE)
307 install(FILES ${AWE_CONF_FILE_DEFAULT} DESTINATION ${AWESOME_SYSCONFDIR}
308 RENAME ${AWE_CONF_FILE})
309 if(GENERATE_MANPAGES)
310 if(COMPRESS_MANPAGES)
311 set(regex "\\.(xml|txt|[0-9])$")
313 set(regex "\\.(xml|txt|gz)$")
315 install(DIRECTORY ${BUILD_DIR}/${relpath}/ DESTINATION ${AWESOME_MAN_PATH}
316 REGEX ${regex} EXCLUDE )
318 install(DIRECTORY ${AWE_ICON_DIR} DESTINATION ${AWESOME_DATA_PATH})
319 install(DIRECTORY ${BUILD_DIR}/themes DESTINATION ${AWESOME_DATA_PATH}
320 PATTERN "*.in" EXCLUDE)
321 install(DIRECTORY ${SOURCE_DIR}/themes DESTINATION ${AWESOME_DATA_PATH}
322 PATTERN "*.in" EXCLUDE)
323 install(FILES ${AWE_DOC_FILES} DESTINATION ${AWESOME_DOC_PATH})
324 install(FILES "awesome.desktop" DESTINATION ${AWESOME_XSESSION_PATH})
326 install(DIRECTORY ${BUILD_DIR}/luadoc DESTINATION ${AWESOME_DOC_PATH})
330 # vim: filetype=cmake:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80