From bf55a3a3923e30fd46390e1ad8ac466110f5affd Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Mon, 26 Sep 2022 08:48:04 -0700 Subject: [PATCH] Make sure ccache is considered as part of the CMake build Summary: I've just realized that CMake is ignoring `ccache`, even if you have it installed. This is the necessary change needed to verify if the user has `ccache` installed and eventually use it. While not a necessary change for Prefab supprot, this is a nice to have that I've discovered while working on it. Changelog: [Internal] [Changed] - Make sure ccache is considered as part of the CMake build Reviewed By: cipolleschi Differential Revision: D39815089 fbshipit-source-id: be62e5fe98954593fd907ec21c41950a967cff04 --- ReactAndroid/cmake-utils/ReactNative-application.cmake | 8 ++++++++ ReactAndroid/src/main/jni/CMakeLists.txt | 7 +++++++ 2 files changed, 15 insertions(+) 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)