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
|
|
|
|
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()
|
|
|
|
|
2023-02-13 20:08:48 +00:00
|
|
|
# Set the default installation prefix to /usr
|
|
|
|
# Otherwise the default value is /usr/local which causes the default config
|
|
|
|
# file to be installed to /usr/local/etc, with /usr, cmake has special handling
|
|
|
|
# for this.
|
|
|
|
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
|
|
|
set(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "Project-default installation prefix" FORCE)
|
|
|
|
endif()
|
|
|
|
|
2020-12-24 00:40:26 +00:00
|
|
|
list(APPEND CMAKE_MODULE_PATH
|
2016-11-02 19:22:45 +00:00
|
|
|
${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)
|
2020-12-22 11:19:46 +00:00
|
|
|
include(01-core)
|
2017-01-26 16:17:02 +00:00
|
|
|
include(02-opts)
|
|
|
|
include(04-targets)
|
2016-06-15 03:32:35 +00:00
|
|
|
|
2018-12-14 15:16:20 +00:00
|
|
|
if(BUILD_DOC)
|
|
|
|
add_subdirectory(doc)
|
|
|
|
endif()
|
2020-12-22 11:19:46 +00:00
|
|
|
|
2020-12-24 00:09:39 +00:00
|
|
|
if (BUILD_SHELL)
|
|
|
|
add_subdirectory(contrib/bash)
|
|
|
|
add_subdirectory(contrib/zsh)
|
|
|
|
endif()
|
2020-12-22 11:19:46 +00:00
|
|
|
|
2020-12-24 01:02:53 +00:00
|
|
|
# Setup everything that uses a C++ compiler (polybar, polybar-msg, tests)
|
2020-12-22 11:19:46 +00:00
|
|
|
if(HAS_CXX_COMPILATION)
|
|
|
|
include(cxx)
|
|
|
|
if(BUILD_LIBPOLY)
|
|
|
|
include(libpoly)
|
|
|
|
add_subdirectory(lib)
|
|
|
|
endif()
|
2020-12-22 02:43:06 +00:00
|
|
|
add_subdirectory(include)
|
|
|
|
add_subdirectory(src bin)
|
|
|
|
endif()
|
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
|
|
|
|
2021-10-05 11:07:19 +00:00
|
|
|
if(BUILD_CONFIG)
|
|
|
|
install(FILES ${CMAKE_SOURCE_DIR}/doc/config.ini
|
2023-02-13 20:08:48 +00:00
|
|
|
DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR}/${PROJECT_NAME}
|
2021-10-05 11:07:19 +00:00
|
|
|
COMPONENT config)
|
2019-04-08 21:19:12 +00:00
|
|
|
endif()
|
|
|
|
|
2020-12-23 23:56:31 +00:00
|
|
|
include(05-summary)
|