build: fix theme installation (FS#263)
[awesome.git] / awesomeConfig.cmake
blob3d23c2344febef79ae5057b5e993d7e07e025d05
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 3-devel)
8 set(VERSION_MAJOR ${VERSION})
9 set(VERSION_MINOR 0)
10 set(VERSION_PATCH 0)
12 set(CODENAME "Wake Up Call")
14 project(${PROJECT_AWE_NAME} C)
16 set(CMAKE_BUILD_TYPE RELEASE)
18 option(WITH_DBUS "build with D-BUS" ON)
19 option(WITH_IMLIB2 "build with Imlib2" OFF)
20 option(GENERATE_MANPAGES "generate manpages" ON)
21 option(GENERATE_LUADOC "generate luadoc" ON)
23 # {{{ CFLAGS
24 add_definitions(-std=gnu99 -ggdb3 -fno-strict-aliasing -Wall -Wextra
25     -Wchar-subscripts -Wundef -Wshadow -Wcast-align -Wwrite-strings
26     -Wsign-compare -Wunused -Wno-unused-parameter -Wuninitialized -Winit-self
27     -Wpointer-arith -Wredundant-decls -Wformat-nonliteral
28     -Wno-format-zero-length -Wmissing-format-attribute -Wmissing-prototypes
29     -Wstrict-prototypes)
30 # }}}
32 # {{{ Find external utilities
33 macro(a_find_program var prg req)
34     set(required ${req})
35     find_program(${var} ${prg})
36     if(NOT ${var})
37         message(STATUS "${prg} not found.")
38         if(required)
39             message(FATAL_ERROR "${prg} is required to build awesome")
40         endif()
41     else()
42         message(STATUS "${prg} -> ${${var}}")
43     endif()
44 endmacro()
46 a_find_program(CAT_EXECUTABLE cat TRUE)
47 a_find_program(LN_EXECUTABLE ln TRUE)
48 a_find_program(GREP_EXECUTABLE grep TRUE)
49 a_find_program(GIT_EXECUTABLE git FALSE)
50 a_find_program(HOSTNAME_EXECUTABLE hostname FALSE)
51 a_find_program(GPERF_EXECUTABLE gperf TRUE)
52 a_find_program(LUAC_EXECUTABLE luac 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 # doxygen
61 include(FindDoxygen)
62 # pkg-config
63 include(FindPkgConfig)
64 # }}}
66 # {{{ Check if documentation can be build
67 if(GENERATE_MANPAGES)
68     if(NOT ASCIIDOC_EXECUTABLE OR NOT XMLTO_EXECUTABLE OR NOT GZIP_EXECUTABLE)
69         if(NOT ASCIIDOC_EXECUTABLE)
70             SET(missing "asciidoc")
71         endif()
72         if(NOT XMLTO_EXECUTABLE)
73             SET(missing ${missing} " xmlto")
74         endif()
75         if(NOT GZIP_EXECUTABLE)
76             SET(missing ${missing} " gzip")
77         endif()
79         message(STATUS "Not generating manpages. Missing: " ${missing})
80         set(GENERATE_MANPAGES OFF)
81     endif()
82 endif()
84 if(GENERATE_LUADOC)
85     if(NOT LUADOC_EXECUTABLE)
86         message(STATUS "Not generating luadoc. Missing: luadoc")
87         set(GENERATE_LUADOC OFF)
88     endif()
89 endif()
90 # }}}
92 # {{{ Version stamp
93 if(EXISTS ${SOURCE_DIR}/.git/HEAD AND GIT_EXECUTABLE)
94     # get current version
95     execute_process(
96         COMMAND ${GIT_EXECUTABLE} describe
97         WORKING_DIRECTORY ${SOURCE_DIR}
98         OUTPUT_VARIABLE VERSION
99         OUTPUT_STRIP_TRAILING_WHITESPACE)
100     # file the git-version-stamp.sh script will look into
101     set(VERSION_STAMP_FILE ${BUILD_DIR}/.version_stamp)
102     file(WRITE ${VERSION_STAMP_FILE} ${VERSION})
103     # create a version_stamp target later
104     set(BUILD_FROM_GIT TRUE)
105 elseif( EXISTS ${SOURCE_DIR}/.version_stamp )
106     # get version from version stamp
107     file(READ ${SOURCE_DIR}/.version_stamp VERSION)
108 endif()
109 # }}}
111 # {{{ Get hostname
113 execute_process(
114     COMMAND ${HOSTNAME_EXECUTABLE} -f
115     WORKING_DIRECTORY ${SOURCE_DIR}
116     OUTPUT_VARIABLE BUILDHOSTNAME
117     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_REQUIRED REQUIRED
130     glib-2.0
131     cairo
132     pango
133     xcb
134     xcb-event
135     xcb-randr
136     xcb-xinerama
137     xcb-aux
138     xcb-atom
139     xcb-keysyms
140     xcb-icccm
141     cairo-xcb)
143 if(NOT AWESOME_REQUIRED_FOUND)
144     message(FATAL_ERROR)
145 endif()
147 macro(a_find_library variable library)
148     find_library(${variable} ${library})
149     if(NOT ${variable})
150         message(FATAL_ERROR ${library} " library not found.")
151     endif()
152 endmacro()
154 # Check for readline, ncurse and libev
155 a_find_library(LIB_READLINE readline)
156 a_find_library(LIB_NCURSES ncurses)
157 a_find_library(LIB_EV ev)
159 # Check for lua5.1
160 find_path(LUA_INC_DIR lua.h
161     /usr/include
162     /usr/include/lua5.1
163     /usr/local/include/lua5.1)
165 find_library(LUA_LIB NAMES lua5.1 lua
166     /usr/lib
167     /usr/lib/lua
168     /usr/local/lib)
170 # Error check
171 if(NOT LUA_LIB)
172     message(FATAL_ERROR "lua library not found")
173 endif()
175 set(AWESOME_REQUIRED_LIBRARIES ${AWESOME_REQUIRED_LIBRARIES}
176     ${LIB_EV}
177     ${LUA_LIB})
179 set(AWESOME_REQUIRED_INCLUDE_DIRS ${AWESOME_REQUIRED_INCLUDE_DIRS}
180     ${LUA_INC_DIR})
182 set(AWESOMECLIENT_LIBRARIES
183     ${LIB_READLINE}
184     ${LIB_NCURSES})
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_LIBRARIES})
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()
204 if(WITH_IMLIB2)
205     pkg_check_modules(IMLIB2 imlib2)
206     if(IMLIB2_FOUND)
207         set(AWESOME_OPTIONAL_LIBRARIES ${AWESOME_OPTIONAL_LIBRARIES} ${IMLIB2_LIBRARIES})
208         set(AWESOME_OPTIONAL_INCLUDE_DIRS ${AWESOME_OPTIONAL_INCLUDE_DIRS} ${IMLIB2_INCLUDE_DIRS})
209     else()
210         set(WITH_IMLIB2 OFF)
211         message(STATUS "Imlib2 not found. Disabled.")
212     endif()
213 endif()
215 if(NOT WITH_IMLIB2)
216     pkg_check_modules(GDK_PIXBUF REQUIRED gdk-2.0>=2.2 gdk-pixbuf-2.0>=2.2)
217     if(GDK_PIXBUF_FOUND)
218         set(AWESOME_OPTIONAL_LIBRARIES ${AWESOME_OPTIONAL_LIBRARIES}
219             ${GDK_PIXBUF_LIBRARIES})
220         set(AWESOME_OPTIONAL_INCLUDE_DIRS ${AWESOME_OPTIONAL_INCLUDE_DIRS}
221             ${GDK_PIXBUF_INCLUDE_DIRS})
222     else()
223         message(FATAL_ERROR "GdkPixBuf not found.")
224     endif()
225 endif()
226 # }}}
228 # {{{ Install path and configuration variables
229 if(DEFINED PREFIX)
230     set(PREFIX ${PREFIX} CACHE PATH "install prefix")
231     set(CMAKE_INSTALL_PREFIX ${PREFIX})
232 else()
233     set(PREFIX ${CMAKE_INSTALL_PREFIX} CACHE PATH "install prefix")
234 endif()
236 #If a sysconfdir is specified, use it instead
237 #of the default configuration dir.
238 if(DEFINED SYSCONFDIR)
239     set(SYSCONFDIR ${SYSCONFDIR} CACHE PATH "config directory")
240 else()
241     set(SYSCONFDIR /etc CACHE PATH "config directory")
242 endif()
244 #If an XDG Config Dir is specificed, use it instead
245 #of the default XDG configuration dir.
246 if(DEFINED XDG_CONFIG_DIR)
247     set(XDG_CONFIG_DIR ${XDG_CONFIG_SYS} CACHE PATH "xdg config directory")
248 else()
249     set(XDG_CONFIG_DIR ${SYSCONFDIR}/xdg CACHE PATH "xdg config directory")
250 endif()
252 # setting AWESOME_DOC_PATH
253 if(DEFINED AWESOME_DOC_PATH)
254     set(AWESOME_DOC_PATH ${AWESOME_DOC_PATH} CACHE PATH "awesome docs directory")
255 else()
256     set(AWESOME_DOC_PATH ${PREFIX}/share/doc/${PROJECT_AWE_NAME} CACHE PATH "awesome docs directory")
257 endif()
259 # setting AWESOME_XSESSION_PATH
260 if(DEFINED AWESOME_XSESSION_PATH)
261     set(AWESOME_XSESSION_PATH ${AWESOME_XSESSION_PATH} CACHE PATH "awesome xsessions directory")
262 else()
263     set(AWESOME_XSESSION_PATH ${PREFIX}/share/xsessions CACHE PATH "awesome xsessions directory")
264 endif()
266 # set man path
267 if(DEFINED AWESOME_MAN_PATH)
268    set(AWESOME_MAN_PATH ${AWESOME_MAN_PATH} CACHE PATH "awesome manpage directory")
269 else()
270    set(AWESOME_MAN_PATH ${PREFIX}/share/man CACHE PATH "awesome manpage directory")
271 endif()
273 # Hide to avoid confusion
274 mark_as_advanced(CMAKE_INSTALL_PREFIX)
276 set(AWESOME_VERSION          ${VERSION})
277 set(AWESOME_COMPILE_MACHINE  ${CMAKE_SYSTEM_PROCESSOR})
278 set(AWESOME_COMPILE_HOSTNAME ${BUILDHOSTNAME})
279 set(AWESOME_COMPILE_BY       $ENV{USER})
280 set(AWESOME_RELEASE          ${CODENAME})
281 set(AWESOME_SYSCONFDIR       ${XDG_CONFIG_DIR}/${PROJECT_AWE_NAME})
282 set(AWESOME_DATA_PATH        ${PREFIX}/share/${PROJECT_AWE_NAME})
283 set(AWESOME_LUA_LIB_PATH     ${AWESOME_DATA_PATH}/lib)
284 set(AWESOME_ICON_PATH        ${AWESOME_DATA_PATH}/icons)
285 set(AWESOME_THEMES_PATH      ${AWESOME_DATA_PATH}/themes)
286 # }}}
288 # {{{ Configure files
289 set(AWESOME_CONFIGURE_FILES
290     config.h.in
291     awesomerc.lua.in
292     themes/default.in
293     lib/awful.lua.in
294     awesome-version-internal.h.in
295     awesome.doxygen.in)
297 macro(a_configure_file file)
298     string(REGEX REPLACE ".in\$" "" outfile ${file})
299     message(STATUS "Configuring ${outfile}")
300     configure_file(${SOURCE_DIR}/${file}
301                    ${BUILD_DIR}/${outfile}
302                    ESCAPE_QUOTE
303                    @ONLY)
304 endmacro()
306 foreach(file ${AWESOME_CONFIGURE_FILES})
307     a_configure_file(${file})
308 endforeach()
309 #}}}
311 # {{{ CPack configuration
312 SET(CPACK_SET_DESTDIR                  TRUE)
313 set(CPACK_PACKAGE_NAME                 "${PROJECT_AWE_NAME}")
314 set(CPACK_GENERATOR                    "TBZ2")
315 set(CPACK_SOURCE_GENERATOR             "TBZ2")
316 set(CPACK_SOURCE_IGNORE_FILES
317     ".git;.*.swp$;.*~;.*patch;.gitignore;${BUILD_DIR}")
318 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY  "A dynamic floating and tiling window manager")
319 set(CPACK_PACKAGE_VENDOR               "awesome development team")
320 set(CPACK_PACKAGE_DESCRIPTION_FILE     "${SOURCE_DIR}/README")
321 set(CPACK_RESOURCE_FILE_LICENSE        "${SOURCE_DIR}/LICENSE")
322 set(CPACK_PACKAGE_VERSION_MAJOR        "${VERSION_MAJOR}")
323 set(CPACK_PACKAGE_VERSION_MINOR        "${VERSION_MINOR}")
324 set(CPACK_PACKAGE_VERSION_PATCH        "${VERSION_PATCH}")
326 include(CPack)
327 #}}}
329 # vim: filetype=cmake:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80