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/
This commit is contained in:
parent
b70d5b55d8
commit
b5129ae0c4
@ -3,6 +3,23 @@
|
|||||||
#
|
#
|
||||||
cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
|
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)
|
project(polybar C CXX)
|
||||||
|
|
||||||
set(CMAKE_MODULE_PATH
|
set(CMAKE_MODULE_PATH
|
||||||
|
@ -81,12 +81,6 @@ elseif(CXXLIB_GCC)
|
|||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lstdc++")
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lstdc++")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ENABLE_CCACHE)
|
|
||||||
querybin(ccache)
|
|
||||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${BINPATH_ccache})
|
|
||||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${BINPATH_ccache})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Install paths
|
# Install paths
|
||||||
if(NOT DEFINED CMAKE_INSTALL_BINDIR)
|
if(NOT DEFINED CMAKE_INSTALL_BINDIR)
|
||||||
set(CMAKE_INSTALL_BINDIR bin)
|
set(CMAKE_INSTALL_BINDIR bin)
|
||||||
|
@ -23,7 +23,6 @@ option(CXXLIB_GCC "Link against stdlibc++" OFF)
|
|||||||
option(BUILD_IPC_MSG "Build ipc messager" ON)
|
option(BUILD_IPC_MSG "Build ipc messager" ON)
|
||||||
option(BUILD_TESTS "Build testsuite" OFF)
|
option(BUILD_TESTS "Build testsuite" OFF)
|
||||||
|
|
||||||
option(ENABLE_CCACHE "Enable ccache support" OFF)
|
|
||||||
option(ENABLE_ALSA "Enable alsa support" ON)
|
option(ENABLE_ALSA "Enable alsa support" ON)
|
||||||
option(ENABLE_CURL "Enable curl support" ON)
|
option(ENABLE_CURL "Enable curl support" ON)
|
||||||
option(ENABLE_I3 "Enable i3 support" ON)
|
option(ENABLE_I3 "Enable i3 support" ON)
|
||||||
|
Loading…
Reference in New Issue
Block a user