event: Prevent seeing banned clients on the visible screen.
[awesome.git] / awesomeConfig.cmake
blobe5af83be4c81901b03e145eb04346377b4dc48bb
1 set(PROJECT_AWE_NAME awesome)
2 set(PROJECT_AWECLIENT_NAME awesome-client)
4 # If ${SOURCE_DIR} is a git repository VERSION is set to
5 # `git describe` later.
6 set(VERSION devel)
8 set(CODENAME "Helicopter")
10 project(${PROJECT_AWE_NAME} C)
12 set(CMAKE_BUILD_TYPE RELEASE)
14 set(CURSES_NEED_NCURSES true)
16 option(WITH_DBUS "build with D-BUS" ON)
17 option(GENERATE_MANPAGES "generate manpages" ON)
18 option(GENERATE_LUADOC "generate luadoc" ON)
20 link_directories(/usr/local/lib)
22 # {{{ CFLAGS
23 add_definitions(-std=gnu99 -ggdb3 -fno-strict-aliasing -Wall -Wextra
24     -Wchar-subscripts -Wundef -Wshadow -Wcast-align -Wwrite-strings
25     -Wsign-compare -Wunused -Wno-unused-parameter -Wuninitialized -Winit-self
26     -Wpointer-arith -Wredundant-decls -Wformat-nonliteral
27     -Wno-format-zero-length -Wmissing-format-attribute -Wmissing-prototypes
28     -Wstrict-prototypes)
29 # }}}
31 # {{{ Find external utilities
32 macro(a_find_program var prg req)
33     set(required ${req})
34     find_program(${var} ${prg})
35     if(NOT ${var})
36         message(STATUS "${prg} not found.")
37         if(required)
38             message(FATAL_ERROR "${prg} is required to build awesome")
39         endif()
40     else()
41         message(STATUS "${prg} -> ${${var}}")
42     endif()
43 endmacro()
45 a_find_program(CAT_EXECUTABLE cat TRUE)
46 a_find_program(LN_EXECUTABLE ln TRUE)
47 a_find_program(GREP_EXECUTABLE grep TRUE)
48 a_find_program(GIT_EXECUTABLE git FALSE)
49 a_find_program(HOSTNAME_EXECUTABLE hostname FALSE)
50 a_find_program(GPERF_EXECUTABLE gperf TRUE)
51 # programs needed for man pages
52 a_find_program(ASCIIDOC_EXECUTABLE asciidoc FALSE)
53 a_find_program(XMLTO_EXECUTABLE xmlto FALSE)
54 a_find_program(GZIP_EXECUTABLE gzip FALSE)
55 # lua documentation
56 a_find_program(LUA_EXECUTABLE lua FALSE)
57 a_find_program(LUADOC_EXECUTABLE luadoc FALSE)
58 # doxygen
59 include(FindDoxygen)
60 # pkg-config
61 include(FindPkgConfig)
62 # ncurses
63 include(FindCurses)
64 # lua 5.1
65 include(FindLua51) #Due to a cmake bug, you will see Lua50 on screen
66 # }}}
68 # {{{ Check if documentation can be build
69 if(GENERATE_MANPAGES)
70     if(NOT ASCIIDOC_EXECUTABLE OR NOT XMLTO_EXECUTABLE OR NOT GZIP_EXECUTABLE)
71         if(NOT ASCIIDOC_EXECUTABLE)
72             SET(missing "asciidoc")
73         endif()
74         if(NOT XMLTO_EXECUTABLE)
75             SET(missing ${missing} " xmlto")
76         endif()
77         if(NOT GZIP_EXECUTABLE)
78             SET(missing ${missing} " gzip")
79         endif()
81         message(STATUS "Not generating manpages. Missing: " ${missing})
82         set(GENERATE_MANPAGES OFF)
83     endif()
84 endif()
86 if(GENERATE_LUADOC)
87     if(NOT LUADOC_EXECUTABLE)
88         message(STATUS "Not generating luadoc. Missing: luadoc")
89         set(GENERATE_LUADOC OFF)
90     endif()
91 endif()
92 # }}}
94 # {{{ Version stamp
95 if(EXISTS ${SOURCE_DIR}/.git/HEAD AND GIT_EXECUTABLE)
96     # get current version
97     execute_process(
98         COMMAND ${GIT_EXECUTABLE} describe
99         WORKING_DIRECTORY ${SOURCE_DIR}
100         OUTPUT_VARIABLE VERSION
101         OUTPUT_STRIP_TRAILING_WHITESPACE)
102     # file the git-version-stamp.sh script will look into
103     set(VERSION_STAMP_FILE ${BUILD_DIR}/.version_stamp)
104     file(WRITE ${VERSION_STAMP_FILE} ${VERSION})
105     # create a version_stamp target later
106     set(BUILD_FROM_GIT TRUE)
107 elseif( EXISTS ${SOURCE_DIR}/.version_stamp )
108     # get version from version stamp
109     file(READ ${SOURCE_DIR}/.version_stamp VERSION)
110 endif()
111 # }}}
113 # {{{ Get hostname
114 execute_process(
115     COMMAND ${HOSTNAME_EXECUTABLE}
116     WORKING_DIRECTORY ${SOURCE_DIR}
117     OUTPUT_VARIABLE BUILDHOSTNAME
118     OUTPUT_STRIP_TRAILING_WHITESPACE)
119 # }}}
121 # {{{ Required libraries
123 # this sets up:
124 # AWESOME_REQUIRED_LIBRARIES
125 # AWESOME_REQUIRED_INCLUDE_DIRS
126 # AWESOMECLIENT_LIBRARIES
128 # Use pkgconfig to get most of the libraries
129 pkg_check_modules(AWESOME_COMMON_REQUIRED REQUIRED
130     xcb>=1.1)
132 pkg_check_modules(AWESOME_REQUIRED REQUIRED
133     glib-2.0
134     cairo
135     pango>=1.19.3
136     pangocairo>=1.19.3
137     x11-xcb
138     xcb-randr
139     xcb-xtest
140     xcb-xinerama
141     xcb-event>=0.3.0
142     xcb-aux>=0.3.0
143     xcb-atom>=0.3.0
144     xcb-keysyms>=0.3.0
145     xcb-icccm>=0.3.3
146     xcb-image>=0.3.0
147     xcb-property>=0.3.0
148     cairo-xcb
149     xproto>=7.0.11
150     imlib2)
152 if(NOT AWESOME_REQUIRED_FOUND OR NOT AWESOME_COMMON_REQUIRED_FOUND)
153     message(FATAL_ERROR)
154 endif()
156 macro(a_find_library variable library)
157     find_library(${variable} ${library})
158     if(NOT ${variable})
159         message(FATAL_ERROR ${library} " library not found.")
160     endif()
161 endmacro()
163 # Check for readline, ncurse and libev
164 a_find_library(LIB_READLINE readline)
165 a_find_library(LIB_EV ev)
167 # Error check
168 if(NOT LUA51_FOUND AND NOT LUA50_FOUND) # This is a workaround to a cmake bug
169     message(FATAL_ERROR "lua library not found")
170 endif()
172 set(AWESOME_REQUIRED_LIBRARIES
173     ${AWESOME_COMMON_REQUIRED_LIBRARIES}
174     ${AWESOME_REQUIRED_LIBRARIES}
175     ${LIB_EV}
176     ${LUA_LIBRARIES})
178 set(AWESOME_REQUIRED_INCLUDE_DIRS
179     ${AWESOME_COMMON_REQUIRED_INCLUDE_DIRS}
180     ${AWESOME_REQUIRED_INCLUDE_DIRS}
181     ${LUA_INCLUDE_DIR})
183 set(AWESOMECLIENT_LIBRARIES
184     ${AWESOME_COMMON_REQUIRED_LIBRARIES}
185     ${LIB_READLINE}
186     ${LIB_XCB}
187     ${CURSES_LIBRARIES})
189 set(AWESOMECLIENT_REQUIRED_INCLUDE_DIRS
190     ${AWESOME_COMMON_REQUIRED_INCLUDE_DIRS})
191 # }}}
193 # {{{ Optional libraries
195 # this sets up:
196 # AWESOME_OPTIONAL_LIBRARIES
197 # AWESOME_OPTIONAL_INCLUDE_DIRS
199 if(WITH_DBUS)
200     pkg_check_modules(DBUS dbus-1)
201     if(DBUS_FOUND)
202         set(AWESOME_OPTIONAL_LIBRARIES ${AWESOME_OPTIONAL_LIBRARIES} ${DBUS_LIBRARIES})
203         set(AWESOME_OPTIONAL_INCLUDE_DIRS ${AWESOME_OPTIONAL_INCLUDE_DIRS} ${DBUS_INCLUDE_DIRS})
204     else()
205         set(WITH_DBUS OFF)
206         message(STATUS "DBUS not found. Disabled.")
207     endif()
208 endif()
209 # }}}
211 # {{{ Install path and configuration variables
212 if(DEFINED PREFIX)
213     set(PREFIX ${PREFIX} CACHE PATH "install prefix")
214     set(CMAKE_INSTALL_PREFIX ${PREFIX})
215 else()
216     set(PREFIX ${CMAKE_INSTALL_PREFIX} CACHE PATH "install prefix")
217 endif()
219 #If a sysconfdir is specified, use it instead
220 #of the default configuration dir.
221 if(DEFINED SYSCONFDIR)
222     set(SYSCONFDIR ${SYSCONFDIR} CACHE PATH "config directory")
223 else()
224     set(SYSCONFDIR /etc CACHE PATH "config directory")
225 endif()
227 #If an XDG Config Dir is specificed, use it instead
228 #of the default XDG configuration dir.
229 if(DEFINED XDG_CONFIG_DIR)
230     set(XDG_CONFIG_DIR ${XDG_CONFIG_SYS} CACHE PATH "xdg config directory")
231 else()
232     set(XDG_CONFIG_DIR ${SYSCONFDIR}/xdg CACHE PATH "xdg config directory")
233 endif()
235 # setting AWESOME_DOC_PATH
236 if(DEFINED AWESOME_DOC_PATH)
237     set(AWESOME_DOC_PATH ${AWESOME_DOC_PATH} CACHE PATH "awesome docs directory")
238 else()
239     set(AWESOME_DOC_PATH ${PREFIX}/share/doc/${PROJECT_AWE_NAME} CACHE PATH "awesome docs directory")
240 endif()
242 # setting AWESOME_XSESSION_PATH
243 if(DEFINED AWESOME_XSESSION_PATH)
244     set(AWESOME_XSESSION_PATH ${AWESOME_XSESSION_PATH} CACHE PATH "awesome xsessions directory")
245 else()
246     set(AWESOME_XSESSION_PATH ${PREFIX}/share/xsessions CACHE PATH "awesome xsessions directory")
247 endif()
249 # set man path
250 if(DEFINED AWESOME_MAN_PATH)
251    set(AWESOME_MAN_PATH ${AWESOME_MAN_PATH} CACHE PATH "awesome manpage directory")
252 else()
253    set(AWESOME_MAN_PATH ${PREFIX}/share/man CACHE PATH "awesome manpage directory")
254 endif()
256 # Hide to avoid confusion
257 mark_as_advanced(CMAKE_INSTALL_PREFIX)
259 set(AWESOME_VERSION          ${VERSION})
260 set(AWESOME_COMPILE_MACHINE  ${CMAKE_SYSTEM_PROCESSOR})
261 set(AWESOME_COMPILE_HOSTNAME ${BUILDHOSTNAME})
262 set(AWESOME_COMPILE_BY       $ENV{USER})
263 set(AWESOME_RELEASE          ${CODENAME})
264 set(AWESOME_SYSCONFDIR       ${XDG_CONFIG_DIR}/${PROJECT_AWE_NAME})
265 set(AWESOME_DATA_PATH        ${PREFIX}/share/${PROJECT_AWE_NAME})
266 set(AWESOME_LUA_LIB_PATH     ${AWESOME_DATA_PATH}/lib)
267 set(AWESOME_ICON_PATH        ${AWESOME_DATA_PATH}/icons)
268 set(AWESOME_THEMES_PATH      ${AWESOME_DATA_PATH}/themes)
269 # }}}
271 # {{{ Configure files
272 file(GLOB_RECURSE awesome_lua_configure_files RELATIVE ${SOURCE_DIR} ${SOURCE_DIR}/lib/*.lua.in)
273 set(AWESOME_CONFIGURE_FILES 
274     ${awesome_lua_configure_files}
275     config.h.in
276     awesomerc.lua.in
277     themes/default/theme.in
278     themes/sky/theme.in
279     awesome-version-internal.h.in
280     awesome.doxygen.in)
282 macro(a_configure_file file)
283     string(REGEX REPLACE ".in\$" "" outfile ${file})
284     message(STATUS "Configuring ${outfile}")
285     configure_file(${SOURCE_DIR}/${file}
286                    ${BUILD_DIR}/${outfile}
287                    ESCAPE_QUOTE
288                    @ONLY)
289 endmacro()
291 foreach(file ${AWESOME_CONFIGURE_FILES})
292     a_configure_file(${file})
293 endforeach()
294 #}}}
296 # vim: filetype=cmake:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80