Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[build] Enable ccache for Xcode iOS builds
Browse files Browse the repository at this point in the history
  • Loading branch information
Juha Alanen committed Feb 14, 2020
1 parent af74282 commit 7a9f802
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
20 changes: 20 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
project("Mapbox GL Native" LANGUAGES CXX C)

find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM AND CMAKE_SYSTEM_NAME STREQUAL "iOS")
# Set up wrapper scripts
set(C_LAUNCHER "${CCACHE_PROGRAM}")
set(CXX_LAUNCHER "${CCACHE_PROGRAM}")
configure_file(${PROJECT_SOURCE_DIR}/scripts/ci/ccache-c.in ccache-c)
configure_file(${PROJECT_SOURCE_DIR}/scripts/ci/ccache-cxx.in ccache-cxx)
execute_process(
COMMAND
chmod
a+rx
"${CMAKE_BINARY_DIR}/ccache-c"
"${CMAKE_BINARY_DIR}/ccache-cxx"
)

# Set Xcode project attributes to route compilation and linking through our scripts
set(CMAKE_XCODE_ATTRIBUTE_CC "${CMAKE_BINARY_DIR}/ccache-c")
set(CMAKE_XCODE_ATTRIBUTE_CXX "${CMAKE_BINARY_DIR}/ccache-cxx")
endif()

set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER Core)

Expand Down
9 changes: 9 additions & 0 deletions scripts/ci/ccache-c.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

# Xcode generator doesn't include the compiler as the
# first argument, Ninja and Makefiles do. Handle both cases.
if [[ "$1" = "${CMAKE_C_COMPILER}" ]] ; then
shift
fi

exec "${C_LAUNCHER}" "${CMAKE_C_COMPILER}" "$@"
9 changes: 9 additions & 0 deletions scripts/ci/ccache-cxx.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

# Xcode generator doesn't include the compiler as the
# first argument, Ninja and Makefiles do. Handle both cases.
if [[ "$1" = "${CMAKE_CXX_COMPILER}" ]] ; then
shift
fi

exec "${CXX_LAUNCHER}" "${CMAKE_CXX_COMPILER}" "$@"

0 comments on commit 7a9f802

Please sign in to comment.