2016-05-19 14:41:06 +00:00
|
|
|
#
|
|
|
|
# Build configuration
|
|
|
|
#
|
2020-12-22 00:58:21 +00:00
|
|
|
cmake_minimum_required(VERSION 3.5.0 FATAL_ERROR)
|
2020-12-22 00:59:26 +00:00
|
|
|
project(polybar CXX)
|
2016-05-24 12:24:45 +00:00
|
|
|
|
2018-05-12 14:29:14 +00:00
|
|
|
option(ENABLE_CCACHE "Enable ccache support" ON)
|
|
|
|
if(ENABLE_CCACHE)
|
|
|
|
message(STATUS "Trying to enable ccache")
|
|
|
|
find_program(BIN_CCACHE ccache)
|
2020-12-22 00:59:26 +00:00
|
|
|
mark_as_advanced(BIN_CCACHE)
|
2018-05-12 14:29:14 +00:00
|
|
|
|
|
|
|
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")
|
2020-12-22 00:59:26 +00:00
|
|
|
set(CMAKE_CXX_COMPILER_LAUNCHER ${BIN_CCACHE} CACHE STRING "")
|
2018-05-12 14:29:14 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2019-04-04 21:25:09 +00:00
|
|
|
# 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)
|
2018-12-14 08:30:17 +00:00
|
|
|
|
2018-12-14 08:51:04 +00:00
|
|
|
# If we are in a git repo we can get the version information from git describe
|
|
|
|
execute_process(COMMAND git describe --tags --dirty=-dev
|
2018-12-14 08:30:17 +00:00
|
|
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
2018-12-14 08:51:04 +00:00
|
|
|
RESULT_VARIABLE git_result
|
|
|
|
OUTPUT_VARIABLE git_describe
|
2018-12-14 08:30:17 +00:00
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
|
|
|
|
|
2018-12-14 08:51:04 +00:00
|
|
|
if(git_result EQUAL "0")
|
|
|
|
set(APP_VERSION "${git_describe}")
|
|
|
|
else()
|
2018-12-14 09:02:20 +00:00
|
|
|
message(STATUS "Could not detect version with git, falling back to built-in version information.")
|
2019-04-04 21:25:09 +00:00
|
|
|
set(APP_VERSION "${version_txt}")
|
2018-12-14 08:30:17 +00:00
|
|
|
endif()
|
|
|
|
|
2016-11-02 19:22:45 +00:00
|
|
|
set(CMAKE_MODULE_PATH
|
|
|
|
${CMAKE_MODULE_PATH}
|
|
|
|
${PROJECT_SOURCE_DIR}/cmake
|
2017-01-26 16:17:02 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/cmake/common
|
2016-11-02 19:22:45 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/cmake/modules)
|
2016-05-20 09:20:58 +00:00
|
|
|
|
2019-06-24 16:08:59 +00:00
|
|
|
include(GNUInstallDirs)
|
2016-11-02 19:22:45 +00:00
|
|
|
include(utils)
|
2017-01-26 16:17:02 +00:00
|
|
|
include(01-core)
|
|
|
|
include(02-opts)
|
|
|
|
include(03-libs)
|
|
|
|
include(04-targets)
|
|
|
|
include(05-summary)
|
2016-06-15 03:32:35 +00:00
|
|
|
|
2018-12-14 15:16:20 +00:00
|
|
|
if(BUILD_DOC)
|
|
|
|
add_subdirectory(doc)
|
|
|
|
endif()
|
2019-04-08 21:29:21 +00:00
|
|
|
add_subdirectory(contrib/bash)
|
|
|
|
add_subdirectory(contrib/zsh)
|
2017-01-26 16:17:02 +00:00
|
|
|
add_subdirectory(include)
|
|
|
|
add_subdirectory(lib)
|
|
|
|
add_subdirectory(src bin)
|
2016-10-24 23:46:26 +00:00
|
|
|
|
2018-04-07 20:16:55 +00:00
|
|
|
# We need to enable testing in the root folder so that 'ctest' and 'make test'
|
|
|
|
# can be run in the build directory
|
2016-10-12 05:17:03 +00:00
|
|
|
if(BUILD_TESTS)
|
2018-04-08 22:49:36 +00:00
|
|
|
enable_testing()
|
2018-11-21 17:46:33 +00:00
|
|
|
add_subdirectory(tests)
|
2016-10-12 05:17:03 +00:00
|
|
|
endif()
|
2019-04-08 21:19:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Generate configuration file
|
|
|
|
#
|
|
|
|
|
|
|
|
set(MODULES_LEFT "bspwm i3")
|
|
|
|
set(MODULES_CENTER "mpd")
|
2020-12-21 21:15:05 +00:00
|
|
|
set(MODULES_RIGHT "filesystem backlight-acpi alsa pulseaudio xkeyboard memory cpu wlan eth battery temperature date powermenu")
|
2019-04-08 21:19:12 +00:00
|
|
|
|
|
|
|
set(FONT_FIXED "fixed:pixelsize=10")
|
|
|
|
set(FONT_UNIFONT "unifont:fontformat=truetype")
|
|
|
|
set(FONT_SIJI "siji:pixelsize=10")
|
|
|
|
|
|
|
|
queryfont(FONT_FIXED ${FONT_FIXED} FIELDS family pixelsize)
|
|
|
|
queryfont(FONT_UNIFONT ${FONT_UNIFONT} FIELDS family fontformat)
|
|
|
|
queryfont(FONT_SIJI ${FONT_SIJI} FIELDS family pixelsize)
|
|
|
|
|
|
|
|
# Strip disabled modules {{{
|
|
|
|
|
|
|
|
if(NOT ENABLE_PULSEAUDIO)
|
|
|
|
string(REPLACE " pulseaudio" "" MODULES_RIGHT ${MODULES_RIGHT})
|
|
|
|
endif()
|
|
|
|
if(NOT ENABLE_ALSA)
|
|
|
|
string(REPLACE " alsa" "" MODULES_RIGHT ${MODULES_RIGHT})
|
|
|
|
endif()
|
|
|
|
if(NOT ENABLE_I3)
|
|
|
|
string(REPLACE " i3" "" MODULES_LEFT ${MODULES_LEFT})
|
|
|
|
endif()
|
|
|
|
if(NOT ENABLE_MPD)
|
|
|
|
string(REPLACE "mpd" "" MODULES_CENTER ${MODULES_CENTER})
|
|
|
|
endif()
|
|
|
|
if(NOT ENABLE_NETWORK)
|
|
|
|
string(REPLACE " wlan eth" "" MODULES_RIGHT ${MODULES_RIGHT})
|
|
|
|
endif()
|
|
|
|
if(NOT WITH_XKB)
|
|
|
|
string(REPLACE "xkeyboard " "" MODULES_RIGHT ${MODULES_RIGHT})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# }}}
|
|
|
|
# Get battery/adapter name {{{
|
|
|
|
|
|
|
|
string(REGEX REPLACE /%battery%.* "" PATH_BAT ${SETTING_PATH_BATTERY})
|
|
|
|
string(REGEX REPLACE /%adapter%.* "" PATH_ADP ${SETTING_PATH_ADAPTER})
|
|
|
|
file(GLOB BAT_LIST RELATIVE ${PATH_BAT} ${PATH_ADP}/B*)
|
|
|
|
file(GLOB ADP_LIST RELATIVE ${PATH_ADP} ${PATH_ADP}/A*)
|
|
|
|
if(BAT_LIST)
|
|
|
|
list(GET BAT_LIST 0 BATTERY)
|
|
|
|
else()
|
|
|
|
set(BATTERY BAT0)
|
|
|
|
endif()
|
|
|
|
if(ADP_LIST)
|
|
|
|
list(GET ADP_LIST 0 ADAPTER)
|
|
|
|
else()
|
|
|
|
set(ADAPTER ADP1)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# }}}
|
|
|
|
# Get network interfaces {{{
|
|
|
|
|
|
|
|
if(ENABLE_NETWORK)
|
|
|
|
file(GLOB IFLIST RELATIVE /sys/class/net /sys/class/net/*)
|
|
|
|
foreach(INTERFACE ${IFLIST})
|
|
|
|
if(NOT ${INTERFACE} STREQUAL "lo")
|
|
|
|
file(GLOB IS_WIRELESS /sys/class/net/${INTERFACE}/wireless)
|
|
|
|
if(IS_WIRELESS)
|
|
|
|
set(INTERFACE_WLAN ${INTERFACE})
|
|
|
|
else()
|
|
|
|
set(INTERFACE_ETH ${INTERFACE})
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
if(NOT INTERFACE_ETH)
|
|
|
|
set(INTERFACE_ETH net0)
|
|
|
|
endif()
|
|
|
|
if(NOT INTERFACE_WLAN)
|
|
|
|
set(INTERFACE_WLAN net1)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# }}}
|
|
|
|
# Configure and install {{{
|
|
|
|
|
|
|
|
configure_file(
|
|
|
|
${CMAKE_CURRENT_LIST_DIR}/config.cmake
|
|
|
|
${CMAKE_CURRENT_LIST_DIR}/config
|
|
|
|
ESCAPE_QUOTES @ONLY)
|
|
|
|
|
|
|
|
install(FILES config
|
2019-06-24 16:08:59 +00:00
|
|
|
DESTINATION ${CMAKE_INSTALL_DOCDIR}
|
2019-04-08 21:19:12 +00:00
|
|
|
COMPONENT config)
|
|
|
|
|
|
|
|
# }}}
|