CMake/ccache.cmake

47 lines
1.7 KiB
CMake
Raw Normal View History

2019-08-31 18:18:50 +03:00
#
2024-12-30 22:37:58 +01:00
# Copyright (C) 2018-2025 QuasarApp.
2019-08-31 18:18:50 +03:00
# Distributed under the MIT software license, see the accompanying
# Everyone is permitted to copy and distribute verbatim copies
# of this license document, but changing it is not allowed.
#
2021-03-19 21:37:14 +03:00
# This module adds support of the ccache.
# If you include this cmake file in the main cmakList file then your project will be use the ccace on to the compilator
if(DEFINED CCACHE_SUPPORT)
return()
else()
set(CCACHE_SUPPORT 1)
endif()
2019-08-31 18:18:50 +03:00
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
message("using ccache in ${CCACHE_PROGRAM}")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
2022-04-29 09:27:46 +03:00
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CCACHE_PROGRAM}") # Less useful to do it for linking, see edit2
2023-04-15 13:23:13 +02:00
if(CMAKE_GENERATOR STREQUAL "Xcode")
2023-04-15 13:47:54 +02:00
set(CC_LAUNCHER ${CMAKE_CURRENT_LIST_DIR}/ccahe_cc_launcher.sh)
set(CXX_LAUNCHER ${CMAKE_CURRENT_LIST_DIR}/ccahe_cxx_launcher.sh)
configure_file("${CC_LAUNCHER}.in" "${CC_LAUNCHER}")
configure_file("${CXX_LAUNCHER}.in" "${CXX_LAUNCHER}")
2023-04-15 13:53:52 +02:00
execute_process(COMMAND chmod +x
"${CC_LAUNCHER}"
"${CXX_LAUNCHER}"
)
2023-04-15 13:23:13 +02:00
# Set Xcode project attributes to route compilation and linking
# through our scripts
2023-04-15 13:47:54 +02:00
set(CMAKE_XCODE_ATTRIBUTE_CC ${CC_LAUNCHER} CACHE INTERNAL "override CMAKE_XCODE_ATTRIBUTE_CC" )
set(CMAKE_XCODE_ATTRIBUTE_CXX ${CXX_LAUNCHER} CACHE INTERNAL "override CMAKE_XCODE_ATTRIBUTE_CC")
2023-04-15 13:23:13 +02:00
message("CMAKE_XCODE_ATTRIBUTE_CC = ${CMAKE_XCODE_ATTRIBUTE_CC}")
message("CMAKE_XCODE_ATTRIBUTE_CXX = ${CMAKE_XCODE_ATTRIBUTE_CXX}")
2023-04-15 13:47:54 +02:00
2023-04-15 13:23:13 +02:00
endif()
2019-08-31 18:18:50 +03:00
endif()