Add cmake files for configuring individual targets

This makes the code a bit less messy. We barely need if(BUILD_...)
guards inside the cmake files, just the root CMakeLists.txt.
This commit is contained in:
patrick96 2020-12-22 12:19:46 +01:00 committed by Patrick Ziegler
parent 20c88ca977
commit 923d9ae061
10 changed files with 249 additions and 254 deletions

View File

@ -30,24 +30,25 @@ set(CMAKE_MODULE_PATH
include(GNUInstallDirs)
include(utils)
include(00-components)
include(01-core)
include(02-opts)
if (HAS_CXX_COMPILATION)
include(01-core)
endif()
include(03-libs)
include(04-targets)
if(BUILD_DOC)
add_subdirectory(doc)
endif()
add_subdirectory(contrib/bash)
add_subdirectory(contrib/zsh)
if (BUILD_LIBPOLY)
# Setup everything that uses a C++ compile (polybar, polybar-msg, tests)
if(HAS_CXX_COMPILATION)
include(cxx)
if(BUILD_LIBPOLY)
include(libpoly)
add_subdirectory(lib)
endif()
add_subdirectory(include)
add_subdirectory(lib)
endif()
if (HAS_CXX_COMPILATION)
add_subdirectory(src bin)
endif()

View File

@ -1,26 +0,0 @@
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,12 +1,32 @@
#
# Core setup
#
option(DISABLE_ALL "Set this to ON disable all targets. Individual targets can be enabled explicitly." OFF)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS 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()
set(THREADS_PREFER_PTHREAD_FLAG ON)
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()
# Export compile commands used for custom targets
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
@ -17,77 +37,3 @@ if(NOT CMAKE_BUILD_TYPE)
message_colored(STATUS "No build type specified; using ${CMAKE_BUILD_TYPE}" 33)
endif()
string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UPPER)
# Compiler flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wpedantic")
if (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
# Need dprintf() for FreeBSD 11.1 and older
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_WITH_DPRINTF")
# libinotify uses c99 extension, so suppress this error
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c99-extensions")
# Ensures that libraries from dependencies in LOCALBASE are used
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/usr/local/lib")
endif()
if(${CMAKE_CXX_COMPILER_ID} STREQUAL Clang)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=parentheses-equality")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-zero-length-array")
endif()
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g2")
if(${CMAKE_CXX_COMPILER_ID} STREQUAL GNU)
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -fdata-sections -ffunction-sections")
set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} -Wl,--gc-sections,--icf=safe")
endif()
# Check compiler
if(${CMAKE_CXX_COMPILER_ID} STREQUAL Clang)
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.4.0")
message_colored(FATAL_ERROR "Compiler not supported (Requires clang-3.4+ or gcc-5.1+)" 31)
else()
message_colored(STATUS "Using supported compiler ${CMAKE_CXX_COMPILER_ID}-${CMAKE_CXX_COMPILER_VERSION}" 32)
endif()
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL GNU)
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.1.0")
message_colored(FATAL_ERROR "Compiler not supported (Requires clang-3.4+ or gcc-5.1+)" 31)
else()
message_colored(STATUS "Using supported compiler ${CMAKE_CXX_COMPILER_ID}-${CMAKE_CXX_COMPILER_VERSION}" 32)
endif()
else()
message_colored(WARNING "Using unsupported compiler ${CMAKE_CXX_COMPILER_ID}-${CMAKE_CXX_COMPILER_VERSION} !" 31)
endif()
# Set compiler and linker flags for preferred C++ library
if(CXXLIB_CLANG)
message_colored(STATUS "Linking against libc++" 32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lc++ -lc++abi")
elseif(CXXLIB_GCC)
message_colored(STATUS "Linking against libstdc++" 32)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lstdc++")
endif()
# Custom build type ; SANITIZE
SET(CMAKE_CXX_FLAGS_SANITIZE "-O0 -g -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer -fno-optimize-sibling-calls"
CACHE STRING "Flags used by the C++ compiler during sanitize builds." FORCE)
SET(CMAKE_EXE_LINKER_FLAGS_SANITIZE ""
CACHE STRING "Flags used for linking binaries during sanitize builds." FORCE)
SET(CMAKE_SHARED_LINKER_FLAGS_SANITIZE ""
CACHE STRING "Flags used by the shared libraries linker during sanitize builds." FORCE)
MARK_AS_ADVANCED(
CMAKE_CXX_FLAGS_SANITIZE
CMAKE_EXE_LINKER_FLAGS_SANITIZE
CMAKE_SHARED_LINKER_FLAGS_SANITIZE)
# Custom build type ; Coverage
SET(CMAKE_CXX_FLAGS_COVERAGE
"${CMAKE_CXX_FLAGS_DEBUG} ${CMAKE_CXX_FLAGS_COVERAGE} --coverage")
SET(CMAKE_EXE_LINKER_FLAGS_COVERAGE
"${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${CMAKE_EXE_LINKER_FLAGS_COVERAGE}")
SET(CMAKE_SHARED_LINKER_FLAGS_COVERAGE
"${CMAKE_SHARED_LINKER_FLAGS_DEBUG} ${CMAKE_SHARED_LINKER_FLAGS_COVERAGE}")

View File

@ -1,68 +1,3 @@
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.")
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 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()
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(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(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)
endif()
endif()
set(SETTING_ALSA_SOUNDCARD "default"
CACHE STRING "Name of the ALSA soundcard driver")
set(SETTING_BSPWM_SOCKET_PATH "/tmp/bspwm_0_0-socket"

View File

@ -1,73 +1,3 @@
#
# Check libraries
#
if (BUILD_DOC)
find_program(BIN_SPHINX "${SPHINX_BUILD}")
if (NOT BIN_SPHINX)
message(FATAL_ERROR "sphinx-build executable '${SPHINX_BUILD}' not found.")
endif()
endif()
if (BUILD_LIBPOLY)
find_package(Threads REQUIRED)
find_package(CairoFC REQUIRED)
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)
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()

96
cmake/cxx.cmake Normal file
View File

@ -0,0 +1,96 @@
option(ENABLE_CCACHE "Enable ccache support" ON)
if(ENABLE_CCACHE)
find_program(BIN_CCACHE ccache)
mark_as_advanced(BIN_CCACHE)
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)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(THREADS_PREFER_PTHREAD_FLAG ON)
# Compiler flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wpedantic")
if (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
# Need dprintf() for FreeBSD 11.1 and older
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_WITH_DPRINTF")
# libinotify uses c99 extension, so suppress this error
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c99-extensions")
# Ensures that libraries from dependencies in LOCALBASE are used
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/usr/local/lib")
endif()
if(${CMAKE_CXX_COMPILER_ID} STREQUAL Clang)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=parentheses-equality")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-zero-length-array")
endif()
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g2")
if(${CMAKE_CXX_COMPILER_ID} STREQUAL GNU)
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -fdata-sections -ffunction-sections")
set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} -Wl,--gc-sections,--icf=safe")
endif()
# Check compiler
if(${CMAKE_CXX_COMPILER_ID} STREQUAL Clang)
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.4.0")
message_colored(FATAL_ERROR "Compiler not supported (Requires clang-3.4+ or gcc-5.1+)" 31)
else()
message_colored(STATUS "Using supported compiler ${CMAKE_CXX_COMPILER_ID}-${CMAKE_CXX_COMPILER_VERSION}" 32)
endif()
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL GNU)
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.1.0")
message_colored(FATAL_ERROR "Compiler not supported (Requires clang-3.4+ or gcc-5.1+)" 31)
else()
message_colored(STATUS "Using supported compiler ${CMAKE_CXX_COMPILER_ID}-${CMAKE_CXX_COMPILER_VERSION}" 32)
endif()
else()
message_colored(WARNING "Using unsupported compiler ${CMAKE_CXX_COMPILER_ID}-${CMAKE_CXX_COMPILER_VERSION} !" 31)
endif()
# Set compiler and linker flags for preferred C++ library
if(CXXLIB_CLANG)
message_colored(STATUS "Linking against libc++" 32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lc++ -lc++abi")
elseif(CXXLIB_GCC)
message_colored(STATUS "Linking against libstdc++" 32)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lstdc++")
endif()
# Custom build type ; SANITIZE
SET(CMAKE_CXX_FLAGS_SANITIZE "-O0 -g -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer -fno-optimize-sibling-calls"
CACHE STRING "Flags used by the C++ compiler during sanitize builds." FORCE)
SET(CMAKE_EXE_LINKER_FLAGS_SANITIZE ""
CACHE STRING "Flags used for linking binaries during sanitize builds." FORCE)
SET(CMAKE_SHARED_LINKER_FLAGS_SANITIZE ""
CACHE STRING "Flags used by the shared libraries linker during sanitize builds." FORCE)
MARK_AS_ADVANCED(
CMAKE_CXX_FLAGS_SANITIZE
CMAKE_EXE_LINKER_FLAGS_SANITIZE
CMAKE_SHARED_LINKER_FLAGS_SANITIZE)
# Custom build type ; Coverage
SET(CMAKE_CXX_FLAGS_COVERAGE
"${CMAKE_CXX_FLAGS_DEBUG} ${CMAKE_CXX_FLAGS_COVERAGE} --coverage")
SET(CMAKE_EXE_LINKER_FLAGS_COVERAGE
"${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${CMAKE_EXE_LINKER_FLAGS_COVERAGE}")
SET(CMAKE_SHARED_LINKER_FLAGS_COVERAGE
"${CMAKE_SHARED_LINKER_FLAGS_DEBUG} ${CMAKE_SHARED_LINKER_FLAGS_COVERAGE}")

106
cmake/libpoly.cmake Normal file
View File

@ -0,0 +1,106 @@
# Sets up options and dependencies for libpoly
# Automatically enable all optional dependencies that are available on the machine
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(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(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)
endif()
# Load all packages for enabled components
find_package(Threads REQUIRED)
find_package(CairoFC REQUIRED)
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)
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. Searches for randr only because we may do a version check
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()

View File

@ -1,3 +1,12 @@
set(SPHINX_BUILD "sphinx-build" CACHE STRING "Name/Path of the sphinx-build executable to use.")
set(SPHINX_FLAGS "" CACHE STRING "Flags to pass to sphinx-build")
find_program(BIN_SPHINX "${SPHINX_BUILD}")
if(NOT BIN_SPHINX)
message(FATAL_ERROR "sphinx-build executable '${SPHINX_BUILD}' not found.")
endif()
separate_arguments(sphinx_flags UNIX_COMMAND "${SPHINX_FLAGS}")
set(doc_path "${CMAKE_CURRENT_SOURCE_DIR}")

View File

@ -19,7 +19,7 @@ if(WITH_XKB)
endif()
add_subdirectory(xpp)
if (NOT TARGET xpp)
if(NOT TARGET xpp)
message(FATAL_ERROR "Target xpp not generated")
else()
get_target_property(_xpp_includes xpp INCLUDE_DIRECTORIES)
@ -32,7 +32,7 @@ endif()
if(ENABLE_I3)
add_subdirectory(i3ipcpp)
if (NOT TARGET i3ipc++)
if(NOT TARGET i3ipc++)
message(FATAL_ERROR "Target i3ipcpp not generated")
else()
get_target_property(_i3ipcpp_includes i3ipc++ INCLUDE_DIRECTORIES)

View File

@ -5,7 +5,7 @@
get_include_dirs(includes_dir)
get_sources_dirs(src_dir)
if (BUILD_LIBPOLY)
if(BUILD_LIBPOLY)
# Source tree {{{
set(ALSA_SOURCES
@ -169,7 +169,7 @@ if (BUILD_LIBPOLY)
# }}}
# Target: polybar {{{
if (BUILD_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)
@ -194,7 +194,5 @@ if(BUILD_POLYBAR_MSG)
install(TARGETS polybar-msg
DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT runtime)
endif()
# }}}