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 "Pickapart")
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)
19 add_definitions(-std=gnu99 -ggdb3 -fno-strict-aliasing -Wall -Wextra
20 -Wchar-subscripts -Wundef -Wshadow -Wcast-align -Wwrite-strings
21 -Wsign-compare -Wunused -Wno-unused-parameter -Wuninitialized -Winit-self
22 -Wpointer-arith -Wredundant-decls -Wformat-nonliteral
23 -Wno-format-zero-length -Wmissing-format-attribute -Wmissing-prototypes
28 include(TestBigEndian)
29 TEST_BIG_ENDIAN(AWESOME_IS_BIG_ENDIAN)
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 # programs needed for man pages
53 a_find_program(ASCIIDOC_EXECUTABLE asciidoc FALSE)
54 a_find_program(XMLTO_EXECUTABLE xmlto FALSE)
55 a_find_program(GZIP_EXECUTABLE gzip FALSE)
57 a_find_program(LUA_EXECUTABLE lua FALSE)
58 a_find_program(LUADOC_EXECUTABLE luadoc FALSE)
60 a_find_program(CONVERT_EXECUTABLE convert TRUE)
64 include(FindPkgConfig)
66 include(FindLua51) #Due to a cmake bug, you will see Lua50 on screen
69 # {{{ Check if documentation can be build
71 if(NOT ASCIIDOC_EXECUTABLE OR NOT XMLTO_EXECUTABLE OR (COMPRESS_MANPAGES AND NOT GZIP_EXECUTABLE))
72 if(NOT ASCIIDOC_EXECUTABLE)
73 SET(missing "asciidoc")
75 if(NOT XMLTO_EXECUTABLE)
76 SET(missing ${missing} " xmlto")
78 if(COMPRESS_MANPAGES AND NOT GZIP_EXECUTABLE)
79 SET(missing ${missing} " gzip")
82 message(STATUS "Not generating manpages. Missing: " ${missing})
83 set(GENERATE_MANPAGES OFF)
88 if(NOT LUADOC_EXECUTABLE)
89 message(STATUS "Not generating luadoc. Missing: luadoc")
90 set(GENERATE_LUADOC OFF)
96 if(EXISTS ${SOURCE_DIR}/.git/HEAD AND GIT_EXECUTABLE)
99 COMMAND ${GIT_EXECUTABLE} describe
100 WORKING_DIRECTORY ${SOURCE_DIR}
101 OUTPUT_VARIABLE VERSION
102 OUTPUT_STRIP_TRAILING_WHITESPACE)
103 # file the git-version-stamp.sh script will look into
104 set(VERSION_STAMP_FILE ${BUILD_DIR}/.version_stamp)
105 file(WRITE ${VERSION_STAMP_FILE} ${VERSION})
106 # create a version_stamp target later
107 set(BUILD_FROM_GIT TRUE)
108 elseif( EXISTS ${SOURCE_DIR}/.version_stamp )
109 # get version from version stamp
110 file(READ ${SOURCE_DIR}/.version_stamp VERSION)
116 COMMAND ${HOSTNAME_EXECUTABLE}
117 WORKING_DIRECTORY ${SOURCE_DIR}
118 OUTPUT_VARIABLE BUILDHOSTNAME
119 OUTPUT_STRIP_TRAILING_WHITESPACE)
122 # {{{ Required libraries
125 # AWESOME_REQUIRED_LDFLAGS
126 # AWESOME_REQUIRED_INCLUDE_DIRS
128 # Use pkgconfig to get most of the libraries
129 pkg_check_modules(AWESOME_COMMON_REQUIRED REQUIRED
132 pkg_check_modules(AWESOME_REQUIRED REQUIRED
147 libstartup-notification-1.0>=0.10
150 libxdg-basedir>=1.0.0)
152 if(NOT AWESOME_REQUIRED_FOUND OR NOT AWESOME_COMMON_REQUIRED_FOUND)
156 macro(a_find_library variable library)
157 find_library(${variable} ${library})
159 message(FATAL_ERROR ${library} " library not found.")
164 a_find_library(LIB_EV ev)
166 # Check for backtrace_symbols()
167 include(CheckFunctionExists)
168 check_function_exists(backtrace_symbols HAS_EXECINFO)
170 find_library(LIB_EXECINFO execinfo)
173 set(AWESOME_REQUIRED_LDFLAGS
174 ${AWESOME_REQUIRED_LDFLAGS}
179 message(STATUS "checking for execinfo -- found")
181 message(STATUS "checking for execinfo -- not found")
184 # __builtin_clz is available since gcc 3.4
185 try_compile(HAS___BUILTIN_CLZ
187 ${CMAKE_SOURCE_DIR}/build-tests/__builtin_clz.c)
188 if(HAS___BUILTIN_CLZ)
189 message(STATUS "checking for __builtin_clz -- yes")
191 message(STATUS "checking for __builtin_clz -- no")
195 if(NOT LUA51_FOUND AND NOT LUA50_FOUND) # This is a workaround to a cmake bug
196 message(FATAL_ERROR "lua library not found")
199 set(AWESOME_REQUIRED_LDFLAGS
200 ${AWESOME_COMMON_REQUIRED_LDFLAGS}
201 ${AWESOME_REQUIRED_LDFLAGS}
205 set(AWESOME_REQUIRED_INCLUDE_DIRS
206 ${AWESOME_COMMON_REQUIRED_INCLUDE_DIRS}
207 ${AWESOME_REQUIRED_INCLUDE_DIRS}
211 # {{{ Optional libraries
214 # AWESOME_OPTIONAL_LDFLAGS
215 # AWESOME_OPTIONAL_INCLUDE_DIRS
218 pkg_check_modules(DBUS dbus-1)
220 set(AWESOME_OPTIONAL_LDFLAGS ${AWESOME_OPTIONAL_LDFLAGS} ${DBUS_LDFLAGS})
221 set(AWESOME_OPTIONAL_INCLUDE_DIRS ${AWESOME_OPTIONAL_INCLUDE_DIRS} ${DBUS_INCLUDE_DIRS})
224 message(STATUS "DBUS not found. Disabled.")
229 # {{{ Install path and configuration variables
231 set(PREFIX ${PREFIX} CACHE PATH "install prefix")
232 set(CMAKE_INSTALL_PREFIX ${PREFIX})
234 set(PREFIX ${CMAKE_INSTALL_PREFIX} CACHE PATH "install prefix")
237 #If a sysconfdir is specified, use it instead
238 #of the default configuration dir.
239 if(DEFINED SYSCONFDIR)
240 set(SYSCONFDIR ${SYSCONFDIR} CACHE PATH "config directory")
242 set(SYSCONFDIR ${PREFIX}/etc CACHE PATH "config directory")
245 #If an XDG Config Dir is specificed, use it instead
246 #of the default XDG configuration dir.
247 if(DEFINED XDG_CONFIG_DIR)
248 set(XDG_CONFIG_DIR ${XDG_CONFIG_DIR} CACHE PATH "xdg config directory")
250 set(XDG_CONFIG_DIR ${SYSCONFDIR}/xdg CACHE PATH "xdg config directory")
253 # setting AWESOME_DOC_PATH
254 if(DEFINED AWESOME_DOC_PATH)
255 set(AWESOME_DOC_PATH ${AWESOME_DOC_PATH} CACHE PATH "awesome docs directory")
257 set(AWESOME_DOC_PATH ${PREFIX}/share/doc/${PROJECT_AWE_NAME} CACHE PATH "awesome docs directory")
260 # setting AWESOME_XSESSION_PATH
261 if(DEFINED AWESOME_XSESSION_PATH)
262 set(AWESOME_XSESSION_PATH ${AWESOME_XSESSION_PATH} CACHE PATH "awesome xsessions directory")
264 set(AWESOME_XSESSION_PATH ${PREFIX}/share/xsessions CACHE PATH "awesome xsessions directory")
268 if(DEFINED AWESOME_MAN_PATH)
269 set(AWESOME_MAN_PATH ${AWESOME_MAN_PATH} CACHE PATH "awesome manpage directory")
271 set(AWESOME_MAN_PATH ${PREFIX}/share/man CACHE PATH "awesome manpage directory")
274 # Hide to avoid confusion
275 mark_as_advanced(CMAKE_INSTALL_PREFIX)
277 set(AWESOME_VERSION ${VERSION})
278 set(AWESOME_COMPILE_MACHINE ${CMAKE_SYSTEM_PROCESSOR})
279 set(AWESOME_COMPILE_HOSTNAME ${BUILDHOSTNAME})
280 set(AWESOME_COMPILE_BY $ENV{USER})
281 set(AWESOME_RELEASE ${CODENAME})
282 set(AWESOME_SYSCONFDIR ${XDG_CONFIG_DIR}/${PROJECT_AWE_NAME})
283 set(AWESOME_DATA_PATH ${PREFIX}/share/${PROJECT_AWE_NAME})
284 set(AWESOME_LUA_LIB_PATH ${AWESOME_DATA_PATH}/lib)
285 set(AWESOME_ICON_PATH ${AWESOME_DATA_PATH}/icons)
286 set(AWESOME_THEMES_PATH ${AWESOME_DATA_PATH}/themes)
289 # {{{ Configure files
290 file(GLOB_RECURSE awesome_lua_configure_files RELATIVE ${SOURCE_DIR} ${SOURCE_DIR}/lib/*.lua.in ${SOURCE_DIR}/themes/*/*.lua.in)
291 set(AWESOME_CONFIGURE_FILES
292 ${awesome_lua_configure_files}
295 awesome-version-internal.h.in
298 macro(a_configure_file file)
299 string(REGEX REPLACE ".in\$" "" outfile ${file})
300 message(STATUS "Configuring ${outfile}")
301 configure_file(${SOURCE_DIR}/${file}
302 ${BUILD_DIR}/${outfile}
307 foreach(file ${AWESOME_CONFIGURE_FILES})
308 a_configure_file(${file})
312 # vim: filetype=cmake:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80