diff options
-rw-r--r-- | CMakeLists.txt | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 35b17a7564..deddd75cd1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,6 +51,8 @@ option(ENABLE_HMI_PTU_DECRYPTION "Policy table update parsed by hmi" ON) option(ENABLE_EXTENDED_POLICY "Turns extended flow which requires embedded system interaction" ON) option(USE_COTIRE "Use Cotire to speed up build (currently only for commands tests)" ON) option(USE_GOLD_LD "Use gold linker intead of GNU linker" ON) +option(USE_CCACHE "Turn on ccache usage" ON) +option(USE_DISTCC "Turn on distributed build_usage" ON) set(OS_TYPE_OPTION "$ENV{OS_TYPE}") set(DEBUG_OPTION "$ENV{DEBUG}") @@ -199,6 +201,37 @@ if (USE_GOLD_LD) endif() endif(USE_GOLD_LD) +if (USE_CCACHE) +# Configure CCache if available + find_program(CCACHE_FOUND ccache) + if(CCACHE_FOUND) + get_property(RULE_LAUNCH_COMPILE GLOBAL PROPERTY RULE_LAUNCH_COMPILE) + set(RULE_LAUNCH_COMPILE "${RULE_LAUNCH_COMPILE} ccache") + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${RULE_LAUNCH_COMPILE}) + + get_property(RULE_LAUNCH_LINK GLOBAL PROPERTY RULE_LAUNCH_LINK) + set(RULE_LAUNCH_LINK "${RULE_LAUNCH_LINK} ccache") + set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${RULE_LAUNCH_LINK}) + + message(INFO " Used CCache for compilation.") + else(CCACHE_FOUND) + message(WARNING " CCache was not found.") + endif(CCACHE_FOUND) +endif(USE_CCACHE) + +if (USE_DISTCC) +# Configure distributed compilation if available + find_program(DISTCC_FOUND distcc) + if(DISTCC_FOUND) + get_property(RULE_LAUNCH_COMPILE GLOBAL PROPERTY RULE_LAUNCH_COMPILE) + set(RULE_LAUNCH_COMPILE "${RULE_LAUNCH_COMPILE} distcc") + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${RULE_LAUNCH_COMPILE}) + message(INFO " Used distributed build.") + else(CCACHE_FOUND) + message(WARNING " distcc was not found. Distributed compilation is impossible.") + endif(DISTCC_FOUND) +endif(USE_DISTCC) + if(ENABLE_SANITIZE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address") endif() |