diff --git a/ReactAndroid/cmake-utils/ReactNative-application.cmake b/ReactAndroid/cmake-utils/ReactNative-application.cmake index 51c0f734c24..cea917f7a77 100644 --- a/ReactAndroid/cmake-utils/ReactNative-application.cmake +++ b/ReactAndroid/cmake-utils/ReactNative-application.cmake @@ -12,10 +12,18 @@ # - Include all the pre-built libraries in your build graph # - Link your library against those prebuilt libraries so you can access JSI, Fabric, etc. # - Link your library against any autolinked library. +# - Make sure ccache is used as part of the compilation process, if you have it installed. cmake_minimum_required(VERSION 3.13) set(CMAKE_VERBOSE_MAKEFILE on) +# If you have ccache installed, we're going to honor it. +find_program(CCACHE_FOUND ccache) +if(CCACHE_FOUND) + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) + set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) +endif(CCACHE_FOUND) + include(${REACT_ANDROID_DIR}/cmake-utils/Android-prebuilt.cmake) file(GLOB input_SRC CONFIGURE_DEPENDS diff --git a/ReactAndroid/src/main/jni/CMakeLists.txt b/ReactAndroid/src/main/jni/CMakeLists.txt index 4de03502c65..ce8896e15e9 100644 --- a/ReactAndroid/src/main/jni/CMakeLists.txt +++ b/ReactAndroid/src/main/jni/CMakeLists.txt @@ -8,6 +8,13 @@ set(CMAKE_VERBOSE_MAKEFILE on) project(ReactAndroid) +# If you have ccache installed, we're going to honor it. +find_program(CCACHE_FOUND ccache) +if(CCACHE_FOUND) + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) + set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) +endif(CCACHE_FOUND) + # Make sure every shared lib includes a .note.gnu.build-id header add_link_options(-Wl,--build-id) add_compile_options(-Wall -Werror -std=c++1y)