diff --git a/CMakeLists.txt b/CMakeLists.txt index d711ceec9..10ad46630 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -222,6 +222,24 @@ if(APPLE_IOS) set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED_FOR_APPS YES) set(CMAKE_XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "${BUNDLE_IDENTIFIER_PREFIX}.$(PRODUCT_NAME)") set(CMAKE_XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "1,2") + + if(CMAKE_CXX_COMPILER_LAUNCHER) + find_program(CCACHE "ccache") + if(CCACHE) + # https://stackoverflow.com/a/36515503/2278742 + # Set up wrapper scripts + configure_file(ios/launch-c.in ios/launch-c) + configure_file(ios/launch-cxx.in ios/launch-cxx) + execute_process(COMMAND chmod a+rx + "${CMAKE_BINARY_DIR}/ios/launch-c" + "${CMAKE_BINARY_DIR}/ios/launch-cxx") + # Set Xcode project attributes to route compilation through our scripts + set(CMAKE_XCODE_ATTRIBUTE_CC "${CMAKE_BINARY_DIR}/ios/launch-c") + set(CMAKE_XCODE_ATTRIBUTE_CXX "${CMAKE_BINARY_DIR}/ios/launch-cxx") + set(CMAKE_XCODE_ATTRIBUTE_LD "${CMAKE_BINARY_DIR}/ios/launch-c") + set(CMAKE_XCODE_ATTRIBUTE_LDPLUSPLUS "${CMAKE_BINARY_DIR}/ios/launch-cxx") + endif() + endif() endif() if(APPLE_MACOS) diff --git a/ios/launch-c.in b/ios/launch-c.in new file mode 100644 index 000000000..59ced1e88 --- /dev/null +++ b/ios/launch-c.in @@ -0,0 +1,3 @@ +#!/bin/sh +export CCACHE_CPP2=true +ccache clang "$@" diff --git a/ios/launch-cxx.in b/ios/launch-cxx.in new file mode 100644 index 000000000..2d52f768c --- /dev/null +++ b/ios/launch-cxx.in @@ -0,0 +1,3 @@ +#!/bin/sh +export CCACHE_CPP2=true +ccache clang++ "$@"