diff options
author | Matt Hill <theothermatt> | 2020-12-21 08:17:35 +0300 |
---|---|---|
committer | Ankit Meel <ankitjmeel@gmail.com> | 2020-12-21 08:17:35 +0300 |
commit | fdb7623e098fe431397815fc67667c5904074913 (patch) | |
tree | 3ce2e718b5e9fee8f330c85925b88d6013226580 /build_files/cmake/platform/platform_apple.cmake | |
parent | 84cc00f3b68e12209e000008f992fad3ac48f757 (diff) |
Unix/macOS: support building with Ccache
This adds an option (WITH_COMPILER_CCACHE) to build using Ccache if it's
found. Makefiles-based, Ninja-based and Xcode generators are supported.
Pass `-DWITH_COMPILER_CCACHE=ON` to cmake to enable Ccache.
Utility option in GNUmakefile is also added: for e.g.,
`make ninja ccache`.
Reviewed By: brecht, ankitm
Differential Revision: https://developer.blender.org/D9665
Diffstat (limited to 'build_files/cmake/platform/platform_apple.cmake')
-rw-r--r-- | build_files/cmake/platform/platform_apple.cmake | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/build_files/cmake/platform/platform_apple.cmake b/build_files/cmake/platform/platform_apple.cmake index 6baa2f3d855..31da5292eaf 100644 --- a/build_files/cmake/platform/platform_apple.cmake +++ b/build_files/cmake/platform/platform_apple.cmake @@ -470,3 +470,17 @@ set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>") set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>") set(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>") set(CMAKE_CXX_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>") + +if(WITH_COMPILER_CCACHE) + if(NOT CMAKE_GENERATOR STREQUAL "Xcode") + find_program(CCACHE_PROGRAM ccache) + if(CCACHE_PROGRAM) + # Makefiles and ninja + set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM}" CACHE STRING "" FORCE) + set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}" CACHE STRING "" FORCE) + else() + message(WARNING "Ccache NOT found, disabling WITH_COMPILER_CCACHE") + set(WITH_COMPILER_CCACHE OFF) + endif() + endif() +endif() |