forked from qt-creator/qt-creator
CMake: add ccache option
Change-Id: I482b0f3ac372f141e465b72fbcca9d8b5c5b352d Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -24,7 +24,7 @@ set(CMAKE_CXX_STANDARD 17)
|
|||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
|
||||||
qtc_handle_sccache_support()
|
qtc_handle_compiler_cache_support()
|
||||||
|
|
||||||
option(BUILD_LINK_WITH_QT "Link with Qt from the parent Qt Creator" OFF)
|
option(BUILD_LINK_WITH_QT "Link with Qt from the parent Qt Creator" OFF)
|
||||||
qtc_link_with_qt()
|
qtc_link_with_qt()
|
||||||
|
@@ -43,6 +43,7 @@ option(BUILD_LIBRARIES_BY_DEFAULT "Build libraries by default. This can be used
|
|||||||
option(BUILD_TESTS_BY_DEFAULT "Build tests by default. This can be used to build all tests by default, or none." ON)
|
option(BUILD_TESTS_BY_DEFAULT "Build tests by default. This can be used to build all tests by default, or none." ON)
|
||||||
option(QTC_SEPARATE_DEBUG_INFO "Extract debug information from binary files." OFF)
|
option(QTC_SEPARATE_DEBUG_INFO "Extract debug information from binary files." OFF)
|
||||||
option(WITH_SCCACHE_SUPPORT "Enables support for building with SCCACHE and separate debug info with MSVC, which SCCACHE normally doesn't support." OFF)
|
option(WITH_SCCACHE_SUPPORT "Enables support for building with SCCACHE and separate debug info with MSVC, which SCCACHE normally doesn't support." OFF)
|
||||||
|
option(WITH_CCACHE_SUPPORT "Enables support for building with CCACHE and separate debug info with MSVC, which CCACHE normally doesn't support." OFF)
|
||||||
|
|
||||||
# If we provide a list of plugins, executables, libraries, then the BUILD_<type>_BY_DEFAULT will be set to OFF
|
# If we provide a list of plugins, executables, libraries, then the BUILD_<type>_BY_DEFAULT will be set to OFF
|
||||||
# and for every element we set BUILD_<type>_<elment> to ON
|
# and for every element we set BUILD_<type>_<elment> to ON
|
||||||
|
@@ -117,15 +117,24 @@ set(__QTC_TESTS "" CACHE INTERNAL "*** Internal ***")
|
|||||||
# This increases memory usage, disk space usage and linking time, so should only be
|
# This increases memory usage, disk space usage and linking time, so should only be
|
||||||
# enabled if necessary.
|
# enabled if necessary.
|
||||||
# Must be called after project(...).
|
# Must be called after project(...).
|
||||||
function(qtc_handle_sccache_support)
|
function(qtc_handle_compiler_cache_support)
|
||||||
if (MSVC AND WITH_SCCACHE_SUPPORT)
|
if (WITH_SCCACHE_SUPPORT OR WITH_CCACHE_SUPPORT)
|
||||||
foreach(config DEBUG RELWITHDEBINFO)
|
if (MSVC)
|
||||||
foreach(lang C CXX)
|
foreach(config DEBUG RELWITHDEBINFO)
|
||||||
set(flags_var "CMAKE_${lang}_FLAGS_${config}")
|
foreach(lang C CXX)
|
||||||
string(REPLACE "/Zi" "/Z7" ${flags_var} "${${flags_var}}")
|
set(flags_var "CMAKE_${lang}_FLAGS_${config}")
|
||||||
set(${flags_var} "${${flags_var}}" PARENT_SCOPE)
|
string(REPLACE "/Zi" "/Z7" ${flags_var} "${${flags_var}}")
|
||||||
|
set(${flags_var} "${${flags_var}}" PARENT_SCOPE)
|
||||||
|
endforeach()
|
||||||
endforeach()
|
endforeach()
|
||||||
endforeach()
|
endif()
|
||||||
|
endif()
|
||||||
|
if (WITH_CCACHE_SUPPORT)
|
||||||
|
find_program(CCACHE_PROGRAM ccache)
|
||||||
|
if(CCACHE_PROGRAM)
|
||||||
|
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}" CACHE STRING "CXX compiler launcher" FORCE)
|
||||||
|
set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM}" CACHE STRING "C compiler launcher" FORCE)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user