diff --git a/CMakeLists.txt b/CMakeLists.txt index f35e1b1b..9658f0f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,16 +24,16 @@ if (${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) message(FATAL_ERROR "Please create a separate build directory and call CMake again") endif() -# speed up recompiling on unix with ccache -find_program(CCACHE_PROGRAM ccache) -if (CCACHE_PROGRAM) - message(STATUS "ccache found") - - # Support Unix Makefiles and Ninja - set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}") +if(NOT DEFINED CMAKE_CXX_COMPILER_LAUNCHER) + # speed up recompiling on unix with ccache + find_program(CCACHE_PROGRAM ccache) + if (CCACHE_PROGRAM) + message(STATUS "ccache found") + # Support Unix Makefiles and Ninja + set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}" CACHE STRING "Compiler launcher for CXX") + endif() endif() - # Variables -------------------------------------------------------------------- set(PROJECT_NAME Sourcetrail)