diff options
Diffstat (limited to 'build_files/cmake/platform/platform_apple_xcode.cmake')
-rw-r--r-- | build_files/cmake/platform/platform_apple_xcode.cmake | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/build_files/cmake/platform/platform_apple_xcode.cmake b/build_files/cmake/platform/platform_apple_xcode.cmake index e4b804fc4ea..f12de540353 100644 --- a/build_files/cmake/platform/platform_apple_xcode.cmake +++ b/build_files/cmake/platform/platform_apple_xcode.cmake @@ -154,3 +154,32 @@ if(NOT ${CMAKE_GENERATOR} MATCHES "Xcode") string(APPEND CMAKE_CXX_FLAGS " -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}") add_definitions("-DMACOSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}") endif() + +if(WITH_COMPILER_CCACHE) + if(CMAKE_GENERATOR STREQUAL "Xcode") + find_program(CCACHE_PROGRAM ccache) + if(CCACHE_PROGRAM) + get_filename_component(ccompiler "${CMAKE_C_COMPILER}" NAME) + get_filename_component(cxxcompiler "${CMAKE_CXX_COMPILER}" NAME) + # Ccache can figure out which compiler to use if it's invoked from + # a symlink with the name of the compiler. + # https://ccache.dev/manual/4.1.html#_run_modes + set(_fake_compiler_dir "${CMAKE_BINARY_DIR}/ccache") + execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${_fake_compiler_dir}) + set(_fake_C_COMPILER "${_fake_compiler_dir}/${ccompiler}") + set(_fake_CXX_COMPILER "${_fake_compiler_dir}/${cxxcompiler}") + execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${CCACHE_PROGRAM}" ${_fake_C_COMPILER}) + execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${CCACHE_PROGRAM}" ${_fake_CXX_COMPILER}) + set(CMAKE_XCODE_ATTRIBUTE_CC ${_fake_C_COMPILER} CACHE STRING "" FORCE) + set(CMAKE_XCODE_ATTRIBUTE_CXX ${_fake_CXX_COMPILER} CACHE STRING "" FORCE) + set(CMAKE_XCODE_ATTRIBUTE_LD ${_fake_C_COMPILER} CACHE STRING "" FORCE) + set(CMAKE_XCODE_ATTRIBUTE_LDPLUSPLUS ${_fake_CXX_COMPILER} CACHE STRING "" FORCE) + unset(_fake_compiler_dir) + unset(_fake_C_COMPILER) + unset(_fake_CXX_COMPILER) + else() + message(WARNING "Ccache NOT found, disabling WITH_COMPILER_CCACHE") + set(WITH_COMPILER_CCACHE OFF) + endif() + endif() +endif() |