diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ed2f46fb5..720a6f8059 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,7 +77,6 @@ option(PYBINDINGS "Create makefiles for building python bindings" OFF) option(SKIP_DESKTOP "Skip building of desktop application" OFF) option(BUILD_MAPSHOT "Build mapshot tool" OFF) option(USE_PCH "Use precompiled headers" OFF) -option(USE_CCACHE "Cache object files with ccache" OFF) if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0) @@ -127,16 +126,14 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}) set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}) -if (USE_CCACHE AND (PLATFORM_MAC OR PLATFORM_LINUX)) - find_program(CCACHE_FOUND ccache) - if (CCACHE_FOUND) - message(STATUS "Using ccache") - set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) - set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) +if (NOT (ENV{CCACHE_DISABLE} EQUAL "1")) + find_program(CCACHE_PROGRAM ccache) + if (CCACHE_PROGRAM) + message(STATUS "Using ccache, export CCACHE_DISABLE=1 to disable it.") + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}") + set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CCACHE_PROGRAM}") set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM}") set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}") - else() - message(FATAL_ERROR "Could not find ccache") endif() endif()