CMake: Fix usage of ccache when no executable was found

Change-Id: Ia9a44234cb074fa5ba2b1dc9ca22a676d1b2d4ce
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Alexandru Croitor 2020-08-17 16:31:38 +02:00
parent 6a2c89c043
commit f8af82e3b3

View File

@ -206,7 +206,12 @@ include(${CMAKE_CURRENT_LIST_DIR}/3rdparty/extra-cmake-modules/modules/ECMEnable
option(QT_USE_CCACHE "Enable the use of ccache")
if(QT_USE_CCACHE)
find_program(CCACHE_PROGRAM ccache)
set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
set(CMAKE_OBJC_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
if(CCACHE_PROGRAM)
set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
set(CMAKE_OBJC_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
set(CMAKE_OBJCXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
else()
message(WARNING "Ccache use was requested, but the program was not found.")
endif()
endif()