forked from external/yambar
cmake: break out bar stuff to separate CMakeLists.txt
This commit is contained in:
parent
76655bc944
commit
ae5029826b
19 changed files with 95 additions and 89 deletions
|
@ -4,6 +4,14 @@ project(f00bar C)
|
||||||
set(CORE_PLUGINS_AS_SHARED_LIBRARIES 0 CACHE BOOL
|
set(CORE_PLUGINS_AS_SHARED_LIBRARIES 0 CACHE BOOL
|
||||||
"Compiles modules, particles and decorations as shared libraries, which are loaded on-demand")
|
"Compiles modules, particles and decorations as shared libraries, which are loaded on-demand")
|
||||||
|
|
||||||
|
set(ENABLE_X11 1 CACHE BOOL "Enables support for the XCB (X11) backend")
|
||||||
|
set_property(DIRECTORY . APPEND PROPERTY
|
||||||
|
COMPILE_DEFINITIONS $<$<BOOL:${ENABLE_X11}>:ENABLE_X11>)
|
||||||
|
|
||||||
|
set(ENABLE_WAYLAND 1 CACHE BOOL "Enables support for the wayland backend")
|
||||||
|
set_property(DIRECTORY . APPEND PROPERTY
|
||||||
|
COMPILE_DEFINITIONS $<$<BOOL:${ENABLE_WAYLAND}>:ENABLE_WAYLAND>)
|
||||||
|
|
||||||
set(CMAKE_C_STANDARD_REQUIRED ON)
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||||
set(CMAKE_C_EXTENSIONS OFF)
|
set(CMAKE_C_EXTENSIONS OFF)
|
||||||
set(CMAKE_C_STANDARD 11)
|
set(CMAKE_C_STANDARD 11)
|
||||||
|
@ -27,26 +35,11 @@ pkg_check_modules(fontconfig REQUIRED IMPORTED_TARGET fontconfig)
|
||||||
pkg_check_modules(cairo REQUIRED IMPORTED_TARGET cairo cairo-ft)
|
pkg_check_modules(cairo REQUIRED IMPORTED_TARGET cairo cairo-ft)
|
||||||
pkg_check_modules(yaml REQUIRED IMPORTED_TARGET yaml-0.1)
|
pkg_check_modules(yaml REQUIRED IMPORTED_TARGET yaml-0.1)
|
||||||
|
|
||||||
set(ENABLE_X11 1 CACHE BOOL "Enables support for the XCB (X11) backend")
|
|
||||||
set_property(DIRECTORY . APPEND PROPERTY
|
|
||||||
COMPILE_DEFINITIONS $<$<BOOL:${ENABLE_X11}>:ENABLE_X11>)
|
|
||||||
|
|
||||||
if (ENABLE_X11)
|
if (ENABLE_X11)
|
||||||
pkg_check_modules(xcb REQUIRED IMPORTED_TARGET
|
pkg_check_modules(xcb REQUIRED IMPORTED_TARGET
|
||||||
xcb xcb-aux xcb-cursor xcb-event xcb-ewmh xcb-randr xcb-render cairo-xcb)
|
xcb xcb-aux xcb-cursor xcb-event xcb-ewmh xcb-randr xcb-render cairo-xcb)
|
||||||
pkg_check_modules(xcb-errors IMPORTED_TARGET xcb-errors)
|
pkg_check_modules(xcb-errors IMPORTED_TARGET xcb-errors)
|
||||||
endif ()
|
|
||||||
|
|
||||||
set(ENABLE_WAYLAND 1 CACHE BOOL "Enables support for the wayland backend")
|
|
||||||
set_property(DIRECTORY . APPEND PROPERTY
|
|
||||||
COMPILE_DEFINITIONS $<$<BOOL:${ENABLE_WAYLAND}>:ENABLE_WAYLAND>)
|
|
||||||
|
|
||||||
if (ENABLE_WAYLAND)
|
|
||||||
pkg_check_modules(wayland REQUIRED IMPORTED_TARGET
|
|
||||||
wayland-client wayland-cursor wlroots)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
if (ENABLE_X11)
|
|
||||||
add_library(xcb-stuff STATIC EXCLUDE_FROM_ALL xcb.c xcb.h)
|
add_library(xcb-stuff STATIC EXCLUDE_FROM_ALL xcb.c xcb.h)
|
||||||
target_link_libraries(xcb-stuff PkgConfig::xcb)
|
target_link_libraries(xcb-stuff PkgConfig::xcb)
|
||||||
if (XCB_ERRORS_FOUND)
|
if (XCB_ERRORS_FOUND)
|
||||||
|
@ -54,60 +47,15 @@ if (ENABLE_X11)
|
||||||
target_link_libraries(xcb-stuff PkgConfig::xcb-errors)
|
target_link_libraries(xcb-stuff PkgConfig::xcb-errors)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
add_library(bar-xcb STATIC EXCLUDE_FROM_ALL bar/xcb.c bar/xcb.h)
|
|
||||||
target_link_libraries(bar-xcb
|
|
||||||
xcb-stuff PkgConfig::cairo)
|
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (ENABLE_WAYLAND)
|
if (ENABLE_WAYLAND)
|
||||||
function (wayland_protocol _deps)
|
pkg_check_modules(wayland REQUIRED IMPORTED_TARGET
|
||||||
set(deps "")
|
wayland-client wayland-cursor wlroots)
|
||||||
foreach (xml_file ${ARGN})
|
|
||||||
get_filename_component(base ${xml_file} NAME_WE)
|
|
||||||
set(out_c ${base}.c)
|
|
||||||
set(out_h ${base}.h)
|
|
||||||
|
|
||||||
add_custom_command(
|
|
||||||
OUTPUT ${out_h}
|
|
||||||
COMMAND wayland-scanner client-header < ${xml_file} > ${out_h}
|
|
||||||
VERBATIM
|
|
||||||
MAIN_DEPENDENCY ${xml_file}
|
|
||||||
)
|
|
||||||
add_custom_command(
|
|
||||||
OUTPUT ${out_c}
|
|
||||||
COMMAND wayland-scanner private-code < ${xml_file} > ${out_c}
|
|
||||||
VERBATIM
|
|
||||||
MAIN_DEPENDENCY ${xml_file}
|
|
||||||
)
|
|
||||||
|
|
||||||
list(APPEND deps ${out_h})
|
|
||||||
list(APPEND deps ${out_c})
|
|
||||||
endforeach ()
|
|
||||||
|
|
||||||
set(${_deps} ${deps} PARENT_SCOPE)
|
|
||||||
endfunction ()
|
|
||||||
|
|
||||||
execute_process(
|
|
||||||
COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=pkgdatadir wayland-protocols
|
|
||||||
OUTPUT_VARIABLE WAYLAND_PROTOCOLS
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
||||||
|
|
||||||
wayland_protocol(
|
|
||||||
wayland_protos
|
|
||||||
${PROJECT_SOURCE_DIR}/external/wlroots/protocol/wlr-layer-shell-unstable-v1.xml
|
|
||||||
${WAYLAND_PROTOCOLS}/stable/xdg-shell/xdg-shell.xml
|
|
||||||
${WAYLAND_PROTOCOLS}/unstable/xdg-output/xdg-output-unstable-v1.xml
|
|
||||||
)
|
|
||||||
|
|
||||||
add_library(wayland-protocols STATIC EXCLUDE_FROM_ALL ${wayland_protos})
|
|
||||||
target_include_directories(wayland-protocols PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
|
|
||||||
|
|
||||||
add_library(bar-wayland STATIC EXCLUDE_FROM_ALL bar/wayland.c bar/wayland.h)
|
|
||||||
target_compile_definitions(bar-wayland PRIVATE _GNU_SOURCE)
|
|
||||||
target_link_libraries(
|
|
||||||
bar-wayland wayland-protocols PkgConfig::wayland PkgConfig::cairo)
|
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
add_subdirectory(bar)
|
||||||
|
|
||||||
add_executable(f00bar
|
add_executable(f00bar
|
||||||
config.c config.h
|
config.c config.h
|
||||||
config-verify.c config-verify.h
|
config-verify.c config-verify.h
|
||||||
|
@ -120,14 +68,10 @@ add_executable(f00bar
|
||||||
plugin.c plugin.h
|
plugin.c plugin.h
|
||||||
tag.c tag.h
|
tag.c tag.h
|
||||||
yml.c yml.h
|
yml.c yml.h
|
||||||
|
|
||||||
bar.h
|
|
||||||
bar/bar.c bar/private.h bar/backend.h
|
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(f00bar
|
target_link_libraries(f00bar
|
||||||
$<$<BOOL:${ENABLE_X11}>:bar-xcb>
|
bar
|
||||||
$<$<BOOL:${ENABLE_WAYLAND}>:bar-wayland>
|
|
||||||
PkgConfig::cairo PkgConfig::fontconfig PkgConfig::yaml
|
PkgConfig::cairo PkgConfig::fontconfig PkgConfig::yaml
|
||||||
${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS})
|
${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS})
|
||||||
|
|
||||||
|
@ -148,8 +92,6 @@ add_subdirectory(modules)
|
||||||
add_subdirectory(particles)
|
add_subdirectory(particles)
|
||||||
add_subdirectory(decorations)
|
add_subdirectory(decorations)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (NOT CORE_PLUGINS_AS_SHARED_LIBRARIES)
|
if (NOT CORE_PLUGINS_AS_SHARED_LIBRARIES)
|
||||||
target_link_libraries(f00bar ${enabled_decorations})
|
target_link_libraries(f00bar ${enabled_decorations})
|
||||||
target_link_libraries(f00bar ${enabled_particles})
|
target_link_libraries(f00bar ${enabled_particles})
|
||||||
|
|
64
bar/CMakeLists.txt
Normal file
64
bar/CMakeLists.txt
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
cmake_minimum_required(VERSION 3.7)
|
||||||
|
|
||||||
|
# X11/XCB bar backend
|
||||||
|
if (ENABLE_X11)
|
||||||
|
add_library(bar-xcb STATIC EXCLUDE_FROM_ALL xcb.c xcb.h)
|
||||||
|
target_link_libraries(bar-xcb xcb-stuff PkgConfig::cairo)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
# Wayland/wlroots bar backend
|
||||||
|
if (ENABLE_WAYLAND)
|
||||||
|
function (wayland_protocol _deps)
|
||||||
|
set(deps "")
|
||||||
|
foreach (xml_file ${ARGN})
|
||||||
|
get_filename_component(base ${xml_file} NAME_WE)
|
||||||
|
set(out_c ${base}.c)
|
||||||
|
set(out_h ${base}.h)
|
||||||
|
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${out_h}
|
||||||
|
COMMAND wayland-scanner client-header < ${xml_file} > ${out_h}
|
||||||
|
VERBATIM
|
||||||
|
MAIN_DEPENDENCY ${xml_file}
|
||||||
|
)
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${out_c}
|
||||||
|
COMMAND wayland-scanner private-code < ${xml_file} > ${out_c}
|
||||||
|
VERBATIM
|
||||||
|
MAIN_DEPENDENCY ${xml_file}
|
||||||
|
)
|
||||||
|
|
||||||
|
list(APPEND deps ${out_h})
|
||||||
|
list(APPEND deps ${out_c})
|
||||||
|
endforeach ()
|
||||||
|
|
||||||
|
set(${_deps} ${deps} PARENT_SCOPE)
|
||||||
|
endfunction ()
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=pkgdatadir wayland-protocols
|
||||||
|
OUTPUT_VARIABLE WAYLAND_PROTOCOLS
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
|
||||||
|
wayland_protocol(
|
||||||
|
wayland_protos
|
||||||
|
${PROJECT_SOURCE_DIR}/external/wlroots/protocol/wlr-layer-shell-unstable-v1.xml
|
||||||
|
${WAYLAND_PROTOCOLS}/stable/xdg-shell/xdg-shell.xml
|
||||||
|
${WAYLAND_PROTOCOLS}/unstable/xdg-output/xdg-output-unstable-v1.xml
|
||||||
|
)
|
||||||
|
|
||||||
|
add_library(wayland-protocols STATIC EXCLUDE_FROM_ALL ${wayland_protos})
|
||||||
|
target_include_directories(wayland-protocols PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
|
add_library(bar-wayland STATIC EXCLUDE_FROM_ALL wayland.c wayland.h)
|
||||||
|
target_compile_definitions(bar-wayland PRIVATE _GNU_SOURCE)
|
||||||
|
target_link_libraries(
|
||||||
|
bar-wayland wayland-protocols PkgConfig::wayland PkgConfig::cairo)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
add_library(bar STATIC EXCLUDE_FROM_ALL bar.c bar.h private.h backend.h)
|
||||||
|
|
||||||
|
target_link_libraries(bar
|
||||||
|
$<$<BOOL:${ENABLE_X11}>:bar-xcb>
|
||||||
|
$<$<BOOL:${ENABLE_WAYLAND}>:bar-wayland>
|
||||||
|
)
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "../bar.h"
|
#include "bar.h"
|
||||||
|
|
||||||
struct backend {
|
struct backend {
|
||||||
bool (*setup)(struct bar *bar);
|
bool (*setup)(struct bar *bar);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "../bar.h"
|
#include "bar.h"
|
||||||
#include "private.h"
|
#include "private.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "color.h"
|
#include "../color.h"
|
||||||
#include "module.h"
|
#include "../module.h"
|
||||||
|
|
||||||
struct bar {
|
struct bar {
|
||||||
int abort_fd;
|
int abort_fd;
|
|
@ -3,7 +3,7 @@
|
||||||
#include <cairo.h>
|
#include <cairo.h>
|
||||||
#include <cairo-xcb.h>
|
#include <cairo-xcb.h>
|
||||||
|
|
||||||
#include "../bar.h"
|
#include "../bar/bar.h"
|
||||||
#include "backend.h"
|
#include "backend.h"
|
||||||
|
|
||||||
struct private {
|
struct private {
|
||||||
|
|
2
config.c
2
config.c
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
|
|
||||||
#include "bar.h"
|
#include "bar/bar.h"
|
||||||
#include "color.h"
|
#include "color.h"
|
||||||
#include "config-verify.h"
|
#include "config-verify.h"
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
|
|
2
main.c
2
main.c
|
@ -14,7 +14,7 @@
|
||||||
#include <sys/eventfd.h>
|
#include <sys/eventfd.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
|
|
||||||
#include "bar.h"
|
#include "bar/bar.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "yml.h"
|
#include "yml.h"
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#define LOG_MODULE "alsa"
|
#define LOG_MODULE "alsa"
|
||||||
#define LOG_ENABLE_DBG 0
|
#define LOG_ENABLE_DBG 0
|
||||||
#include "../log.h"
|
#include "../log.h"
|
||||||
#include "../bar.h"
|
#include "../bar/bar.h"
|
||||||
#include "../config-verify.h"
|
#include "../config-verify.h"
|
||||||
#include "../config.h"
|
#include "../config.h"
|
||||||
#include "../plugin.h"
|
#include "../plugin.h"
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
#define LOG_MODULE "backlight"
|
#define LOG_MODULE "backlight"
|
||||||
#include "../log.h"
|
#include "../log.h"
|
||||||
#include "../bar.h"
|
#include "../bar/bar.h"
|
||||||
#include "../config.h"
|
#include "../config.h"
|
||||||
#include "../config-verify.h"
|
#include "../config-verify.h"
|
||||||
#include "../plugin.h"
|
#include "../plugin.h"
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
#define LOG_MODULE "battery"
|
#define LOG_MODULE "battery"
|
||||||
#include "../log.h"
|
#include "../log.h"
|
||||||
#include "../bar.h"
|
#include "../bar/bar.h"
|
||||||
#include "../config.h"
|
#include "../config.h"
|
||||||
#include "../config-verify.h"
|
#include "../config-verify.h"
|
||||||
#include "../plugin.h"
|
#include "../plugin.h"
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
|
|
||||||
#include "../bar.h"
|
#include "../bar/bar.h"
|
||||||
#include "../config.h"
|
#include "../config.h"
|
||||||
#include "../config-verify.h"
|
#include "../config-verify.h"
|
||||||
#include "../plugin.h"
|
#include "../plugin.h"
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#define LOG_MODULE "i3"
|
#define LOG_MODULE "i3"
|
||||||
#define LOG_ENABLE_DBG 0
|
#define LOG_ENABLE_DBG 0
|
||||||
#include "../log.h"
|
#include "../log.h"
|
||||||
#include "../bar.h"
|
#include "../bar/bar.h"
|
||||||
#include "../config.h"
|
#include "../config.h"
|
||||||
#include "../config-verify.h"
|
#include "../config-verify.h"
|
||||||
#include "../particles/dynlist.h"
|
#include "../particles/dynlist.h"
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#define LOG_MODULE "mpd"
|
#define LOG_MODULE "mpd"
|
||||||
#define LOG_ENABLE_DBG 0
|
#define LOG_ENABLE_DBG 0
|
||||||
#include "../log.h"
|
#include "../log.h"
|
||||||
#include "../bar.h"
|
#include "../bar/bar.h"
|
||||||
#include "../config.h"
|
#include "../config.h"
|
||||||
#include "../config-verify.h"
|
#include "../config-verify.h"
|
||||||
#include "../plugin.h"
|
#include "../plugin.h"
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#define LOG_MODULE "network"
|
#define LOG_MODULE "network"
|
||||||
#define LOG_ENABLE_DBG 0
|
#define LOG_ENABLE_DBG 0
|
||||||
#include "../log.h"
|
#include "../log.h"
|
||||||
#include "../bar.h"
|
#include "../bar/bar.h"
|
||||||
#include "../config.h"
|
#include "../config.h"
|
||||||
#include "../config-verify.h"
|
#include "../config-verify.h"
|
||||||
#include "../module.h"
|
#include "../module.h"
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#define LOG_MODULE "removables"
|
#define LOG_MODULE "removables"
|
||||||
#define LOG_ENABLE_DBG 0
|
#define LOG_ENABLE_DBG 0
|
||||||
#include "../log.h"
|
#include "../log.h"
|
||||||
#include "../bar.h"
|
#include "../bar/bar.h"
|
||||||
#include "../config.h"
|
#include "../config.h"
|
||||||
#include "../config-verify.h"
|
#include "../config-verify.h"
|
||||||
#include "../particles/dynlist.h"
|
#include "../particles/dynlist.h"
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#define LOG_MODULE "xkb"
|
#define LOG_MODULE "xkb"
|
||||||
#define LOG_ENABLE_DBG 0
|
#define LOG_ENABLE_DBG 0
|
||||||
#include "../log.h"
|
#include "../log.h"
|
||||||
#include "../bar.h"
|
#include "../bar/bar.h"
|
||||||
#include "../config.h"
|
#include "../config.h"
|
||||||
#include "../config-verify.h"
|
#include "../config-verify.h"
|
||||||
#include "../plugin.h"
|
#include "../plugin.h"
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
#define LOG_MODULE "xwindow"
|
#define LOG_MODULE "xwindow"
|
||||||
#include "../log.h"
|
#include "../log.h"
|
||||||
#include "../bar.h"
|
#include "../bar/bar.h"
|
||||||
#include "../config.h"
|
#include "../config.h"
|
||||||
#include "../config-verify.h"
|
#include "../config-verify.h"
|
||||||
#include "../plugin.h"
|
#include "../plugin.h"
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#define LOG_MODULE "particle"
|
#define LOG_MODULE "particle"
|
||||||
#define LOG_ENABLE_DBG 0
|
#define LOG_ENABLE_DBG 0
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "bar.h"
|
#include "bar/bar.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
particle_default_destroy(struct particle *particle)
|
particle_default_destroy(struct particle *particle)
|
||||||
|
|
Loading…
Add table
Reference in a new issue