File: CMakeLists.txt

package info (click to toggle)
polybar 3.7.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,108 kB
  • sloc: cpp: 30,424; python: 3,750; sh: 284; makefile: 83
file content (77 lines) | stat: -rw-r--r-- 2,181 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#
# Build configuration
#
cmake_minimum_required(VERSION 3.5.0 FATAL_ERROR)
project(polybar CXX)

# 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)

# If we are in a git repo we can get the version information from git describe
execute_process(COMMAND git describe --tags --dirty=-dev
  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
  RESULT_VARIABLE git_result
  OUTPUT_VARIABLE git_describe
  OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)

if(git_result EQUAL "0")
  set(APP_VERSION "${git_describe}")
else()
  message(STATUS "Could not detect version with git, falling back to built-in version information.")
  set(APP_VERSION "${version_txt}")
endif()

# 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()

list(APPEND CMAKE_MODULE_PATH
  ${PROJECT_SOURCE_DIR}/cmake
  ${PROJECT_SOURCE_DIR}/cmake/common
  ${PROJECT_SOURCE_DIR}/cmake/modules)

include(GNUInstallDirs)
include(utils)
include(01-core)
include(02-opts)
include(04-targets)

if(BUILD_DOC)
  add_subdirectory(doc)
endif()

if (BUILD_SHELL)
  add_subdirectory(contrib/bash)
  add_subdirectory(contrib/zsh)
endif()

# Setup everything that uses a C++ compiler (polybar, polybar-msg, tests)
if(HAS_CXX_COMPILATION)
  include(cxx)
  if(BUILD_LIBPOLY)
    include(libpoly)
    add_subdirectory(lib)
  endif()
  add_subdirectory(include)
  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
if(BUILD_TESTS)
  enable_testing()
  add_subdirectory(tests)
endif()

if(BUILD_CONFIG)
  install(FILES ${CMAKE_SOURCE_DIR}/doc/config.ini
    DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR}/${PROJECT_NAME}
    COMPONENT config)
endif()

include(05-summary)