2016-05-19 14:41:06 +00:00
|
|
|
#
|
|
|
|
# Build configuration
|
|
|
|
#
|
2016-11-02 19:22:45 +00:00
|
|
|
cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
|
2016-05-24 12:24:45 +00:00
|
|
|
|
2018-05-12 14:29:14 +00:00
|
|
|
# Enable ccache by default and as early as possible because project() performs
|
|
|
|
# checks on the compiler
|
|
|
|
option(ENABLE_CCACHE "Enable ccache support" ON)
|
|
|
|
if(ENABLE_CCACHE)
|
|
|
|
message(STATUS "Trying to enable ccache")
|
|
|
|
find_program(BIN_CCACHE 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_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${BIN_CCACHE})
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2016-11-19 05:22:44 +00:00
|
|
|
project(polybar C CXX)
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2018-12-14 08:51:04 +00:00
|
|
|
# Polybar version information
|
|
|
|
# Update this on every release
|
|
|
|
# This is used to create the version string if a git repo is not available
|
2018-12-14 08:30:17 +00:00
|
|
|
set(VERSION_MAJOR "3")
|
|
|
|
set(VERSION_MINOR "3")
|
|
|
|
set(VERSION_PATCH "0")
|
|
|
|
|
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.")
|
2018-12-14 08:30:17 +00:00
|
|
|
set(APP_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
STRING(REGEX REPLACE "[^a-zA-Z0-9_]" "_" APP_VERSION_NAMESPACE "v${APP_VERSION}")
|
|
|
|
|
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
|
|
|
|
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
|
|
|
|
2017-01-26 16:17:02 +00:00
|
|
|
add_subdirectory(doc)
|
2017-05-19 10:30:26 +00:00
|
|
|
add_subdirectory(doc/bash)
|
2017-01-26 16:17:02 +00:00
|
|
|
add_subdirectory(doc/zsh)
|
|
|
|
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()
|