Skip to content

Commit

Permalink
Merge pull request #15886 from Rechi/xcode/ccache
Browse files Browse the repository at this point in the history
[cmake] enable using ccache with xcode
  • Loading branch information
Rechi committed Apr 16, 2019
2 parents cfd3b05 + 781dbe5 commit d4ae297
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cmake/modules/FindCCache.cmake
Expand Up @@ -12,7 +12,16 @@ include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(CCache REQUIRED_VARS CCACHE_PROGRAM)

if(CCACHE_FOUND)
# Supports Unix Makefiles and Ninja
# Supports Unix Makefiles, Ninja and Xcode
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CCACHE_PROGRAM}")

file(WRITE "${CMAKE_BINARY_DIR}/launch-c" "exec \"${CCACHE_PROGRAM}\" \"${CMAKE_C_COMPILER}\" \"$@\"\n")
file(WRITE "${CMAKE_BINARY_DIR}/launch-cxx" "exec \"${CCACHE_PROGRAM}\" \"${CMAKE_CXX_COMPILER}\" \"$@\"\n")
execute_process(COMMAND chmod +x "${CMAKE_BINARY_DIR}/launch-c" "${CMAKE_BINARY_DIR}/launch-cxx")

set(CMAKE_XCODE_ATTRIBUTE_CC "${CMAKE_BINARY_DIR}/launch-c" PARENT_SCOPE)
set(CMAKE_XCODE_ATTRIBUTE_CXX "${CMAKE_BINARY_DIR}/launch-cxx" PARENT_SCOPE)
set(CMAKE_XCODE_ATTRIBUTE_LD "${CMAKE_BINARY_DIR}/launch-c" PARENT_SCOPE)
set(CMAKE_XCODE_ATTRIBUTE_LDPLUSPLUS "${CMAKE_BINARY_DIR}/launch-cxx" PARENT_SCOPE)
endif()

0 comments on commit d4ae297

Please sign in to comment.