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.
8 set(VERSION_MAJOR ${VERSION})
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)
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
32 # {{{ Find external utilities
33 macro(a_find_program var prg req)
35 find_program(${var} ${prg})
37 message(STATUS "${prg} not found.")
39 message(FATAL_ERROR "${prg} is required to build awesome")
42 message(STATUS "${prg} -> ${${var}}")
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)
58 a_find_program(LUA_EXECUTABLE lua FALSE)
59 a_find_program(LUADOC_EXECUTABLE luadoc FALSE)
63 include(FindPkgConfig)
66 # {{{ Check if documentation can be build
68 if(NOT ASCIIDOC_EXECUTABLE OR NOT XMLTO_EXECUTABLE OR NOT GZIP_EXECUTABLE)
69 if(NOT ASCIIDOC_EXECUTABLE)
70 SET(missing "asciidoc")
72 if(NOT XMLTO_EXECUTABLE)
73 SET(missing ${missing} " xmlto")
75 if(NOT GZIP_EXECUTABLE)
76 SET(missing ${missing} " gzip")
79 message(STATUS "Not generating manpages. Missing: " ${missing})
80 set(GENERATE_MANPAGES OFF)
85 if(NOT LUADOC_EXECUTABLE)
86 message(STATUS "Not generating luadoc. Missing: luadoc")
87 set(GENERATE_LUADOC OFF)
93 if(EXISTS ${SOURCE_DIR}/.git/HEAD AND GIT_EXECUTABLE)
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)
114 COMMAND ${HOSTNAME_EXECUTABLE} -f
115 WORKING_DIRECTORY ${SOURCE_DIR}
116 OUTPUT_VARIABLE BUILDHOSTNAME
117 OUTPUT_STRIP_TRAILING_WHITESPACE)
121 # {{{ Required libraries
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
143 if(NOT AWESOME_REQUIRED_FOUND)
147 macro(a_find_library variable library)
148 find_library(${variable} ${library})
150 message(FATAL_ERROR ${library} " library not found.")
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)
160 find_path(LUA_INC_DIR lua.h
163 /usr/local/include/lua5.1)
165 find_library(LUA_LIB NAMES lua5.1 lua
172 message(FATAL_ERROR "lua library not found")
175 set(AWESOME_REQUIRED_LIBRARIES ${AWESOME_REQUIRED_LIBRARIES}
179 set(AWESOME_REQUIRED_INCLUDE_DIRS ${AWESOME_REQUIRED_INCLUDE_DIRS}
182 set(AWESOMECLIENT_LIBRARIES
187 # {{{ Optional libraries
190 # AWESOME_OPTIONAL_LIBRARIES
191 # AWESOME_OPTIONAL_INCLUDE_DIRS
194 pkg_check_modules(DBUS dbus-1)
196 set(AWESOME_OPTIONAL_LIBRARIES ${AWESOME_OPTIONAL_LIBRARIES} ${DBUS_LIBRARIES})
197 set(AWESOME_OPTIONAL_INCLUDE_DIRS ${AWESOME_OPTIONAL_INCLUDE_DIRS} ${DBUS_INCLUDE_DIRS})
200 message(STATUS "DBUS not found. Disabled.")
205 pkg_check_modules(IMLIB2 imlib2)
207 set(AWESOME_OPTIONAL_LIBRARIES ${AWESOME_OPTIONAL_LIBRARIES} ${IMLIB2_LIBRARIES})
208 set(AWESOME_OPTIONAL_INCLUDE_DIRS ${AWESOME_OPTIONAL_INCLUDE_DIRS} ${IMLIB2_INCLUDE_DIRS})
211 message(STATUS "Imlib2 not found. Disabled.")
216 pkg_check_modules(GDK_PIXBUF REQUIRED gdk-2.0>=2.2 gdk-pixbuf-2.0>=2.2)
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})
223 message(FATAL_ERROR "GdkPixBuf not found.")
228 # {{{ Install path and configuration variables
230 set(PREFIX ${PREFIX} CACHE PATH "install prefix")
231 set(CMAKE_INSTALL_PREFIX ${PREFIX})
233 set(PREFIX ${CMAKE_INSTALL_PREFIX} CACHE PATH "install prefix")
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")
241 set(SYSCONFDIR /etc CACHE PATH "config directory")
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")
249 set(XDG_CONFIG_DIR ${SYSCONFDIR}/xdg CACHE PATH "xdg config directory")
252 # setting AWESOME_DOC_PATH
253 if(DEFINED AWESOME_DOC_PATH)
254 set(AWESOME_DOC_PATH ${AWESOME_DOC_PATH} CACHE PATH "awesome docs directory")
256 set(AWESOME_DOC_PATH ${PREFIX}/share/doc/${PROJECT_AWE_NAME} CACHE PATH "awesome docs directory")
259 # setting AWESOME_XSESSION_PATH
260 if(DEFINED AWESOME_XSESSION_PATH)
261 set(AWESOME_XSESSION_PATH ${AWESOME_XSESSION_PATH} CACHE PATH "awesome xsessions directory")
263 set(AWESOME_XSESSION_PATH ${PREFIX}/share/xsessions CACHE PATH "awesome xsessions directory")
267 if(DEFINED AWESOME_MAN_PATH)
268 set(AWESOME_MAN_PATH ${AWESOME_MAN_PATH} CACHE PATH "awesome manpage directory")
270 set(AWESOME_MAN_PATH ${PREFIX}/share/man CACHE PATH "awesome manpage directory")
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)
288 # {{{ Configure files
289 set(AWESOME_CONFIGURE_FILES
294 awesome-version-internal.h.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}
306 foreach(file ${AWESOME_CONFIGURE_FILES})
307 a_configure_file(${file})
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}")
329 # vim: filetype=cmake:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80