Mirror of Awesome WM window manager
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

awesomeConfig.cmake 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. set(PROJECT_AWE_NAME awesome)
  2. # If ${SOURCE_DIR} is a git repository VERSION is set to
  3. # `git describe` later.
  4. set(VERSION devel)
  5. set(CODENAME "Too long")
  6. include(AutoOption.cmake)
  7. autoOption(WITH_DBUS "build with D-BUS")
  8. autoOption(GENERATE_MANPAGES "generate manpages")
  9. option(COMPRESS_MANPAGES "compress manpages" ON)
  10. option(GENERATE_DOC "generate API documentation" ON)
  11. option(DO_COVERAGE "build with coverage" OFF)
  12. autoOption(WITH_XCB_ERRORS "build with xcb-errors")
  13. if (GENERATE_DOC AND DO_COVERAGE)
  14. message(STATUS "Not generating API documentation with DO_COVERAGE")
  15. set(GENERATE_DOC OFF)
  16. endif()
  17. # {{{ Find external utilities
  18. macro(a_find_program var prg req)
  19. set(required ${req})
  20. find_program(${var} ${prg})
  21. if(NOT ${var})
  22. message(STATUS "${prg} not found.")
  23. if(required)
  24. message(FATAL_ERROR "${prg} is required to build awesome")
  25. endif()
  26. else()
  27. message(STATUS "${prg} -> ${${var}}")
  28. endif()
  29. endmacro()
  30. a_find_program(GIT_EXECUTABLE git FALSE)
  31. # programs needed for man pages
  32. a_find_program(ASCIIDOCTOR_EXECUTABLE asciidoctor FALSE)
  33. a_find_program(GZIP_EXECUTABLE gzip FALSE)
  34. # Lua documentation
  35. if(GENERATE_DOC)
  36. a_find_program(LDOC_EXECUTABLE ldoc FALSE)
  37. if(NOT LDOC_EXECUTABLE)
  38. a_find_program(LDOC_EXECUTABLE ldoc.lua FALSE)
  39. endif()
  40. if(LDOC_EXECUTABLE)
  41. execute_process(COMMAND sh -c "${LDOC_EXECUTABLE} --sadly-ldoc-has-no-version-option 2>&1 | grep ' vs 1.4.5'"
  42. OUTPUT_VARIABLE LDOC_VERSION_RESULT)
  43. if(NOT LDOC_VERSION_RESULT STREQUAL "")
  44. message(WARNING "Ignoring LDoc, because version 1.4.5 is known to be broken")
  45. unset(LDOC_EXECUTABLE CACHE)
  46. endif()
  47. endif()
  48. if(NOT LDOC_EXECUTABLE)
  49. message(STATUS "Not generating API documentation. Missing: ldoc.")
  50. set(GENERATE_DOC OFF)
  51. endif()
  52. else()
  53. message(STATUS "Not generating API documentation.")
  54. endif()
  55. # theme graphics
  56. a_find_program(CONVERT_EXECUTABLE convert TRUE)
  57. # pkg-config
  58. include(FindPkgConfig)
  59. # lua
  60. include(FindLua)
  61. if (NOT LUA_FOUND)
  62. message(FATAL_ERROR
  63. "Could not find Lua. See the error above.\n"
  64. "You might want to hint it using the LUA_DIR environment variable, "
  65. "or set the LUA_INCLUDE_DIR / LUA_LIBRARY CMake variables.")
  66. endif()
  67. # }}}
  68. # {{{ Check if documentation can be build
  69. if(GENERATE_MANPAGES)
  70. if(NOT ASCIIDOCTOR_EXECUTABLE OR (COMPRESS_MANPAGES AND NOT GZIP_EXECUTABLE))
  71. if(NOT ASCIIDOCTOR_EXECUTABLE)
  72. SET(missing "asciidoctor")
  73. endif()
  74. if(COMPRESS_MANPAGES AND NOT GZIP_EXECUTABLE)
  75. SET(missing ${missing} " gzip")
  76. endif()
  77. autoDisable(GENERATE_MANPAGES "Not generating manpages. Missing: " ${missing})
  78. endif()
  79. endif()
  80. # }}}
  81. # {{{ Version stamp
  82. if(OVERRIDE_VERSION)
  83. set(VERSION ${OVERRIDE_VERSION})
  84. message(STATUS "Using version from OVERRIDE_VERSION: ${VERSION}")
  85. elseif(EXISTS ${SOURCE_DIR}/.git AND GIT_EXECUTABLE)
  86. # get current version
  87. execute_process(
  88. COMMAND ${GIT_EXECUTABLE} describe --dirty
  89. WORKING_DIRECTORY ${SOURCE_DIR}
  90. OUTPUT_VARIABLE VERSION
  91. OUTPUT_STRIP_TRAILING_WHITESPACE)
  92. # File the build-utils/git-version-stamp.sh script will look into.
  93. set(VERSION_STAMP_FILE ${BUILD_DIR}/.version_stamp)
  94. file(WRITE ${VERSION_STAMP_FILE} ${VERSION})
  95. # create a version_stamp target later
  96. set(BUILD_FROM_GIT TRUE)
  97. message(STATUS "Using version from git: ${VERSION}")
  98. elseif( EXISTS ${SOURCE_DIR}/.version_stamp )
  99. # get version from version stamp
  100. file(READ ${SOURCE_DIR}/.version_stamp VERSION)
  101. message(STATUS "Using version from ${SOURCE_DIR}/.version_stamp: ${VERSION}")
  102. endif()
  103. # }}}
  104. # {{{ Required libraries
  105. #
  106. # this sets up:
  107. # AWESOME_REQUIRED_LDFLAGS
  108. # AWESOME_REQUIRED_INCLUDE_DIRS
  109. # Use pkgconfig to get most of the libraries
  110. pkg_check_modules(AWESOME_COMMON_REQUIRED REQUIRED
  111. xcb>=1.6)
  112. set(AWESOME_DEPENDENCIES
  113. glib-2.0
  114. glib-2.0>=2.40
  115. gdk-pixbuf-2.0
  116. cairo
  117. x11
  118. xcb-cursor
  119. xcb-randr
  120. xcb-xtest
  121. xcb-xinerama
  122. xcb-shape
  123. xcb-util
  124. xcb-util>=0.3.8
  125. xcb-keysyms
  126. xcb-keysyms>=0.3.4
  127. xcb-icccm
  128. xcb-icccm>=0.3.8
  129. xcb-xfixes
  130. # NOTE: it's not clear what version is required, but 1.10 works at least.
  131. # See https://github.com/awesomeWM/awesome/pull/149#issuecomment-94208356.
  132. xcb-xkb
  133. xkbcommon
  134. xkbcommon-x11
  135. cairo-xcb
  136. libstartup-notification-1.0
  137. libstartup-notification-1.0>=0.10
  138. xproto
  139. xproto>=7.0.15
  140. libxdg-basedir
  141. libxdg-basedir>=1.0.0
  142. xcb-xrm
  143. )
  144. pkg_check_modules(AWESOME_REQUIRED REQUIRED ${AWESOME_DEPENDENCIES})
  145. # Check for backtrace_symbols()
  146. include(CheckSymbolExists)
  147. check_symbol_exists(backtrace_symbols execinfo.h HAS_EXECINFO)
  148. if(NOT HAS_EXECINFO)
  149. find_library(LIB_EXECINFO execinfo)
  150. if(LIB_EXECINFO)
  151. set(HAS_EXECINFO 1)
  152. set(AWESOME_REQUIRED_LDFLAGS
  153. ${AWESOME_REQUIRED_LDFLAGS}
  154. ${LIB_EXECINFO})
  155. endif()
  156. endif()
  157. if(HAS_EXECINFO)
  158. message(STATUS "checking for execinfo -- found")
  159. else()
  160. message(STATUS "checking for execinfo -- not found")
  161. endif()
  162. # Do we need libm for round()?
  163. check_symbol_exists(round math.h HAS_ROUND_WITHOUT_LIBM)
  164. if(NOT HAS_ROUND_WITHOUT_LIBM)
  165. SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} m)
  166. set(AWESOME_REQUIRED_LDFLAGS ${AWESOME_REQUIRED_LDFLAGS} m)
  167. check_symbol_exists(round math.h HAS_ROUND_WITH_LIBM)
  168. if(NOT HAS_ROUND_WITH_LIBM)
  169. message(FATAL_ERROR "Did not find round()")
  170. endif()
  171. message(STATUS "checking for round -- in libm")
  172. else()
  173. message(STATUS "checking for round -- builtin")
  174. endif()
  175. set(AWESOME_REQUIRED_LDFLAGS
  176. ${AWESOME_COMMON_REQUIRED_LDFLAGS}
  177. ${AWESOME_REQUIRED_LDFLAGS}
  178. ${LUA_LIBRARIES}
  179. )
  180. set(AWESOME_REQUIRED_INCLUDE_DIRS
  181. ${AWESOME_COMMON_REQUIRED_INCLUDE_DIRS}
  182. ${AWESOME_REQUIRED_INCLUDE_DIRS}
  183. ${LUA_INCLUDE_DIR})
  184. # }}}
  185. # {{{ Optional libraries
  186. #
  187. # this sets up:
  188. # AWESOME_OPTIONAL_LDFLAGS
  189. # AWESOME_OPTIONAL_INCLUDE_DIRS
  190. if(WITH_DBUS)
  191. pkg_check_modules(DBUS dbus-1)
  192. if(DBUS_FOUND)
  193. set(AWESOME_OPTIONAL_LDFLAGS ${AWESOME_OPTIONAL_LDFLAGS} ${DBUS_LDFLAGS})
  194. set(AWESOME_OPTIONAL_INCLUDE_DIRS ${AWESOME_OPTIONAL_INCLUDE_DIRS} ${DBUS_INCLUDE_DIRS})
  195. else()
  196. autoDisable(WITH_DBUS "DBus not found.")
  197. endif()
  198. endif()
  199. if(WITH_XCB_ERRORS)
  200. pkg_check_modules(XCB_ERRORS xcb-errors)
  201. if(XCB_ERRORS_FOUND)
  202. set(AWESOME_OPTIONAL_LDFLAGS ${AWESOME_OPTIONAL_LDFLAGS} ${XCB_ERRORS_LDFLAGS})
  203. set(AWESOME_OPTIONAL_INCLUDE_DIRS ${AWESOME_OPTIONAL_INCLUDE_DIRS} ${XCB_ERRORS_INCLUDE_DIRS})
  204. else()
  205. autoDisable(WITH_XCB_ERRORS "xcb-errors not found.")
  206. endif()
  207. endif()
  208. # }}}
  209. # {{{ Install path and configuration variables
  210. #If a sysconfdir is specified, use it instead
  211. #of the default configuration dir.
  212. if(DEFINED SYSCONFDIR)
  213. set(SYSCONFDIR ${SYSCONFDIR} CACHE PATH "config directory")
  214. else()
  215. set(SYSCONFDIR ${CMAKE_INSTALL_PREFIX}/etc CACHE PATH "config directory")
  216. endif()
  217. #If an XDG Config Dir is specificed, use it instead
  218. #of the default XDG configuration dir.
  219. if(DEFINED XDG_CONFIG_DIR)
  220. set(XDG_CONFIG_DIR ${XDG_CONFIG_DIR} CACHE PATH "xdg config directory")
  221. else()
  222. set(XDG_CONFIG_DIR ${SYSCONFDIR}/xdg CACHE PATH "xdg config directory")
  223. endif()
  224. # setting AWESOME_DATA_PATH
  225. if(DEFINED AWESOME_DATA_PATH)
  226. set(AWESOME_DATA_PATH ${AWESOME_DATA_PATH} CACHE PATH "awesome share directory")
  227. else()
  228. set(AWESOME_DATA_PATH ${CMAKE_INSTALL_PREFIX}/share/${PROJECT_AWE_NAME} CACHE PATH "awesome share directory")
  229. endif()
  230. # setting AWESOME_DOC_PATH
  231. if(DEFINED AWESOME_DOC_PATH)
  232. set(AWESOME_DOC_PATH ${AWESOME_DOC_PATH} CACHE PATH "awesome docs directory")
  233. else()
  234. set(AWESOME_DOC_PATH ${CMAKE_INSTALL_PREFIX}/share/doc/${PROJECT_AWE_NAME} CACHE PATH "awesome docs directory")
  235. endif()
  236. # setting AWESOME_XSESSION_PATH
  237. if(DEFINED AWESOME_XSESSION_PATH)
  238. set(AWESOME_XSESSION_PATH ${AWESOME_XSESSION_PATH} CACHE PATH "awesome xsessions directory")
  239. else()
  240. set(AWESOME_XSESSION_PATH ${CMAKE_INSTALL_PREFIX}/share/xsessions CACHE PATH "awesome xsessions directory")
  241. endif()
  242. # set man path
  243. if(DEFINED AWESOME_MAN_PATH)
  244. set(AWESOME_MAN_PATH ${AWESOME_MAN_PATH} CACHE PATH "awesome manpage directory")
  245. else()
  246. set(AWESOME_MAN_PATH ${CMAKE_INSTALL_PREFIX}/share/man CACHE PATH "awesome manpage directory")
  247. endif()
  248. # Hide to avoid confusion
  249. mark_as_advanced(CMAKE_INSTALL_CMAKE_INSTALL_PREFIX)
  250. set(AWESOME_VERSION ${VERSION})
  251. set(AWESOME_RELEASE ${CODENAME})
  252. set(AWESOME_SYSCONFDIR ${XDG_CONFIG_DIR}/${PROJECT_AWE_NAME})
  253. set(AWESOME_LUA_LIB_PATH ${AWESOME_DATA_PATH}/lib)
  254. set(AWESOME_ICON_PATH ${AWESOME_DATA_PATH}/icons)
  255. set(AWESOME_THEMES_PATH ${AWESOME_DATA_PATH}/themes)
  256. # }}}
  257. if(GENERATE_DOC)
  258. # Load the common documentation
  259. include(docs/load_ldoc.cmake)
  260. # Generate the widget lists
  261. include(docs/widget_lists.cmake)
  262. endif()
  263. # Use `include`, rather than `add_subdirectory`, to keep the variables
  264. # The file is a valid CMakeLists.txt and can be executed directly if only
  265. # the image artefacts are needed.
  266. include(tests/examples/CMakeLists.txt)
  267. # {{{ Configure files
  268. file(GLOB awesome_base_c_configure_files RELATIVE ${SOURCE_DIR}
  269. ${SOURCE_DIR}/*.c
  270. ${SOURCE_DIR}/*.h)
  271. file(GLOB awesome_c_configure_files RELATIVE ${SOURCE_DIR}
  272. ${SOURCE_DIR}/common/*.c
  273. ${SOURCE_DIR}/common/*.h
  274. ${SOURCE_DIR}/objects/*.c
  275. ${SOURCE_DIR}/objects/*.h)
  276. file(GLOB_RECURSE awesome_lua_configure_files RELATIVE ${SOURCE_DIR}
  277. ${SOURCE_DIR}/lib/*.lua)
  278. file(GLOB_RECURSE awesome_theme_configure_files RELATIVE ${SOURCE_DIR}
  279. ${SOURCE_DIR}/themes/*/*.lua)
  280. set(AWESOME_CONFIGURE_FILES
  281. ${awesome_base_c_configure_files}
  282. ${awesome_theme_configure_files}
  283. config.h
  284. docs/config.ld
  285. awesome-version-internal.h)
  286. foreach(file ${AWESOME_CONFIGURE_FILES})
  287. configure_file(${SOURCE_DIR}/${file}
  288. ${BUILD_DIR}/${file}
  289. ESCAPE_QUOTES
  290. @ONLY)
  291. endforeach()
  292. set(AWESOME_CONFIGURE_COPYONLY_WITHCOV_FILES
  293. ${awesome_c_configure_files}
  294. ${awesome_lua_configure_files}
  295. )
  296. if(DO_COVERAGE)
  297. foreach(file ${AWESOME_CONFIGURE_COPYONLY_WITHCOV_FILES})
  298. configure_file(${SOURCE_DIR}/${file}
  299. ${BUILD_DIR}/${file}
  300. COPYONLY)
  301. endforeach()
  302. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 --coverage -fprofile-arcs -ftest-coverage")
  303. else()
  304. foreach(file ${AWESOME_CONFIGURE_COPYONLY_WITHCOV_FILES})
  305. configure_file(${SOURCE_DIR}/${file}
  306. ${BUILD_DIR}/${file}
  307. ESCAPE_QUOTES
  308. @ONLY)
  309. endforeach()
  310. endif()
  311. #}}}
  312. # {{{ Check for LGI
  313. add_executable(lgi-check build-utils/lgi-check.c)
  314. target_link_libraries(lgi-check ${LUA_LIBRARIES})
  315. target_include_directories(lgi-check PRIVATE ${LUA_INCLUDE_DIR})
  316. add_custom_target(lgi-check-run ALL
  317. COMMAND lgi-check
  318. DEPENDS lgi-check
  319. COMMENT "Checking for LGI...")
  320. # }}}
  321. # {{{ Generate some aggregated documentation from lua script
  322. add_custom_target(setup_directories DEPENDS lgi-check-run)
  323. add_custom_command(TARGET setup_directories
  324. COMMAND ${CMAKE_COMMAND} -E make_directory ${BUILD_DIR}/script_files/
  325. COMMAND ${CMAKE_COMMAND} -E make_directory ${BUILD_DIR}/docs/common/
  326. COMMAND ${CMAKE_COMMAND} -E make_directory ${BUILD_DIR}/doc/images/
  327. COMMAND ${CMAKE_COMMAND} -E copy ${SOURCE_DIR}/docs/_parser.lua ${BUILD_DIR}/docs/
  328. )
  329. add_custom_command(
  330. OUTPUT ${BUILD_DIR}/docs/06-appearance.md
  331. COMMAND lua ${SOURCE_DIR}/docs/06-appearance.md.lua
  332. ${BUILD_DIR}/docs/06-appearance.md
  333. DEPENDS
  334. lgi-check-run
  335. ${SOURCE_DIR}/docs/06-appearance.md.lua
  336. ${SOURCE_DIR}/docs/_parser.lua
  337. )
  338. add_custom_command(
  339. OUTPUT ${BUILD_DIR}/docs/common/rules_index.ldoc
  340. COMMAND lua ${SOURCE_DIR}/docs/build_rules_index.lua
  341. ${BUILD_DIR}/docs/common/rules_index.ldoc
  342. # Cheap trick until the ldoc `configure_file` is ported to be a build
  343. # step rather than part of cmake.
  344. COMMAND ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/docs/common/rules_index.ldoc
  345. ${SOURCE_DIR}/docs/common/rules_index.ldoc
  346. DEPENDS
  347. lgi-check-run
  348. ${SOURCE_DIR}/docs/build_rules_index.lua
  349. ${SOURCE_DIR}/docs/_parser.lua
  350. )
  351. add_custom_command(
  352. OUTPUT ${BUILD_DIR}/awesomerc.lua ${BUILD_DIR}/docs/05-awesomerc.md
  353. ${BUILD_DIR}/script_files/rc.lua
  354. COMMAND lua ${SOURCE_DIR}/docs/05-awesomerc.md.lua
  355. ${BUILD_DIR}/docs/05-awesomerc.md ${SOURCE_DIR}/awesomerc.lua
  356. ${BUILD_DIR}/awesomerc.lua
  357. ${BUILD_DIR}/script_files/rc.lua
  358. DEPENDS ${SOURCE_DIR}/awesomerc.lua ${SOURCE_DIR}/docs/05-awesomerc.md.lua
  359. )
  360. add_custom_command(
  361. OUTPUT ${BUILD_DIR}/script_files/theme.lua
  362. COMMAND lua ${SOURCE_DIR}/docs/sample_theme.lua ${BUILD_DIR}/script_files/
  363. )
  364. # Create a target for the auto-generated awesomerc.lua and other files
  365. add_custom_target(generate_awesomerc DEPENDS
  366. setup_directories
  367. ${BUILD_DIR}/awesomerc.lua
  368. ${BUILD_DIR}/script_files/theme.lua
  369. ${BUILD_DIR}/script_files/rc.lua
  370. ${SOURCE_DIR}/awesomerc.lua
  371. ${BUILD_DIR}/docs/06-appearance.md
  372. ${SOURCE_DIR}/docs/05-awesomerc.md.lua
  373. ${SOURCE_DIR}/docs/build_rules_index.lua
  374. ${BUILD_DIR}/docs/common/rules_index.ldoc
  375. ${SOURCE_DIR}/docs/sample_theme.lua
  376. ${SOURCE_DIR}/docs/sample_files.lua
  377. ${SOURCE_DIR}/awesomerc.lua
  378. ${awesome_c_configure_files}
  379. ${awesome_lua_configure_files}
  380. )
  381. #}}}
  382. # {{{ Copy additional files
  383. file(GLOB awesome_md_docs RELATIVE ${SOURCE_DIR}
  384. ${SOURCE_DIR}/docs/*.md)
  385. set(AWESOME_ADDITIONAL_FILES
  386. ${awesome_md_docs})
  387. foreach(file ${AWESOME_ADDITIONAL_FILES})
  388. configure_file(${SOURCE_DIR}/${file}
  389. ${BUILD_DIR}/${file}
  390. @ONLY)
  391. endforeach()
  392. #}}}
  393. # vim: filetype=cmake:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80:foldmethod=marker