refactor(cmake): Allow targets to be enabled individually

Each major target of polybar can now be enabled/disabled while
configuring (even polybar itself).

The cmake code specific to each target will only run if the target is
enabled.

This allows us to for example just build the documentation without
having to run all the cmake code related to compilation or having the
polybar dependencies installed (other than sphinx).
This commit is contained in:
patrick96 2020-12-22 03:43:06 +01:00 committed by Patrick Ziegler
parent 771154742c
commit c24a6999a4
14 changed files with 357 additions and 327 deletions

View File

@ -21,9 +21,9 @@ jobs:
run: sudo apt-get install -y python3-sphinx
- name: Build Documentation
run: |
mkdir -p doc/build
cd doc/build
cmake ..
mkdir -p build
cd build
cmake -DDISABLE_ALL=ON -DBUILD_DOC=ON ..
make doc
build:

View File

@ -20,6 +20,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Build
- Bump the minimum cmake version to 3.5
- The `BUILD_IPC_MSG` option has been renamed to `BUILD_POLYBAR_MSG`
- Building the documentation is now enabled by default and not just when
`sphinx-build` is found.
- Users can control exactly which targets should be available with the following
cmake options (together with their default value):
- `BUILD_POLYBAR=ON` - Builds the `polybar` executable
- `BUILD_POLYBAR_MSG=ON` - Builds the `polybar-msg` executable
- `BUILD_TESTS=OFF` - Builds the test suite
- `BUILD_DOC=ON` - Builds the documentation
- `DISABLE_ALL=OFF` - Disables all above targets by default. Individual
targets can still be enabled explicitly.
- The documentation can no longer be built by directly configuring the `doc`
directory.
### Added
- Warn states for the cpu, memory, fs, and battery modules.

View File

@ -4,22 +4,6 @@
cmake_minimum_required(VERSION 3.5.0 FATAL_ERROR)
project(polybar CXX)
option(ENABLE_CCACHE "Enable ccache support" ON)
if(ENABLE_CCACHE)
message(STATUS "Trying to enable ccache")
find_program(BIN_CCACHE ccache)
mark_as_advanced(BIN_CCACHE)
string(ASCII 27 esc)
if(NOT BIN_CCACHE)
message(STATUS "${esc}[33mCouldn't locate ccache, disabling ccache...${esc}[0m")
else()
# Enable only if the binary is found
message(STATUS "${esc}[32mUsing compiler cache ${BIN_CCACHE}${esc}[0m")
set(CMAKE_CXX_COMPILER_LAUNCHER ${BIN_CCACHE} CACHE STRING "")
endif()
endif()
# Extract version information from version.txt. The first line that looks like
# a version string is used, so the file supports comments
file(STRINGS version.txt version_txt REGEX "^[0-9]+\\.[0-9]+\\.[0-9]+.*$" LIMIT_COUNT 1)
@ -46,20 +30,26 @@ set(CMAKE_MODULE_PATH
include(GNUInstallDirs)
include(utils)
include(01-core)
include(00-components)
include(02-opts)
if (HAS_CXX_COMPILATION)
include(01-core)
endif()
include(03-libs)
include(04-targets)
include(05-summary)
if(BUILD_DOC)
add_subdirectory(doc)
endif()
add_subdirectory(contrib/bash)
add_subdirectory(contrib/zsh)
add_subdirectory(include)
add_subdirectory(lib)
add_subdirectory(src bin)
if (BUILD_LIBPOLY)
add_subdirectory(include)
add_subdirectory(lib)
endif()
if (HAS_CXX_COMPILATION)
add_subdirectory(src bin)
endif()
# We need to enable testing in the root folder so that 'ctest' and 'make test'
# can be run in the build directory
@ -68,6 +58,7 @@ if(BUILD_TESTS)
add_subdirectory(tests)
endif()
include(05-summary)
#
# Generate configuration file

View File

@ -149,7 +149,7 @@ set_build_opts() {
read -r -p "$(msg "Build \"polybar-msg\" used to send ipc messages ------------------ [y/N]: ")" -n 1 p && echo
[[ "${p^^}" != "Y" ]] && ENABLE_IPC_MSG="OFF" || ENABLE_IPC_MSG="ON"
fi
if [[ -z "$JOB_COUNT" ]]; then
read -r -p "$(msg "Parallelize the build using make -j$(nproc) --------------------------- [y/N]: ")" -n 1 p && echo
[[ "${p^^}" != "Y" ]] && JOB_COUNT=1 || JOB_COUNT=$(nproc)
@ -200,7 +200,7 @@ main() {
-DENABLE_MPD:BOOL="${ENABLE_MPD}" \
-DENABLE_NETWORK:BOOL="${ENABLE_NETWORK}" \
-DENABLE_CURL:BOOL="${ENABLE_CURL}" \
-DBUILD_IPC_MSG:BOOL="${ENABLE_IPC_MSG}" \
-DBUILD_POLYBAR_MSG:BOOL="${ENABLE_IPC_MSG}" \
.. || msg_err "Failed to generate build... read output to get a hint of what went wrong"
msg "Building project"

26
cmake/00-components.cmake Normal file
View File

@ -0,0 +1,26 @@
option(DISABLE_ALL "Set this to ON disable all targets. Individual targets can be enabled explicitly." OFF)
# If all targets are disabled, we set the default value for options that are on
# by default to OFF
if (DISABLE_ALL)
set(DEFAULT_ON OFF)
else()
set(DEFAULT_ON ON)
endif()
option(BUILD_POLYBAR "Build the main polybar executable" ${DEFAULT_ON})
option(BUILD_POLYBAR_MSG "Build polybar-msg" ${DEFAULT_ON})
option(BUILD_TESTS "Build testsuite" OFF)
option(BUILD_DOC "Build documentation" ${DEFAULT_ON})
if (BUILD_POLYBAR OR BUILD_TESTS)
set(BUILD_LIBPOLY ON)
else()
set(BUILD_LIBPOLY OFF)
endif()
if (BUILD_LIBPOLY OR BUILD_POLYBAR_MSG)
set(HAS_CXX_COMPILATION ON)
else()
set(HAS_CXX_COMPILATION OFF)
endif()

View File

@ -1,59 +1,66 @@
#
# Build options
#
set(SPHINX_FLAGS "" CACHE STRING "Flags to pass to sphinx-build")
set(SPHINX_BUILD "sphinx-build" CACHE STRING "Name/Path of the sphinx-build executable to use.")
checklib(BUILD_DOC "binary" "${SPHINX_BUILD}")
checklib(ENABLE_ALSA "pkg-config" alsa)
checklib(ENABLE_CURL "pkg-config" libcurl)
checklib(ENABLE_I3 "binary" i3)
checklib(ENABLE_MPD "pkg-config" libmpdclient)
checklib(WITH_LIBNL "pkg-config" libnl-genl-3.0)
if(WITH_LIBNL)
checklib(ENABLE_NETWORK "pkg-config" libnl-genl-3.0)
set(WIRELESS_LIB "libnl")
else()
checklib(ENABLE_NETWORK "cmake" Libiw)
set(WIRELESS_LIB "wireless-tools")
endif()
checklib(ENABLE_PULSEAUDIO "pkg-config" libpulse)
checklib(WITH_XKB "pkg-config" xcb-xkb)
checklib(WITH_XRM "pkg-config" xcb-xrm)
checklib(WITH_XRANDR_MONITORS "pkg-config" "xcb-randr>=1.12")
checklib(WITH_XCURSOR "pkg-config" "xcb-cursor")
if (HAS_CXX_COMPILATION)
option(ENABLE_CCACHE "Enable ccache support" ON)
if(ENABLE_CCACHE)
find_program(BIN_CCACHE ccache)
mark_as_advanced(BIN_CCACHE)
if(NOT DEFINED ENABLE_CCACHE AND CMAKE_BUILD_TYPE_UPPER MATCHES DEBUG)
set(ENABLE_CCACHE ON)
if(NOT BIN_CCACHE)
message_colored(STATUS "Couldn't locate ccache, disabling ccache..." "33")
else()
# Enable only if the binary is found
message_colored(STATUS "Using compiler cache ${BIN_CCACHE}" "32")
set(CMAKE_CXX_COMPILER_LAUNCHER ${BIN_CCACHE} CACHE STRING "")
endif()
endif()
option(CXXLIB_CLANG "Link against libc++" OFF)
option(CXXLIB_GCC "Link against stdlibc++" OFF)
endif()
option(CXXLIB_CLANG "Link against libc++" OFF)
option(CXXLIB_GCC "Link against stdlibc++" OFF)
if (BUILD_LIBPOLY)
checklib(ENABLE_ALSA "pkg-config" alsa)
checklib(ENABLE_CURL "pkg-config" libcurl)
checklib(ENABLE_I3 "binary" i3)
checklib(ENABLE_MPD "pkg-config" libmpdclient)
checklib(WITH_LIBNL "pkg-config" libnl-genl-3.0)
if(WITH_LIBNL)
checklib(ENABLE_NETWORK "pkg-config" libnl-genl-3.0)
set(WIRELESS_LIB "libnl")
else()
checklib(ENABLE_NETWORK "cmake" Libiw)
set(WIRELESS_LIB "wireless-tools")
endif()
checklib(ENABLE_PULSEAUDIO "pkg-config" libpulse)
checklib(WITH_XKB "pkg-config" xcb-xkb)
checklib(WITH_XRM "pkg-config" xcb-xrm)
checklib(WITH_XRANDR_MONITORS "pkg-config" "xcb-randr>=1.12")
checklib(WITH_XCURSOR "pkg-config" "xcb-cursor")
option(BUILD_IPC_MSG "Build ipc messager" ON)
option(BUILD_TESTS "Build testsuite" OFF)
option(BUILD_DOC "Build documentation" ON)
option(ENABLE_ALSA "Enable alsa support" ON)
option(ENABLE_CURL "Enable curl support" ON)
option(ENABLE_I3 "Enable i3 support" ON)
option(ENABLE_MPD "Enable mpd support" ON)
option(WITH_LIBNL "Use netlink interface for wireless" ON)
option(ENABLE_NETWORK "Enable network support" ON)
option(ENABLE_XKEYBOARD "Enable xkeyboard support" ON)
option(ENABLE_PULSEAUDIO "Enable PulseAudio support" ON)
option(ENABLE_ALSA "Enable alsa support" ON)
option(ENABLE_CURL "Enable curl support" ON)
option(ENABLE_I3 "Enable i3 support" ON)
option(ENABLE_MPD "Enable mpd support" ON)
option(WITH_LIBNL "Use netlink interface for wireless" ON)
option(ENABLE_NETWORK "Enable network support" ON)
option(ENABLE_XKEYBOARD "Enable xkeyboard support" ON)
option(ENABLE_PULSEAUDIO "Enable PulseAudio support" ON)
option(WITH_XRANDR_MONITORS "xcb-randr monitor support" ON)
option(WITH_XKB "xcb-xkb support" ON)
option(WITH_XRM "xcb-xrm support" ON)
option(WITH_XCURSOR "xcb-cursor support" ON)
option(WITH_XRANDR_MONITORS "xcb-randr monitor support" ON)
option(WITH_XKB "xcb-xkb support" ON)
option(WITH_XRM "xcb-xrm support" ON)
option(WITH_XCURSOR "xcb-cursor support" ON)
option(DEBUG_LOGGER "Trace logging" ON)
option(DEBUG_LOGGER "Trace logging" ON)
if(CMAKE_BUILD_TYPE_UPPER MATCHES DEBUG)
option(DEBUG_LOGGER_VERBOSE "Trace logging (verbose)" OFF)
option(DEBUG_HINTS "Debug clickable areas" OFF)
option(DEBUG_WHITESPACE "Debug whitespace" OFF)
option(DEBUG_FONTCONFIG "Debug fontconfig" OFF)
if(CMAKE_BUILD_TYPE_UPPER MATCHES DEBUG)
option(DEBUG_LOGGER_VERBOSE "Trace logging (verbose)" OFF)
option(DEBUG_HINTS "Debug clickable areas" OFF)
option(DEBUG_WHITESPACE "Debug whitespace" OFF)
option(DEBUG_FONTCONFIG "Debug fontconfig" OFF)
endif()
endif()
set(SETTING_ALSA_SOUNDCARD "default"

View File

@ -2,62 +2,72 @@
# Check libraries
#
find_package(Threads REQUIRED)
find_package(CairoFC REQUIRED)
if (BUILD_DOC)
find_program(BIN_SPHINX "${SPHINX_BUILD}")
if (ENABLE_ALSA)
find_package(ALSA REQUIRED)
set(ALSA_VERSION ${ALSA_VERSION_STRING})
endif()
if (ENABLE_CURL)
find_package(CURL REQUIRED)
set(CURL_VERSION ${CURL_VERSION_STRING})
endif()
if (ENABLE_MPD)
find_package(LibMPDClient REQUIRED)
set(MPD_VERSION ${LibMPDClient_VERSION})
endif()
if (ENABLE_NETWORK)
if(WITH_LIBNL)
find_package(LibNlGenl3 REQUIRED)
set(NETWORK_LIBRARY_VERSION ${LibNlGenl3_VERSION})
else()
find_package(Libiw REQUIRED)
if (NOT BIN_SPHINX)
message(FATAL_ERROR "sphinx-build executable '${SPHINX_BUILD}' not found.")
endif()
endif()
if (ENABLE_PULSEAUDIO)
find_package(LibPulse REQUIRED)
set(PULSEAUDIO_VERSION ${LibPulse_VERSION})
endif()
if (BUILD_LIBPOLY)
find_package(Threads REQUIRED)
find_package(CairoFC REQUIRED)
# xcomposite is required
list(APPEND XORG_EXTENSIONS COMPOSITE)
if (WITH_XKB)
list(APPEND XORG_EXTENSIONS XKB)
endif()
if (WITH_XCURSOR)
list(APPEND XORG_EXTENSIONS CURSOR)
endif()
if (WITH_XRM)
list(APPEND XORG_EXTENSIONS XRM)
endif()
if (ENABLE_ALSA)
find_package(ALSA REQUIRED)
set(ALSA_VERSION ${ALSA_VERSION_STRING})
endif()
# Set min xrandr version required
if (WITH_XRANDR_MONITORS)
set(XRANDR_VERSION "1.12")
else ()
set(XRANDR_VERSION "")
endif()
if (ENABLE_CURL)
find_package(CURL REQUIRED)
set(CURL_VERSION ${CURL_VERSION_STRING})
endif()
# Randr is required
find_package(Xcb ${XRANDR_VERSION} REQUIRED COMPONENTS RANDR)
find_package(Xcb REQUIRED COMPONENTS ${XORG_EXTENSIONS})
if (ENABLE_MPD)
find_package(LibMPDClient REQUIRED)
set(MPD_VERSION ${LibMPDClient_VERSION})
endif()
# FreeBSD Support
if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
find_package(LibInotify REQUIRED)
if (ENABLE_NETWORK)
if(WITH_LIBNL)
find_package(LibNlGenl3 REQUIRED)
set(NETWORK_LIBRARY_VERSION ${LibNlGenl3_VERSION})
else()
find_package(Libiw REQUIRED)
endif()
endif()
if (ENABLE_PULSEAUDIO)
find_package(LibPulse REQUIRED)
set(PULSEAUDIO_VERSION ${LibPulse_VERSION})
endif()
# xcomposite is required
list(APPEND XORG_EXTENSIONS COMPOSITE)
if (WITH_XKB)
list(APPEND XORG_EXTENSIONS XKB)
endif()
if (WITH_XCURSOR)
list(APPEND XORG_EXTENSIONS CURSOR)
endif()
if (WITH_XRM)
list(APPEND XORG_EXTENSIONS XRM)
endif()
# Set min xrandr version required
if (WITH_XRANDR_MONITORS)
set(XRANDR_VERSION "1.12")
else ()
set(XRANDR_VERSION "")
endif()
# Randr is required
find_package(Xcb ${XRANDR_VERSION} REQUIRED COMPONENTS RANDR)
find_package(Xcb REQUIRED COMPONENTS ${XORG_EXTENSIONS})
# FreeBSD Support
if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
find_package(LibInotify REQUIRED)
endif()
endif()

View File

@ -5,8 +5,13 @@
message(STATUS " Build:")
message_colored(STATUS " Version: ${APP_VERSION}" "32;1")
message_colored(STATUS " Type: ${CMAKE_BUILD_TYPE}" "37;2")
message_colored(STATUS " CXX: ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UPPER}}" "37;2")
message_colored(STATUS " LD: ${CMAKE_LINKER} ${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_${CMAKE_BUILD_TYPE_UPPER}}" "37;2")
if (HAS_CXX_COMPILATION)
message_colored(STATUS " CXX: ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UPPER}}" "37;2")
message_colored(STATUS " LD: ${CMAKE_LINKER} ${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_${CMAKE_BUILD_TYPE_UPPER}}" "37;2")
endif()
if (BUILD_DOC)
message_colored(STATUS " sphinx-build: ${BIN_SPHINX} ${SPHINX_FLAGS}" "37;2")
endif()
message(STATUS " Install Paths:")
message_colored(STATUS " PREFIX: ${CMAKE_INSTALL_PREFIX}" "32")
@ -16,34 +21,37 @@ message_colored(STATUS " DOCDIR: ${CMAKE_INSTALL_FULL_DOCDIR}" "32")
message_colored(STATUS " MANDIR: ${CMAKE_INSTALL_FULL_MANDIR}" "32")
message(STATUS " Targets:")
colored_option(" polybar-msg" BUILD_IPC_MSG)
colored_option(" polybar" BUILD_POLYBAR)
colored_option(" polybar-msg" BUILD_POLYBAR_MSG)
colored_option(" testsuite" BUILD_TESTS)
colored_option(" documentation" BUILD_DOC)
message(STATUS " Module support:")
colored_option(" alsa" ENABLE_ALSA ALSA_VERSION)
colored_option(" curl" ENABLE_CURL CURL_VERSION)
colored_option(" i3" ENABLE_I3)
colored_option(" mpd" ENABLE_MPD MPD_VERSION)
colored_option(" network (${WIRELESS_LIB})" ENABLE_NETWORK NETWORK_LIBRARY_VERSION)
colored_option(" pulseaudio" ENABLE_PULSEAUDIO PULSEAUDIO_VERSION)
colored_option(" xkeyboard" WITH_XKB Xcb_XKB_VERSION)
if (BUILD_LIBPOLY)
message(STATUS " Module support:")
colored_option(" alsa" ENABLE_ALSA ALSA_VERSION)
colored_option(" curl" ENABLE_CURL CURL_VERSION)
colored_option(" i3" ENABLE_I3)
colored_option(" mpd" ENABLE_MPD MPD_VERSION)
colored_option(" network (${WIRELESS_LIB})" ENABLE_NETWORK NETWORK_LIBRARY_VERSION)
colored_option(" pulseaudio" ENABLE_PULSEAUDIO PULSEAUDIO_VERSION)
colored_option(" xkeyboard" WITH_XKB Xcb_XKB_VERSION)
message(STATUS " X extensions:")
colored_option(" xcb-randr" Xcb_RANDR_FOUND Xcb_RANDR_VERSION)
colored_option(" xcb-randr (monitor support)" WITH_XRANDR_MONITORS Xcb_RANDR_VERSION)
colored_option(" xcb-composite" Xcb_COMPOSITE_FOUND Xcb_COMPOSITE_VERSION)
colored_option(" xcb-xkb" WITH_XKB Xcb_XKB_VERSION)
colored_option(" xcb-xrm" WITH_XRM Xcb_XRM_VERSION)
colored_option(" xcb-cursor" WITH_XCURSOR Xcb_CURSOR_VERSION)
message(STATUS " X extensions:")
colored_option(" xcb-randr" Xcb_RANDR_FOUND Xcb_RANDR_VERSION)
colored_option(" xcb-randr (monitor support)" WITH_XRANDR_MONITORS Xcb_RANDR_VERSION)
colored_option(" xcb-composite" Xcb_COMPOSITE_FOUND Xcb_COMPOSITE_VERSION)
colored_option(" xcb-xkb" WITH_XKB Xcb_XKB_VERSION)
colored_option(" xcb-xrm" WITH_XRM Xcb_XRM_VERSION)
colored_option(" xcb-cursor" WITH_XCURSOR Xcb_CURSOR_VERSION)
message(STATUS " Log options:")
colored_option(" Trace logging" DEBUG_LOGGER)
message(STATUS " Log options:")
colored_option(" Trace logging" DEBUG_LOGGER)
if(CMAKE_BUILD_TYPE_UPPER MATCHES DEBUG)
message(STATUS " Debug options:")
colored_option(" Trace logging (verbose)" DEBUG_LOGGER_VERBOSE)
colored_option(" Draw clickable areas" DEBUG_HINTS)
colored_option(" Print fc-match details" DEBUG_FONTCONFIG)
colored_option(" Enable window shading" DEBUG_SHADED)
if(CMAKE_BUILD_TYPE_UPPER MATCHES DEBUG)
message(STATUS " Debug options:")
colored_option(" Trace logging (verbose)" DEBUG_LOGGER_VERBOSE)
colored_option(" Draw clickable areas" DEBUG_HINTS)
colored_option(" Print fc-match details" DEBUG_FONTCONFIG)
colored_option(" Enable window shading" DEBUG_SHADED)
endif()
endif()

View File

@ -31,7 +31,7 @@ cmake \
-DCMAKE_CXX_FLAGS="${CXXFLAGS} -Werror" \
-DCMAKE_BUILD_TYPE="${BUILD_TYPE}" \
-DBUILD_TESTS:BOOL="${BUILD_TESTS:-OFF}" \
-DBUILD_DOC:BOOL="${BUILD_DOC:-OFF}" \
-DBUILD_DOC:BOOL=OFF \
-DENABLE_PULSEAUDIO="${ENABLE_PULSEAUDIO:-OFF}" \
-DENABLE_NETWORK="${ENABLE_NETWORK:-OFF}" \
-DENABLE_MPD="${ENABLE_MPD:-OFF}" \

View File

@ -1,13 +1,3 @@
cmake_minimum_required(VERSION 3.5.0 FATAL_ERROR)
# Only used if documentation is built on its own
project(polybar-doc NONE)
if(NOT SPHINX_BUILD)
set(SPHINX_BUILD "sphinx-build")
endif()
set(SPHINX_FLAGS "" CACHE STRING "Flags to pass to sphinx-build")
separate_arguments(sphinx_flags UNIX_COMMAND "${SPHINX_FLAGS}")
set(doc_path "${CMAKE_CURRENT_SOURCE_DIR}")
@ -25,7 +15,7 @@ foreach(builder ${doc_builders})
set(doc_target "doc_${builder}")
set(builder_log "builder-${builder}.log")
add_custom_target(${doc_target}
COMMAND ${SPHINX_BUILD}
COMMAND ${BIN_SPHINX}
-b ${builder}
# conf.py dir
-c "${CMAKE_CURRENT_BINARY_DIR}"
@ -43,19 +33,6 @@ endforeach()
# Dummy target that depends on all documentation targets
add_custom_target(doc ALL DEPENDS ${doc_targets})
# This is needed for the case where only the doc target is built
# CMAKE_INSTALL_DOCDIR uses PROJECT_NAME which is now polybar-doc, to be
# consistent with a regular install we temporarily override it with "polybar"
# before including GNUInstallDirs
# Also since no language is set and GNUInstallDirs cannot set
# CMAKE_INSTALL_LIBDIR, so we set it to a dummy value to suppress a warning
if(${CMAKE_PROJECT_NAME} STREQUAL "polybar-doc")
set(PROJECT_NAME "polybar")
set(CMAKE_INSTALL_LIBDIR "")
include(GNUInstallDirs)
set(PROJECT_NAME "polybar-doc")
endif()
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/
DESTINATION ${CMAKE_INSTALL_DOCDIR}
COMPONENT doc)

View File

@ -13,9 +13,6 @@ have that installed.
If you build polybar normally while having Sphinx installed during configuration, the documentation will be enabled and
built as well. Building the documentation can be disabled by passing `-DBUILD_DOC=OFF` to `cmake`.
Alternatively the documentation can be built without the rest of polybar, for that run `cmake` only on the `doc`
directory. For example, create a `build` directory in `doc` and then run `cmake ..` in there.
Once configured, all of the documentation can be generated with `make doc` or use `make doc_html` or `make doc_man` to
only generate the html documentation or the man pages respectively.

View File

@ -13,5 +13,3 @@ configure_file(
${CMAKE_CURRENT_LIST_DIR}/settings.hpp.cmake
${CMAKE_BINARY_DIR}/generated-sources/settings.hpp
ESCAPE_QUOTES)
set(APP_VERSION ${APP_VERSION} PARENT_SCOPE)

View File

@ -2,183 +2,187 @@
# Configure src
#
# Source tree {{{
get_include_dirs(includes_dir)
get_sources_dirs(src_dir)
set(ALSA_SOURCES
${src_dir}/adapters/alsa/control.cpp
${src_dir}/adapters/alsa/mixer.cpp
${src_dir}/modules/alsa.cpp
)
if (BUILD_LIBPOLY)
# Source tree {{{
set(GITHUB_SOURCES ${src_dir}/modules/github.cpp ${src_dir}/utils/http.cpp)
set(ALSA_SOURCES
${src_dir}/adapters/alsa/control.cpp
${src_dir}/adapters/alsa/mixer.cpp
${src_dir}/modules/alsa.cpp
)
set(I3_SOURCES
${src_dir}/modules/i3.cpp
${src_dir}/utils/i3.cpp
)
set(GITHUB_SOURCES ${src_dir}/modules/github.cpp ${src_dir}/utils/http.cpp)
set(MPD_SOURCES
${src_dir}/adapters/mpd.cpp
${src_dir}/modules/mpd.cpp
)
set(I3_SOURCES
${src_dir}/modules/i3.cpp
${src_dir}/utils/i3.cpp
)
set(NETWORK_SOURCES
${src_dir}/adapters/net.cpp
${src_dir}/modules/network.cpp
$<IF:$<BOOL:${WITH_LIBNL}>,${src_dir}/adapters/net_nl.cpp,${src_dir}/adapters/net_iw.cpp>
)
set(MPD_SOURCES
${src_dir}/adapters/mpd.cpp
${src_dir}/modules/mpd.cpp
)
set(PULSEAUDIO_SOURCES
${src_dir}/adapters/pulseaudio.cpp
${src_dir}/modules/pulseaudio.cpp
)
set(NETWORK_SOURCES
${src_dir}/adapters/net.cpp
${src_dir}/modules/network.cpp
$<IF:$<BOOL:${WITH_LIBNL}>,${src_dir}/adapters/net_nl.cpp,${src_dir}/adapters/net_iw.cpp>
)
set(XCURSOR_SOURCES ${src_dir}/x11/cursor.cpp)
set(PULSEAUDIO_SOURCES
${src_dir}/adapters/pulseaudio.cpp
${src_dir}/modules/pulseaudio.cpp
)
set(XKB_SOURCES
${src_dir}/modules/xkeyboard.cpp
${src_dir}/x11/extensions/xkb.cpp
)
set(XCURSOR_SOURCES ${src_dir}/x11/cursor.cpp)
set(XRM_SOURCES ${src_dir}/x11/xresources.cpp)
set(XKB_SOURCES
${src_dir}/modules/xkeyboard.cpp
${src_dir}/x11/extensions/xkb.cpp
)
configure_file(
${CMAKE_CURRENT_LIST_DIR}/settings.cpp.cmake
${CMAKE_BINARY_DIR}/generated-sources/settings.cpp
ESCAPE_QUOTES)
set(XRM_SOURCES ${src_dir}/x11/xresources.cpp)
set(POLY_SOURCES
${CMAKE_BINARY_DIR}/generated-sources/settings.cpp
configure_file(
${CMAKE_CURRENT_LIST_DIR}/settings.cpp.cmake
${CMAKE_BINARY_DIR}/generated-sources/settings.cpp
ESCAPE_QUOTES)
${src_dir}/cairo/utils.cpp
set(POLY_SOURCES
${CMAKE_BINARY_DIR}/generated-sources/settings.cpp
${src_dir}/components/bar.cpp
${src_dir}/components/builder.cpp
${src_dir}/components/command_line.cpp
${src_dir}/components/config.cpp
${src_dir}/components/config_parser.cpp
${src_dir}/components/controller.cpp
${src_dir}/components/ipc.cpp
${src_dir}/components/logger.cpp
${src_dir}/components/renderer.cpp
${src_dir}/components/screen.cpp
${src_dir}/components/taskqueue.cpp
${src_dir}/cairo/utils.cpp
${src_dir}/drawtypes/animation.cpp
${src_dir}/drawtypes/iconset.cpp
${src_dir}/drawtypes/label.cpp
${src_dir}/drawtypes/progressbar.cpp
${src_dir}/drawtypes/ramp.cpp
${src_dir}/components/bar.cpp
${src_dir}/components/builder.cpp
${src_dir}/components/command_line.cpp
${src_dir}/components/config.cpp
${src_dir}/components/config_parser.cpp
${src_dir}/components/controller.cpp
${src_dir}/components/ipc.cpp
${src_dir}/components/logger.cpp
${src_dir}/components/renderer.cpp
${src_dir}/components/screen.cpp
${src_dir}/components/taskqueue.cpp
${src_dir}/events/signal_emitter.cpp
${src_dir}/events/signal_receiver.cpp
${src_dir}/drawtypes/animation.cpp
${src_dir}/drawtypes/iconset.cpp
${src_dir}/drawtypes/label.cpp
${src_dir}/drawtypes/progressbar.cpp
${src_dir}/drawtypes/ramp.cpp
${src_dir}/modules/backlight.cpp
${src_dir}/modules/battery.cpp
${src_dir}/modules/bspwm.cpp
${src_dir}/modules/counter.cpp
${src_dir}/modules/cpu.cpp
${src_dir}/modules/date.cpp
${src_dir}/modules/fs.cpp
${src_dir}/modules/ipc.cpp
${src_dir}/modules/memory.cpp
${src_dir}/modules/menu.cpp
${src_dir}/modules/meta/base.cpp
${src_dir}/modules/script.cpp
${src_dir}/modules/systray.cpp
${src_dir}/modules/temperature.cpp
${src_dir}/modules/text.cpp
${src_dir}/modules/xbacklight.cpp
${src_dir}/modules/xwindow.cpp
${src_dir}/modules/xworkspaces.cpp
${src_dir}/events/signal_emitter.cpp
${src_dir}/events/signal_receiver.cpp
${src_dir}/tags/dispatch.cpp
${src_dir}/tags/parser.cpp
${src_dir}/modules/backlight.cpp
${src_dir}/modules/battery.cpp
${src_dir}/modules/bspwm.cpp
${src_dir}/modules/counter.cpp
${src_dir}/modules/cpu.cpp
${src_dir}/modules/date.cpp
${src_dir}/modules/fs.cpp
${src_dir}/modules/ipc.cpp
${src_dir}/modules/memory.cpp
${src_dir}/modules/menu.cpp
${src_dir}/modules/meta/base.cpp
${src_dir}/modules/script.cpp
${src_dir}/modules/systray.cpp
${src_dir}/modules/temperature.cpp
${src_dir}/modules/text.cpp
${src_dir}/modules/xbacklight.cpp
${src_dir}/modules/xwindow.cpp
${src_dir}/modules/xworkspaces.cpp
${src_dir}/utils/actions.cpp
${src_dir}/utils/bspwm.cpp
${src_dir}/utils/color.cpp
${src_dir}/utils/command.cpp
${src_dir}/utils/concurrency.cpp
${src_dir}/utils/env.cpp
${src_dir}/utils/factory.cpp
${src_dir}/utils/file.cpp
${src_dir}/utils/inotify.cpp
${src_dir}/utils/io.cpp
${src_dir}/utils/process.cpp
${src_dir}/utils/socket.cpp
${src_dir}/utils/string.cpp
${src_dir}/utils/throttle.cpp
${src_dir}/tags/dispatch.cpp
${src_dir}/tags/parser.cpp
${src_dir}/x11/atoms.cpp
${src_dir}/x11/background_manager.cpp
${src_dir}/x11/connection.cpp
${src_dir}/x11/ewmh.cpp
${src_dir}/x11/extensions/composite.cpp
${src_dir}/x11/extensions/randr.cpp
${src_dir}/x11/icccm.cpp
${src_dir}/x11/registry.cpp
${src_dir}/x11/tray_client.cpp
${src_dir}/x11/tray_manager.cpp
${src_dir}/x11/window.cpp
${src_dir}/x11/winspec.cpp
${src_dir}/x11/xembed.cpp
${src_dir}/utils/actions.cpp
${src_dir}/utils/bspwm.cpp
${src_dir}/utils/color.cpp
${src_dir}/utils/command.cpp
${src_dir}/utils/concurrency.cpp
${src_dir}/utils/env.cpp
${src_dir}/utils/factory.cpp
${src_dir}/utils/file.cpp
${src_dir}/utils/inotify.cpp
${src_dir}/utils/io.cpp
${src_dir}/utils/process.cpp
${src_dir}/utils/socket.cpp
${src_dir}/utils/string.cpp
${src_dir}/utils/throttle.cpp
$<$<BOOL:${ENABLE_ALSA}>:${ALSA_SOURCES}>
$<$<BOOL:${ENABLE_CURL}>:${GITHUB_SOURCES}>
$<$<BOOL:${ENABLE_I3}>:${I3_SOURCES}>
$<$<BOOL:${ENABLE_MPD}>:${MPD_SOURCES}>
$<$<BOOL:${ENABLE_NETWORK}>:${NETWORK_SOURCES}>
$<$<BOOL:${ENABLE_PULSEAUDIO}>:${PULSEAUDIO_SOURCES}>
$<$<BOOL:${WITH_XCURSOR}>:${XCURSOR_SOURCES}>
$<$<BOOL:${WITH_XKB}>:${XKB_SOURCES}>
$<$<BOOL:${WITH_XRM}>:${XRM_SOURCES}>
)
${src_dir}/x11/atoms.cpp
${src_dir}/x11/background_manager.cpp
${src_dir}/x11/connection.cpp
${src_dir}/x11/ewmh.cpp
${src_dir}/x11/extensions/composite.cpp
${src_dir}/x11/extensions/randr.cpp
${src_dir}/x11/icccm.cpp
${src_dir}/x11/registry.cpp
${src_dir}/x11/tray_client.cpp
${src_dir}/x11/tray_manager.cpp
${src_dir}/x11/window.cpp
${src_dir}/x11/winspec.cpp
${src_dir}/x11/xembed.cpp
# }}}
$<$<BOOL:${ENABLE_ALSA}>:${ALSA_SOURCES}>
$<$<BOOL:${ENABLE_CURL}>:${GITHUB_SOURCES}>
$<$<BOOL:${ENABLE_I3}>:${I3_SOURCES}>
$<$<BOOL:${ENABLE_MPD}>:${MPD_SOURCES}>
$<$<BOOL:${ENABLE_NETWORK}>:${NETWORK_SOURCES}>
$<$<BOOL:${ENABLE_PULSEAUDIO}>:${PULSEAUDIO_SOURCES}>
$<$<BOOL:${WITH_XCURSOR}>:${XCURSOR_SOURCES}>
$<$<BOOL:${WITH_XKB}>:${XKB_SOURCES}>
$<$<BOOL:${WITH_XRM}>:${XRM_SOURCES}>
)
# Target: polybar {{{
# }}}
add_library(poly STATIC ${POLY_SOURCES})
target_include_directories(poly PUBLIC ${includes_dir})
target_link_libraries(poly PUBLIC
Threads::Threads
Cairo::CairoFC
moodycamel
xpp
$<$<TARGET_EXISTS:i3ipc++>:i3ipc++>
$<$<TARGET_EXISTS:ALSA::ALSA>:ALSA::ALSA>
$<$<TARGET_EXISTS:CURL::libcurl>:CURL::libcurl>
$<$<TARGET_EXISTS:LibMPDClient::LibMPDClient>:LibMPDClient::LibMPDClient>
$<$<TARGET_EXISTS:LibNlGenl3::LibNlGenl3>:LibNlGenl3::LibNlGenl3>
$<$<TARGET_EXISTS:Libiw::Libiw>:Libiw::Libiw>
$<$<TARGET_EXISTS:LibPulse::LibPulse>:LibPulse::LibPulse>
$<$<TARGET_EXISTS:Xcb::RANDR>:Xcb::RANDR>
$<$<TARGET_EXISTS:Xcb::COMPOSITE>:Xcb::COMPOSITE>
$<$<TARGET_EXISTS:Xcb::XKB>:Xcb::XKB>
$<$<TARGET_EXISTS:Xcb::CURSOR>:Xcb::CURSOR>
$<$<TARGET_EXISTS:Xcb::XRM>:Xcb::XRM>
$<$<TARGET_EXISTS:LibInotify::LibInotify>:LibInotify::LibInotify>
)
# Target poly {{{
add_library(poly STATIC EXCLUDE_FROM_ALL ${POLY_SOURCES})
target_include_directories(poly PUBLIC ${includes_dir})
target_link_libraries(poly PUBLIC
Threads::Threads
Cairo::CairoFC
moodycamel
xpp
$<$<TARGET_EXISTS:i3ipc++>:i3ipc++>
$<$<TARGET_EXISTS:ALSA::ALSA>:ALSA::ALSA>
$<$<TARGET_EXISTS:CURL::libcurl>:CURL::libcurl>
$<$<TARGET_EXISTS:LibMPDClient::LibMPDClient>:LibMPDClient::LibMPDClient>
$<$<TARGET_EXISTS:LibNlGenl3::LibNlGenl3>:LibNlGenl3::LibNlGenl3>
$<$<TARGET_EXISTS:Libiw::Libiw>:Libiw::Libiw>
$<$<TARGET_EXISTS:LibPulse::LibPulse>:LibPulse::LibPulse>
$<$<TARGET_EXISTS:Xcb::RANDR>:Xcb::RANDR>
$<$<TARGET_EXISTS:Xcb::COMPOSITE>:Xcb::COMPOSITE>
$<$<TARGET_EXISTS:Xcb::XKB>:Xcb::XKB>
$<$<TARGET_EXISTS:Xcb::CURSOR>:Xcb::CURSOR>
$<$<TARGET_EXISTS:Xcb::XRM>:Xcb::XRM>
$<$<TARGET_EXISTS:LibInotify::LibInotify>:LibInotify::LibInotify>
)
target_compile_options(poly PUBLIC $<$<CXX_COMPILER_ID:GNU>:$<$<CONFIG:MinSizeRel>:-flto>>)
set_target_properties(poly PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/libs)
target_compile_options(poly PUBLIC $<$<CXX_COMPILER_ID:GNU>:$<$<CONFIG:MinSizeRel>:-flto>>)
set_target_properties(poly PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/libs)
# }}}
add_executable(polybar main.cpp)
target_link_libraries(polybar poly)
set_target_properties(poly PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
# Target: polybar {{{
if (BUILD_POLYBAR)
add_executable(polybar main.cpp)
target_link_libraries(polybar poly)
set_target_properties(poly PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
install(TARGETS polybar
DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT runtime)
install(TARGETS polybar
DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT runtime)
endif()
# }}}
endif()
# }}}
# Target: polybar-msg {{{
if(BUILD_IPC_MSG)
if(BUILD_POLYBAR_MSG)
add_executable(polybar-msg
ipc.cpp
utils/env.cpp

View File

@ -6,7 +6,6 @@
#include "common.hpp"
#include "utils/file.hpp"
#include "utils/io.hpp"
using namespace polybar;
using namespace std;