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(CODENAME "Stellar")
10 project(${PROJECT_AWE_NAME} C)
12 set(CMAKE_BUILD_TYPE RELEASE)
14 option(WITH_DBUS "build with D-BUS" ON)
15 option(GENERATE_MANPAGES "generate manpages" ON)
16 option(GENERATE_LUADOC "generate luadoc" ON)
18 link_directories(/usr/local/lib)
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
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 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)
59 a_find_program(LUA_EXECUTABLE lua FALSE)
60 a_find_program(LUADOC_EXECUTABLE luadoc FALSE)
62 a_find_program(CONVERT_EXECUTABLE convert TRUE)
66 include(FindPkgConfig)
68 include(FindLua51) #Due to a cmake bug, you will see Lua50 on screen
71 # {{{ Check if documentation can be build
73 if(NOT ASCIIDOC_EXECUTABLE OR NOT XMLTO_EXECUTABLE OR NOT GZIP_EXECUTABLE)
74 if(NOT ASCIIDOC_EXECUTABLE)
75 SET(missing "asciidoc")
77 if(NOT XMLTO_EXECUTABLE)
78 SET(missing ${missing} " xmlto")
80 if(NOT GZIP_EXECUTABLE)
81 SET(missing ${missing} " gzip")
84 message(STATUS "Not generating manpages. Missing: " ${missing})
85 set(GENERATE_MANPAGES OFF)
90 if(NOT LUADOC_EXECUTABLE)
91 message(STATUS "Not generating luadoc. Missing: luadoc")
92 set(GENERATE_LUADOC OFF)
98 if(EXISTS ${SOURCE_DIR}/.git/HEAD AND GIT_EXECUTABLE)
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)
118 COMMAND ${HOSTNAME_EXECUTABLE}
119 WORKING_DIRECTORY ${SOURCE_DIR}
120 OUTPUT_VARIABLE BUILDHOSTNAME
121 OUTPUT_STRIP_TRAILING_WHITESPACE)
124 # {{{ Required libraries
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
134 pkg_check_modules(AWESOME_REQUIRED REQUIRED
151 libstartup-notification-1.0>=0.10
154 libxdg-basedir>=1.0.0)
156 if(NOT AWESOME_REQUIRED_FOUND OR NOT AWESOME_COMMON_REQUIRED_FOUND)
160 macro(a_find_library variable library)
161 find_library(${variable} ${library})
163 message(FATAL_ERROR ${library} " library not found.")
168 a_find_library(LIB_EV ev)
171 if(NOT LUA51_FOUND AND NOT LUA50_FOUND) # This is a workaround to a cmake bug
172 message(FATAL_ERROR "lua library not found")
175 set(AWESOME_REQUIRED_LIBRARIES
176 ${AWESOME_COMMON_REQUIRED_LDFLAGS}
177 ${AWESOME_REQUIRED_LIBRARIES}
181 set(AWESOME_REQUIRED_INCLUDE_DIRS
182 ${AWESOME_COMMON_REQUIRED_INCLUDE_DIRS}
183 ${AWESOME_REQUIRED_INCLUDE_DIRS}
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_LDFLAGS})
197 set(AWESOME_OPTIONAL_INCLUDE_DIRS ${AWESOME_OPTIONAL_INCLUDE_DIRS} ${DBUS_INCLUDE_DIRS})
200 message(STATUS "DBUS not found. Disabled.")
205 # {{{ Install path and configuration variables
207 set(PREFIX ${PREFIX} CACHE PATH "install prefix")
208 set(CMAKE_INSTALL_PREFIX ${PREFIX})
210 set(PREFIX ${CMAKE_INSTALL_PREFIX} CACHE PATH "install prefix")
213 #If a sysconfdir is specified, use it instead
214 #of the default configuration dir.
215 if(DEFINED SYSCONFDIR)
216 set(SYSCONFDIR ${SYSCONFDIR} CACHE PATH "config directory")
218 set(SYSCONFDIR ${PREFIX}/etc CACHE PATH "config directory")
221 #If an XDG Config Dir is specificed, use it instead
222 #of the default XDG configuration dir.
223 if(DEFINED XDG_CONFIG_DIR)
224 set(XDG_CONFIG_DIR ${XDG_CONFIG_DIR} CACHE PATH "xdg config directory")
226 set(XDG_CONFIG_DIR ${SYSCONFDIR}/xdg CACHE PATH "xdg config directory")
229 # setting AWESOME_DOC_PATH
230 if(DEFINED AWESOME_DOC_PATH)
231 set(AWESOME_DOC_PATH ${AWESOME_DOC_PATH} CACHE PATH "awesome docs directory")
233 set(AWESOME_DOC_PATH ${PREFIX}/share/doc/${PROJECT_AWE_NAME} CACHE PATH "awesome docs directory")
236 # setting AWESOME_XSESSION_PATH
237 if(DEFINED AWESOME_XSESSION_PATH)
238 set(AWESOME_XSESSION_PATH ${AWESOME_XSESSION_PATH} CACHE PATH "awesome xsessions directory")
240 set(AWESOME_XSESSION_PATH ${PREFIX}/share/xsessions CACHE PATH "awesome xsessions directory")
244 if(DEFINED AWESOME_MAN_PATH)
245 set(AWESOME_MAN_PATH ${AWESOME_MAN_PATH} CACHE PATH "awesome manpage directory")
247 set(AWESOME_MAN_PATH ${PREFIX}/share/man CACHE PATH "awesome manpage directory")
250 # Hide to avoid confusion
251 mark_as_advanced(CMAKE_INSTALL_PREFIX)
253 set(AWESOME_VERSION ${VERSION})
254 set(AWESOME_COMPILE_MACHINE ${CMAKE_SYSTEM_PROCESSOR})
255 set(AWESOME_COMPILE_HOSTNAME ${BUILDHOSTNAME})
256 set(AWESOME_COMPILE_BY $ENV{USER})
257 set(AWESOME_RELEASE ${CODENAME})
258 set(AWESOME_SYSCONFDIR ${XDG_CONFIG_DIR}/${PROJECT_AWE_NAME})
259 set(AWESOME_DATA_PATH ${PREFIX}/share/${PROJECT_AWE_NAME})
260 set(AWESOME_LUA_LIB_PATH ${AWESOME_DATA_PATH}/lib)
261 set(AWESOME_ICON_PATH ${AWESOME_DATA_PATH}/icons)
262 set(AWESOME_THEMES_PATH ${AWESOME_DATA_PATH}/themes)
265 # {{{ Configure files
266 file(GLOB_RECURSE awesome_lua_configure_files RELATIVE ${SOURCE_DIR} ${SOURCE_DIR}/lib/*.lua.in ${SOURCE_DIR}/themes/*/*.lua.in)
267 set(AWESOME_CONFIGURE_FILES
268 ${awesome_lua_configure_files}
271 awesome-version-internal.h.in
274 macro(a_configure_file file)
275 string(REGEX REPLACE ".in\$" "" outfile ${file})
276 message(STATUS "Configuring ${outfile}")
277 configure_file(${SOURCE_DIR}/${file}
278 ${BUILD_DIR}/${outfile}
283 foreach(file ${AWESOME_CONFIGURE_FILES})
284 a_configure_file(${file})
288 # vim: filetype=cmake:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80