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