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