From da2798c756f58ee158448e0f77f91d50d26d3d63 Mon Sep 17 00:00:00 2001 From: Sukender Date: Sun, 1 Apr 2012 01:00:08 +0200 Subject: [PATCH] Added ccache support. Seems okay on my Linux. --- CMakeLists.txt | 18 +++++++++--------- CMakeModules/Warnings.cmake | 1 + 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1a57440e2c2..c8fa0f8171c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,11 +9,6 @@ # TODO: # - Replace PIONEER_VERSION / PIONEER_EXTRAVERSION usage with Version.h. # Version.h/.cpp allow to grab versionning of VersionNumber.h without recompiling the entire project. -# - Handle ccache to speedup builds (Linux) -# http://stackoverflow.com/questions/1815688/how-to-use-ccache-with-cmake -# http://stackoverflow.com/questions/2930500/ccache-does-not-hit-cache-without-deleting-cmake-files -# --with-ccache: enables compiling with ccache -# "ccache was requested but was not found. Build will proceed as normal" # - Same options as automake: # --enable-debug: -DDEBUG # --with-no-optimise: -O0 (else -O3) @@ -198,12 +193,17 @@ ENDIF() ######################################################################### # ccache -if(NOT WIN32) +#if(NOT WIN32) +if(CMAKE_COMPILER_IS_GNUCXX) OPTION(${PROJECT_NAME}_USE_ccache "Set to ON to use ccache to compile." OFF) if (${PROJECT_NAME}_USE_ccache) - message("ccache unsupported for now!!!") - #find_package("ccache") - #"ccache was requested but was not found. Build will proceed as normal" + find_package(ccache QUIET) + if(CCACHE_FOUND) + set(CMAKE_CXX_COMPILER ${CCACHE_GXX}) + set(CMAKE_C_COMPILER ${CCACHE_GCC}) + else() + message("ccache was requested but was not found. Build will proceed as normal") + endif() endif() endif() diff --git a/CMakeModules/Warnings.cmake b/CMakeModules/Warnings.cmake index b23385ee67a..9f7d945591c 100644 --- a/CMakeModules/Warnings.cmake +++ b/CMakeModules/Warnings.cmake @@ -138,3 +138,4 @@ IF(${PROJECT_NAME}_AGGRESSIVE_WARNING_FLAGS_C) ENDFOREACH() ENDIF() ENDIF() +