1 set(PROJECT_AWE_NAME awesome)
3 # If ${SOURCE_DIR} is a git repository VERSION is set to
4 # `git describe` later.
7 set(CODENAME "Closing In")
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)
21 add_definitions(-std=gnu99 -ggdb3 -rdynamic -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
30 include(TestBigEndian)
31 TEST_BIG_ENDIAN(AWESOME_IS_BIG_ENDIAN)
34 # {{{ Find external utilities
35 macro(a_find_program var prg req)
37 find_program(${var} ${prg})
39 message(STATUS "${prg} not found.")
41 message(FATAL_ERROR "${prg} is required to build awesome")
44 message(STATUS "${prg} -> ${${var}}")
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 # 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)
61 a_find_program(CONVERT_EXECUTABLE convert TRUE)
65 include(FindPkgConfig)
67 include(FindLua51) #Due to a cmake bug, you will see Lua50 on screen
70 # {{{ Check if documentation can be build
72 if(NOT ASCIIDOC_EXECUTABLE OR NOT XMLTO_EXECUTABLE OR (COMPRESS_MANPAGES AND NOT GZIP_EXECUTABLE))
73 if(NOT ASCIIDOC_EXECUTABLE)
74 SET(missing "asciidoc")
76 if(NOT XMLTO_EXECUTABLE)
77 SET(missing ${missing} " xmlto")
79 if(COMPRESS_MANPAGES AND NOT GZIP_EXECUTABLE)
80 SET(missing ${missing} " gzip")
83 message(STATUS "Not generating manpages. Missing: " ${missing})
84 set(GENERATE_MANPAGES OFF)
89 if(NOT LUADOC_EXECUTABLE)
90 message(STATUS "Not generating luadoc. Missing: luadoc")
91 set(GENERATE_LUADOC OFF)
97 if(EXISTS ${SOURCE_DIR}/.git/HEAD AND GIT_EXECUTABLE)
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)
117 COMMAND ${HOSTNAME_EXECUTABLE}
118 WORKING_DIRECTORY ${SOURCE_DIR}
119 OUTPUT_VARIABLE BUILDHOSTNAME
120 OUTPUT_STRIP_TRAILING_WHITESPACE)
123 # {{{ Required libraries
126 # AWESOME_REQUIRED_LDFLAGS
127 # AWESOME_REQUIRED_INCLUDE_DIRS
129 # Use pkgconfig to get most of the libraries
130 pkg_check_modules(AWESOME_COMMON_REQUIRED REQUIRED
133 pkg_check_modules(AWESOME_REQUIRED REQUIRED
150 libstartup-notification-1.0>=0.10
152 libxdg-basedir>=1.0.0)
154 if(NOT AWESOME_REQUIRED_FOUND OR NOT AWESOME_COMMON_REQUIRED_FOUND)
158 macro(a_find_library variable library)
159 find_library(${variable} ${library})
161 message(FATAL_ERROR ${library} " library not found.")
166 a_find_library(LIB_EV ev)
167 # GNU libc has <execinfo.h> and backtrace() stuff. If this is not available, we
169 message(STATUS "checking for execinfo")
170 try_compile(HAS_EXECINFO
172 ${CMAKE_SOURCE_DIR}/build-tests/execinfo.c)
174 find_library(LIB_EXECINFO execinfo)
177 set(AWESOME_REQUIRED_LDFLAGS
178 ${AWESOME_REQUIRED_LDFLAGS}
183 message(STATUS "checking for execinfo -- found")
185 message(STATUS "checking for execinfo -- not found")
189 if(NOT LUA51_FOUND AND NOT LUA50_FOUND) # This is a workaround to a cmake bug
190 message(FATAL_ERROR "lua library not found")
193 set(AWESOME_REQUIRED_LDFLAGS
194 ${AWESOME_COMMON_REQUIRED_LDFLAGS}
195 ${AWESOME_REQUIRED_LDFLAGS}
199 set(AWESOME_REQUIRED_INCLUDE_DIRS
200 ${AWESOME_COMMON_REQUIRED_INCLUDE_DIRS}
201 ${AWESOME_REQUIRED_INCLUDE_DIRS}
205 # {{{ Optional libraries
208 # AWESOME_OPTIONAL_LDFLAGS
209 # AWESOME_OPTIONAL_INCLUDE_DIRS
212 pkg_check_modules(DBUS dbus-1)
214 set(AWESOME_OPTIONAL_LDFLAGS ${AWESOME_OPTIONAL_LDFLAGS} ${DBUS_LDFLAGS})
215 set(AWESOME_OPTIONAL_INCLUDE_DIRS ${AWESOME_OPTIONAL_INCLUDE_DIRS} ${DBUS_INCLUDE_DIRS})
218 message(STATUS "DBUS not found. Disabled.")
223 # {{{ Install path and configuration variables
225 set(PREFIX ${PREFIX} CACHE PATH "install prefix")
226 set(CMAKE_INSTALL_PREFIX ${PREFIX})
228 set(PREFIX ${CMAKE_INSTALL_PREFIX} CACHE PATH "install prefix")
231 #If a sysconfdir is specified, use it instead
232 #of the default configuration dir.
233 if(DEFINED SYSCONFDIR)
234 set(SYSCONFDIR ${SYSCONFDIR} CACHE PATH "config directory")
236 set(SYSCONFDIR ${PREFIX}/etc CACHE PATH "config directory")
239 #If an XDG Config Dir is specificed, use it instead
240 #of the default XDG configuration dir.
241 if(DEFINED XDG_CONFIG_DIR)
242 set(XDG_CONFIG_DIR ${XDG_CONFIG_DIR} CACHE PATH "xdg config directory")
244 set(XDG_CONFIG_DIR ${SYSCONFDIR}/xdg CACHE PATH "xdg config directory")
247 # setting AWESOME_DOC_PATH
248 if(DEFINED AWESOME_DOC_PATH)
249 set(AWESOME_DOC_PATH ${AWESOME_DOC_PATH} CACHE PATH "awesome docs directory")
251 set(AWESOME_DOC_PATH ${PREFIX}/share/doc/${PROJECT_AWE_NAME} CACHE PATH "awesome docs directory")
254 # setting AWESOME_XSESSION_PATH
255 if(DEFINED AWESOME_XSESSION_PATH)
256 set(AWESOME_XSESSION_PATH ${AWESOME_XSESSION_PATH} CACHE PATH "awesome xsessions directory")
258 set(AWESOME_XSESSION_PATH ${PREFIX}/share/xsessions CACHE PATH "awesome xsessions directory")
262 if(DEFINED AWESOME_MAN_PATH)
263 set(AWESOME_MAN_PATH ${AWESOME_MAN_PATH} CACHE PATH "awesome manpage directory")
265 set(AWESOME_MAN_PATH ${PREFIX}/share/man CACHE PATH "awesome manpage directory")
268 # Hide to avoid confusion
269 mark_as_advanced(CMAKE_INSTALL_PREFIX)
271 set(AWESOME_VERSION ${VERSION})
272 set(AWESOME_COMPILE_MACHINE ${CMAKE_SYSTEM_PROCESSOR})
273 set(AWESOME_COMPILE_HOSTNAME ${BUILDHOSTNAME})
274 set(AWESOME_COMPILE_BY $ENV{USER})
275 set(AWESOME_RELEASE ${CODENAME})
276 set(AWESOME_SYSCONFDIR ${XDG_CONFIG_DIR}/${PROJECT_AWE_NAME})
277 set(AWESOME_DATA_PATH ${PREFIX}/share/${PROJECT_AWE_NAME})
278 set(AWESOME_LUA_LIB_PATH ${AWESOME_DATA_PATH}/lib)
279 set(AWESOME_ICON_PATH ${AWESOME_DATA_PATH}/icons)
280 set(AWESOME_THEMES_PATH ${AWESOME_DATA_PATH}/themes)
283 # {{{ Configure files
284 file(GLOB_RECURSE awesome_lua_configure_files RELATIVE ${SOURCE_DIR} ${SOURCE_DIR}/lib/*.lua.in ${SOURCE_DIR}/themes/*/*.lua.in)
285 set(AWESOME_CONFIGURE_FILES
286 ${awesome_lua_configure_files}
289 awesome-version-internal.h.in
292 macro(a_configure_file file)
293 string(REGEX REPLACE ".in\$" "" outfile ${file})
294 message(STATUS "Configuring ${outfile}")
295 configure_file(${SOURCE_DIR}/${file}
296 ${BUILD_DIR}/${outfile}
301 foreach(file ${AWESOME_CONFIGURE_FILES})
302 a_configure_file(${file})
306 # vim: filetype=cmake:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80