polybar-dwm/CMakeLists.txt
patrick96 b5129ae0c4 refactor(ccache): Enable by default
Following [1] to get to this setup.

We setup all the ccache configuration before calling project() because
project will perform compiler checks. This is also why we can't use
message_colored here and print the colors manually

Before ENABLE_CCACHE was not yet defined when we reached the check in
01-core because the option was defined in 02-opts

[1] https://crascit.com/2016/04/09/using-ccache-with-cmake/
2018-06-01 10:49:00 -07:00

52 lines
1.3 KiB
CMake

#
# Build configuration
#
cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
# 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()
project(polybar C CXX)
set(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
${PROJECT_SOURCE_DIR}/cmake
${PROJECT_SOURCE_DIR}/cmake/common
${PROJECT_SOURCE_DIR}/cmake/modules)
include(utils)
include(01-core)
include(02-opts)
include(03-libs)
include(04-targets)
include(05-summary)
add_subdirectory(doc)
add_subdirectory(doc/bash)
add_subdirectory(doc/zsh)
add_subdirectory(include)
add_subdirectory(lib)
add_subdirectory(man)
add_subdirectory(src bin)
# 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 EXCLUDE_FROM_ALL)
endif()