From 6f6a37fe089ddb420fa09bdd6e0c9c2b414f3d9d Mon Sep 17 00:00:00 2001 From: PerseoGI Date: Fri, 21 Feb 2025 12:11:05 +0100 Subject: [PATCH 1/7] New ccache binary recipe --- recipes/ccache/binary/ccache-autoinject.cmake | 25 +++++++++ recipes/ccache/binary/conandata.yml | 14 +++++ recipes/ccache/binary/conanfile.py | 56 +++++++++++++++++++ .../ccache/binary/test_package/CMakeLists.txt | 4 ++ .../ccache/binary/test_package/conanfile.py | 32 +++++++++++ .../binary/test_package/test_package.cpp | 5 ++ recipes/ccache/config.yml | 3 + 7 files changed, 139 insertions(+) create mode 100644 recipes/ccache/binary/ccache-autoinject.cmake create mode 100644 recipes/ccache/binary/conandata.yml create mode 100644 recipes/ccache/binary/conanfile.py create mode 100644 recipes/ccache/binary/test_package/CMakeLists.txt create mode 100644 recipes/ccache/binary/test_package/conanfile.py create mode 100644 recipes/ccache/binary/test_package/test_package.cpp create mode 100644 recipes/ccache/config.yml diff --git a/recipes/ccache/binary/ccache-autoinject.cmake b/recipes/ccache/binary/ccache-autoinject.cmake new file mode 100644 index 0000000..fcb2a37 --- /dev/null +++ b/recipes/ccache/binary/ccache-autoinject.cmake @@ -0,0 +1,25 @@ +include_guard() + +# Enable cache if available +set(CACHE_OPTION "ccache" CACHE STRING "Compiler cache to be used") +set(CACHE_OPTION_VALUES "ccache" "sccache") +set(CCACHE_ARGS "base_dir=;hash_dir=false") +set_property(CACHE CACHE_OPTION PROPERTY STRINGS ${CACHE_OPTION_VALUES}) +list(FIND CACHE_OPTION_VALUES ${CACHE_OPTION} CACHE_OPTION_INDEX) + +if(${CACHE_OPTION_INDEX} EQUAL -1) + message( + STATUS + "Using custom compiler cache system: '${CACHE_OPTION}', explicitly supported entries are ${CACHE_OPTION_VALUES}" + ) +endif() + +find_program(CACHE_BINARY NAMES ${CACHE_OPTION_VALUES}) +if(CACHE_BINARY) + message(STATUS "${CACHE_BINARY} found and enabled") + set(CMAKE_CXX_COMPILER_LAUNCHER "${CACHE_BINARY};${CCACHE_ARGS}" CACHE FILEPATH "CXX compiler cache used") + set(CMAKE_C_COMPILER_LAUNCHER "${CACHE_BINARY};${CCACHE_ARGS}" CACHE FILEPATH "C compiler cache used") +else() + message(WARNING "${CACHE_OPTION} is enabled but was not found. Not using it") +endif() + diff --git a/recipes/ccache/binary/conandata.yml b/recipes/ccache/binary/conandata.yml new file mode 100644 index 0000000..2a9ead5 --- /dev/null +++ b/recipes/ccache/binary/conandata.yml @@ -0,0 +1,14 @@ +sources: + "4.10.2": + Linux: + x86_64: + url: "https://github.com/ccache/ccache/releases/download/v4.10.2/ccache-4.10.2-linux-x86_64.tar.xz" + sha256: "80cab87bd510eca796467aee8e663c398239e0df1c4800a0b5dff11dca0b4f18" + Macos: + universal: + url: "https://github.com/ccache/ccache/releases/download/v4.10.2/ccache-4.10.2-darwin.tar.gz" + sha256: "d90514fff15943a8607e84e3f42d45f823915a92f99984f3fc88202f6295d1e8" + Windows: + x86_64: + url: "https://github.com/ccache/ccache/releases/download/v4.10.2/ccache-4.10.2-windows-x86_64.zip" + sha256: "6252f081876a9a9f700fae13a5aec5d0d486b28261d7f1f72ac11c7ad9df4da9" diff --git a/recipes/ccache/binary/conanfile.py b/recipes/ccache/binary/conanfile.py new file mode 100644 index 0000000..2f890ef --- /dev/null +++ b/recipes/ccache/binary/conanfile.py @@ -0,0 +1,56 @@ +import os +from pathlib import Path + +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.files import get, copy, replace_in_file + +required_conan_version = ">=2.7" + +AUTOIJECT_CMAKE = "ccache-autoinject.cmake" + +class CcacheConan(ConanFile): + name = "ccache" + package_type = "application" + description = ( + "Ccache (or “ccache”) is a compiler cache. It speeds up recompilation " + "by caching previous compilations and detecting when the same " + "compilation is being done again." + ) + license = "GPL-3.0-or-later" + topics = ("compiler-cache", "recompilation", "cache", "compiler") + homepage = "https://ccache.dev" + url = "https://github.com/conan-io/conan-center-index" + settings = "os", "arch" + exports_sources = [AUTOIJECT_CMAKE] + + def validate(self): + if self.settings.os != "Macos" and self.settings.arch != "x86_64": + raise ConanInvalidConfiguration("ccache binaries are only provided for x86_64 architectures") + + def build(self): + arch = str(self.settings.arch) if self.settings.os != "Macos" else "universal" + get(self, **self.conan_data["sources"][self.version][str(self.settings.os)][arch], + destination=self.source_folder, strip_root=True) + + def package_id(self): + if self.info.settings.os == "Macos": + del self.info.settings.arch + + def package(self): + copy(self, "*GPL-*.txt", src=self.build_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "LICENSE.*", src=self.build_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "ccache", src=self.build_folder, dst=os.path.join(self.package_folder, "bin")) + copy(self, AUTOIJECT_CMAKE, src=self.build_folder, dst=self.package_folder) + + def finalize(self): + copy(self, "*", src=self.immutable_package_folder, dst=self.package_folder) + # TODO: find a way of retrieving conan home without accessing private API + # replace_in_file(self, os.path.join(self.package_folder, AUTOIJECT_CMAKE), "", self._conan_helpers.cache.store) + replace_in_file(self, os.path.join(self.package_folder, AUTOIJECT_CMAKE), "", str(Path.home())) + + def package_info(self): + self.cpp_info.libdirs = [] + self.cpp_info.includedirs = [] + if self.conf.get("user.ccache:auto_inject", default=True, check_type=bool): + self.conf_info.append("tools.cmake.cmaketoolchain:user_toolchain", os.path.join(self.package_folder, AUTOIJECT_CMAKE)) diff --git a/recipes/ccache/binary/test_package/CMakeLists.txt b/recipes/ccache/binary/test_package/CMakeLists.txt new file mode 100644 index 0000000..35cfafb --- /dev/null +++ b/recipes/ccache/binary/test_package/CMakeLists.txt @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES CXX) + +add_executable(${PROJECT_NAME} test_package.cpp) diff --git a/recipes/ccache/binary/test_package/conanfile.py b/recipes/ccache/binary/test_package/conanfile.py new file mode 100644 index 0000000..6b3ab8e --- /dev/null +++ b/recipes/ccache/binary/test_package/conanfile.py @@ -0,0 +1,32 @@ +import os +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +from conan.errors import ConanException + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain" + + def build_requirements(self): + self.tool_requires(self.tested_reference_str) + + def test(self): + generated_file = os.path.join(self.dependencies.build[self.tested_reference_str].package_folder, "ccache-autoinject.cmake") + if not os.path.exists(generated_file): + raise ConanException("ccache-autoinject.cmake toolchain file does not exist") + user_toolchain = self.conf.get("tools.cmake.cmaketoolchain:user_toolchain", check_type=list) + if generated_file not in user_toolchain: + raise ConanException("ccache not found in user toolchain") + + if can_run(self): + self.run("ccache --version", env="conanbuild") + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() diff --git a/recipes/ccache/binary/test_package/test_package.cpp b/recipes/ccache/binary/test_package/test_package.cpp new file mode 100644 index 0000000..fc9a9df --- /dev/null +++ b/recipes/ccache/binary/test_package/test_package.cpp @@ -0,0 +1,5 @@ +#include + +int main() { + std::cout << "Hello world!\n"; +} diff --git a/recipes/ccache/config.yml b/recipes/ccache/config.yml new file mode 100644 index 0000000..0e00862 --- /dev/null +++ b/recipes/ccache/config.yml @@ -0,0 +1,3 @@ +versions: + "4.10.2": + folder: binary From f4ab809786a869d62437f9b84370dda9b8d8c728 Mon Sep 17 00:00:00 2001 From: PerseoGI Date: Thu, 12 Jun 2025 18:11:15 +0200 Subject: [PATCH 2/7] WIP --- recipes/ccache/binary/ccache-autoinject.cmake | 231 ++++++++++++++++-- recipes/ccache/binary/conanfile.py | 3 + .../ccache/binary/test_package/conanfile.py | 16 +- 3 files changed, 222 insertions(+), 28 deletions(-) diff --git a/recipes/ccache/binary/ccache-autoinject.cmake b/recipes/ccache/binary/ccache-autoinject.cmake index fcb2a37..2fff30e 100644 --- a/recipes/ccache/binary/ccache-autoinject.cmake +++ b/recipes/ccache/binary/ccache-autoinject.cmake @@ -1,25 +1,216 @@ +# SPDX-License-Identifier: MIT +# SPDX-FileCopyrightText: 2024 Maxim Radugin + +#[=======================================================================[.rst: +Findccache +---------- + +This module finds the compiler cache executable on the system and routes +compilation and linking calls via compiler cache executable for Xcode, +Visual Studio, Ninja and Unix Makefiles generators. + +Add path where Findccache.cmake is located to CMAKE_MODULE_PATH variable. +For example, if Findccache.cmake is located next to CMakeLists.txt file, use:: + + list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}) + +``CMAKE_MODULE_PATH`` should be set before calling find_package(). +See example project. + +For more information on find package modules see: +https://cmake.org/cmake/help/latest/command/find_package.html + +Adding following line after ``project()`` will try to enable use of compiler +cache:: + + find_package(ccache) + +As of time of writing ccache does not yet support MSVC /Zi flag and requires +/Z7 instead. If possible, it is advised to switch CMP0141 to NEW and set +CMAKE_MSVC_DEBUG_INFORMATION_FORMAT to ``Embedded`` in the root CMakeLists.txt +before first ``project()`` or ``enable_language()`` call. If ``CMP0141`` is set +to ``OLD``, this script will try the old way of switching debug information +format by manipulating ``CMAKE__FLAGS_`` variables, which is known +to be unreliable in some cases:: + + set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT Embedded) + cmake_policy(SET CMP0141 NEW) + + project(...) + +This module will look only for ``ccache`` program by default, force override +``CCACHE_PROGRAMS`` cache variable to look for for alternative compiler +cache programs:: + + set(CCACHE_PROGRAMS "sccache;buildcache;ccache" CACHE STRING _ FORCE) + +The following variables are provided to indicate compiler cache support: + +``CCACHE_FOUND`` + Variable indicating if the compiler cache executable was found. + +``CCACHE_SUPPORTED`` + Variable indicating if the ccache supports current generator. + +#]=======================================================================] + include_guard() +set(CCACHE_PROGRAMS "ccache" CACHE STRING "eligible compiler cache programs to look for") -# Enable cache if available -set(CACHE_OPTION "ccache" CACHE STRING "Compiler cache to be used") -set(CACHE_OPTION_VALUES "ccache" "sccache") -set(CCACHE_ARGS "base_dir=;hash_dir=false") -set_property(CACHE CACHE_OPTION PROPERTY STRINGS ${CACHE_OPTION_VALUES}) -list(FIND CACHE_OPTION_VALUES ${CACHE_OPTION} CACHE_OPTION_INDEX) - -if(${CACHE_OPTION_INDEX} EQUAL -1) - message( - STATUS - "Using custom compiler cache system: '${CACHE_OPTION}', explicitly supported entries are ${CACHE_OPTION_VALUES}" - ) -endif() +find_program(CCACHE_PROGRAM NAMES ${CCACHE_PROGRAMS} DOC "compiler cache executable") + +# handle the QUIETLY and REQUIRED arguments and set xxx_FOUND to TRUE if +# all listed variables are TRUE +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args(ccache + DEFAULT_MSG + CCACHE_PROGRAM +) + +if (CCACHE_FOUND) + set(CCACHE_SUPPORTED YES) + + if (CMAKE_GENERATOR STREQUAL "Xcode") + set(c_launcher_file "#!/bin/sh\nexec \"${CCACHE_PROGRAM}\" \"${CMAKE_C_COMPILER}\" \"$@\"\n") + set(cxx_launcher_file "#!/bin/sh\nexec \"${CCACHE_PROGRAM}\" \"${CMAKE_CXX_COMPILER}\" \"$@\"\n") + file(CONFIGURE OUTPUT ${CMAKE_BINARY_DIR}/launch-c CONTENT "${c_launcher_file}") + file(CONFIGURE OUTPUT ${CMAKE_BINARY_DIR}/launch-cxx CONTENT "${cxx_launcher_file}") + execute_process(COMMAND chmod a+rx + "${CMAKE_BINARY_DIR}/launch-c" + "${CMAKE_BINARY_DIR}/launch-cxx" + ) -find_program(CACHE_BINARY NAMES ${CACHE_OPTION_VALUES}) -if(CACHE_BINARY) - message(STATUS "${CACHE_BINARY} found and enabled") - set(CMAKE_CXX_COMPILER_LAUNCHER "${CACHE_BINARY};${CCACHE_ARGS}" CACHE FILEPATH "CXX compiler cache used") - set(CMAKE_C_COMPILER_LAUNCHER "${CACHE_BINARY};${CCACHE_ARGS}" CACHE FILEPATH "C compiler cache used") -else() - message(WARNING "${CACHE_OPTION} is enabled but was not found. Not using it") + # Set Xcode project attributes to route compilation and linking through our scripts + set(CMAKE_XCODE_ATTRIBUTE_CC "${CMAKE_BINARY_DIR}/launch-c" CACHE INTERNAL _) + set(CMAKE_XCODE_ATTRIBUTE_CXX "${CMAKE_BINARY_DIR}/launch-cxx" CACHE INTERNAL _) + set(CMAKE_XCODE_ATTRIBUTE_LD "${CMAKE_BINARY_DIR}/launch-c" CACHE INTERNAL _) + set(CMAKE_XCODE_ATTRIBUTE_LDPLUSPLUS "${CMAKE_BINARY_DIR}/launch-cxx" CACHE INTERNAL _) + elseif (CMAKE_GENERATOR MATCHES "Visual Studio") + # Copy original ccache.exe and rename to cl.exe, this way intermediate cmd file is not needed + file(COPY_FILE ${CCACHE_PROGRAM} ${CMAKE_BINARY_DIR}/cl.exe ONLY_IF_DIFFERENT) + + # Set Visual Studio global variables: + # - Use above cl.exe (ccache.exe) as a compiler + # - Enable parallel compilation + list(APPEND CMAKE_VS_GLOBALS + "CLToolExe=cl.exe" + "CLToolPath=${CMAKE_BINARY_DIR}" + "UseMultiToolTask=true" + "UseStructuredOutput=false" + ) + elseif(CMAKE_GENERATOR MATCHES "Ninja" OR CMAKE_GENERATOR MATCHES "Unix Makefiles") + # Support Unix Makefiles and Ninja + set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM}") + set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}") + else() + message(WARNING "Unsupported generator for compiler cache: ${CMAKE_GENERATOR}") + set(CCACHE_SUPPORTED NO) + endif() + + # For MSVC compiler need to check and/or set compatible debug information format + if (CCACHE_SUPPORTED AND CMAKE_CXX_COMPILER_ID MATCHES "MSVC") + cmake_policy(GET CMP0141 msvc_debug_info_format_policy) + if (msvc_debug_info_format_policy STREQUAL "NEW") + if (NOT CMAKE_MSVC_DEBUG_INFORMATION_FORMAT) + message(WARNING "CMAKE_MSVC_DEBUG_INFORMATION_FORMAT is not set, set it to \"Embedded\" for compiler cache to work") + set(CCACHE_SUPPORTED NO) + elseif (NOT CMAKE_MSVC_DEBUG_INFORMATION_FORMAT STREQUAL "Embedded") + message(WARNING "Unsupported MSVC debug information format for compiler cache: ${CMAKE_MSVC_DEBUG_INFORMATION_FORMAT}") + set(CCACHE_SUPPORTED NO) + endif() + else() + # Use the old way to try to switch from /Zi or /ZI to /Z7 (it is known not to work for some third-party CMake projects) + + # Determine if this is being generated by a multi-config CMake generator + get_property(IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + + # If the user has not provided us with the build target then we generate sensible defaults + if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + if (IS_MULTI_CONFIG) + message(WARNING "Multi-config generator is used without build types defined, setting CMAKE_CONFIGURATION_TYPES using default values") + set(CMAKE_CONFIGURATION_TYPES "Debug;MinSizeRel;Release;RelWithDebInfo") + else() + message(WARNING "Single-config generator is used without build type defined, setting CMAKE_BUILD_TYPE using default value") + set(CMAKE_BUILD_TYPE "Debug") + endif() + endif() + + # For cache to work debug information should be included within object files (/Z7 flag) + # and will be combined in pdb during linking phase + set(flag_pattern "[/\-]Z[iI]") + if (IS_MULTI_CONFIG) + foreach(config ${CMAKE_CONFIGURATION_TYPES}) + string(TOUPPER "${config}" config) + string(REGEX REPLACE "${flag_pattern}" "/Z7" CMAKE_CXX_FLAGS_${config} "${CMAKE_CXX_FLAGS_${config}}") + string(REGEX REPLACE "${flag_pattern}" "/Z7" CMAKE_C_FLAGS_${config} "${CMAKE_C_FLAGS_${config}}") + endforeach() + else() + string(TOUPPER "${CMAKE_BUILD_TYPE}" config) + string(REGEX REPLACE "${flag_pattern}" "/Z7" CMAKE_CXX_FLAGS_${config} "${CMAKE_CXX_FLAGS_${config}}") + string(REGEX REPLACE "${flag_pattern}" "/Z7" CMAKE_C_FLAGS_${config} "${CMAKE_C_FLAGS_${config}}") + endif() + endif() + endif() + message(STATUS "Using compiler cache: ${CCACHE_SUPPORTED}") + mark_as_advanced(CCACHE_PROGRAM) endif() + +# include_guard() +# +# # Enable cache if available +# set(CACHE_OPTION "ccache" CACHE STRING "Compiler cache to be used") +# set(CACHE_OPTION_VALUES "ccache" "sccache") +# set(CCACHE_ARGS "base_dir=;hash_dir=false") +# set_property(CACHE CACHE_OPTION PROPERTY STRINGS ${CACHE_OPTION_VALUES}) +# list(FIND CACHE_OPTION_VALUES ${CACHE_OPTION} CACHE_OPTION_INDEX) +# +# if(${CACHE_OPTION_INDEX} EQUAL -1) +# message( +# STATUS +# "Using custom compiler cache system: '${CACHE_OPTION}', explicitly supported entries are ${CACHE_OPTION_VALUES}" +# ) +# endif() +# +# find_program(CACHE_BINARY NAMES ${CACHE_OPTION_VALUES}) +# if(CACHE_BINARY) +# message(STATUS "${CACHE_BINARY} version ${ccache_VERSION} found and enabled") +# set(CMAKE_CXX_COMPILER_LAUNCHER "${CACHE_BINARY};${CCACHE_ARGS}" CACHE FILEPATH "CXX compiler cache used") +# set(CMAKE_C_COMPILER_LAUNCHER "${CACHE_BINARY};${CCACHE_ARGS}" CACHE FILEPATH "C compiler cache used") +# else() +# message(WARNING "${CACHE_OPTION} is enabled but was not found. Not using it") +# endif() + + +# include_guard() +# +# # Find ccache executable +# find_program(CCACHE_PROGRAM NAMES ccache) +# +# if(CCACHE_PROGRAM) +# message(STATUS "ccache found: ${CCACHE_PROGRAM}, enabling via CMake launcher and environment.") +# # Method 1: Set CMake launcher variables +# set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_PROGRAM} CACHE FILEPATH "CXX compiler cache used" FORCE) +# set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_PROGRAM} CACHE FILEPATH "C compiler cache used" FORCE) +# +# # Method 2: Set environment variables (ccache reads these automatically) +# # This is often more robust and recommended for hash_dir/base_dir. +# set(ENV{CCACHE_NOHASHDIR}) +# if(DEFINED ENV{HOME}) +# set(ENV{CCACHE_BASEDIR} "$ENV{HOME}") # Use HOME if defined +# elseif(DEFINED ENV{CI_PROJECT_DIR}) +# set(ENV{CCACHE_BASEDIR} "$ENV{CI_PROJECT_DIR}") # Example for GitLab CI +# elseif(DEFINED ENV{GITHUB_WORKSPACE}) +# set(ENV{CCACHE_BASEDIR} "$ENV{GITHUB_WORKSPACE}") # Example for GitHub Actions +# # Add more conditions for your specific CI/dev environments if needed +# else() +# message(WARNING "Could not determine a suitable CCACHE_BASEDIR automatically.") +# endif() +# # Ensure base_dir exists (ccache might require this) +# if(DEFINED ENV{CCACHE_BASEDIR} AND NOT IS_DIRECTORY "$ENV{CCACHE_BASEDIR}") +# message(WARNING "CCACHE_BASEDIR '$ENV{CCACHE_BASEDIR}' is not a directory.") +# endif() +# else() +# message(WARNING "ccache not found. Not enabling ccache integration.") +# endif() diff --git a/recipes/ccache/binary/conanfile.py b/recipes/ccache/binary/conanfile.py index 2f890ef..1cc07f2 100644 --- a/recipes/ccache/binary/conanfile.py +++ b/recipes/ccache/binary/conanfile.py @@ -54,3 +54,6 @@ def package_info(self): self.cpp_info.includedirs = [] if self.conf.get("user.ccache:auto_inject", default=True, check_type=bool): self.conf_info.append("tools.cmake.cmaketoolchain:user_toolchain", os.path.join(self.package_folder, AUTOIJECT_CMAKE)) + + self.buildenv_info.define("CCACHE_NOHASHDIR", "1") + self.buildenv_info.define("CCACHE_BASEDIR", str(Path.home())) diff --git a/recipes/ccache/binary/test_package/conanfile.py b/recipes/ccache/binary/test_package/conanfile.py index 6b3ab8e..faeb532 100644 --- a/recipes/ccache/binary/test_package/conanfile.py +++ b/recipes/ccache/binary/test_package/conanfile.py @@ -12,6 +12,14 @@ class TestPackageConan(ConanFile): def build_requirements(self): self.tool_requires(self.tested_reference_str) + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + def test(self): generated_file = os.path.join(self.dependencies.build[self.tested_reference_str].package_folder, "ccache-autoinject.cmake") if not os.path.exists(generated_file): @@ -22,11 +30,3 @@ def test(self): if can_run(self): self.run("ccache --version", env="conanbuild") - - def layout(self): - cmake_layout(self) - - def build(self): - cmake = CMake(self) - cmake.configure() - cmake.build() From e389c9d098ebe69b873a5ee1583b0c685c83478b Mon Sep 17 00:00:00 2001 From: PerseoGI Date: Wed, 2 Jul 2025 12:30:19 +0200 Subject: [PATCH 3/7] Refactor recipe --- recipes/ccache/binary/ccache-autoinject.cmake | 221 +----------------- recipes/ccache/binary/conandata.yml | 17 +- recipes/ccache/binary/conanfile.py | 27 ++- .../ccache/binary/test_package/conanfile.py | 2 + recipes/ccache/config.yml | 2 +- 5 files changed, 35 insertions(+), 234 deletions(-) diff --git a/recipes/ccache/binary/ccache-autoinject.cmake b/recipes/ccache/binary/ccache-autoinject.cmake index 2fff30e..6e38f6d 100644 --- a/recipes/ccache/binary/ccache-autoinject.cmake +++ b/recipes/ccache/binary/ccache-autoinject.cmake @@ -1,216 +1,13 @@ -# SPDX-License-Identifier: MIT -# SPDX-FileCopyrightText: 2024 Maxim Radugin - -#[=======================================================================[.rst: -Findccache ----------- - -This module finds the compiler cache executable on the system and routes -compilation and linking calls via compiler cache executable for Xcode, -Visual Studio, Ninja and Unix Makefiles generators. - -Add path where Findccache.cmake is located to CMAKE_MODULE_PATH variable. -For example, if Findccache.cmake is located next to CMakeLists.txt file, use:: - - list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}) - -``CMAKE_MODULE_PATH`` should be set before calling find_package(). -See example project. - -For more information on find package modules see: -https://cmake.org/cmake/help/latest/command/find_package.html - -Adding following line after ``project()`` will try to enable use of compiler -cache:: - - find_package(ccache) - -As of time of writing ccache does not yet support MSVC /Zi flag and requires -/Z7 instead. If possible, it is advised to switch CMP0141 to NEW and set -CMAKE_MSVC_DEBUG_INFORMATION_FORMAT to ``Embedded`` in the root CMakeLists.txt -before first ``project()`` or ``enable_language()`` call. If ``CMP0141`` is set -to ``OLD``, this script will try the old way of switching debug information -format by manipulating ``CMAKE__FLAGS_`` variables, which is known -to be unreliable in some cases:: - - set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT Embedded) - cmake_policy(SET CMP0141 NEW) - - project(...) - -This module will look only for ``ccache`` program by default, force override -``CCACHE_PROGRAMS`` cache variable to look for for alternative compiler -cache programs:: - - set(CCACHE_PROGRAMS "sccache;buildcache;ccache" CACHE STRING _ FORCE) - -The following variables are provided to indicate compiler cache support: - -``CCACHE_FOUND`` - Variable indicating if the compiler cache executable was found. - -``CCACHE_SUPPORTED`` - Variable indicating if the ccache supports current generator. - -#]=======================================================================] - include_guard() -set(CCACHE_PROGRAMS "ccache" CACHE STRING "eligible compiler cache programs to look for") - -find_program(CCACHE_PROGRAM NAMES ${CCACHE_PROGRAMS} DOC "compiler cache executable") - -# handle the QUIETLY and REQUIRED arguments and set xxx_FOUND to TRUE if -# all listed variables are TRUE -include(FindPackageHandleStandardArgs) - -find_package_handle_standard_args(ccache - DEFAULT_MSG - CCACHE_PROGRAM -) - -if (CCACHE_FOUND) - set(CCACHE_SUPPORTED YES) - - if (CMAKE_GENERATOR STREQUAL "Xcode") - set(c_launcher_file "#!/bin/sh\nexec \"${CCACHE_PROGRAM}\" \"${CMAKE_C_COMPILER}\" \"$@\"\n") - set(cxx_launcher_file "#!/bin/sh\nexec \"${CCACHE_PROGRAM}\" \"${CMAKE_CXX_COMPILER}\" \"$@\"\n") - file(CONFIGURE OUTPUT ${CMAKE_BINARY_DIR}/launch-c CONTENT "${c_launcher_file}") - file(CONFIGURE OUTPUT ${CMAKE_BINARY_DIR}/launch-cxx CONTENT "${cxx_launcher_file}") - execute_process(COMMAND chmod a+rx - "${CMAKE_BINARY_DIR}/launch-c" - "${CMAKE_BINARY_DIR}/launch-cxx" - ) - # Set Xcode project attributes to route compilation and linking through our scripts - set(CMAKE_XCODE_ATTRIBUTE_CC "${CMAKE_BINARY_DIR}/launch-c" CACHE INTERNAL _) - set(CMAKE_XCODE_ATTRIBUTE_CXX "${CMAKE_BINARY_DIR}/launch-cxx" CACHE INTERNAL _) - set(CMAKE_XCODE_ATTRIBUTE_LD "${CMAKE_BINARY_DIR}/launch-c" CACHE INTERNAL _) - set(CMAKE_XCODE_ATTRIBUTE_LDPLUSPLUS "${CMAKE_BINARY_DIR}/launch-cxx" CACHE INTERNAL _) - elseif (CMAKE_GENERATOR MATCHES "Visual Studio") - # Copy original ccache.exe and rename to cl.exe, this way intermediate cmd file is not needed - file(COPY_FILE ${CCACHE_PROGRAM} ${CMAKE_BINARY_DIR}/cl.exe ONLY_IF_DIFFERENT) +# Find ccache executable +find_program(CCACHE_PROGRAM NAMES ccache) - # Set Visual Studio global variables: - # - Use above cl.exe (ccache.exe) as a compiler - # - Enable parallel compilation - list(APPEND CMAKE_VS_GLOBALS - "CLToolExe=cl.exe" - "CLToolPath=${CMAKE_BINARY_DIR}" - "UseMultiToolTask=true" - "UseStructuredOutput=false" - ) - elseif(CMAKE_GENERATOR MATCHES "Ninja" OR CMAKE_GENERATOR MATCHES "Unix Makefiles") - # Support Unix Makefiles and Ninja - set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM}") - set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}") - else() - message(WARNING "Unsupported generator for compiler cache: ${CMAKE_GENERATOR}") - set(CCACHE_SUPPORTED NO) - endif() - - # For MSVC compiler need to check and/or set compatible debug information format - if (CCACHE_SUPPORTED AND CMAKE_CXX_COMPILER_ID MATCHES "MSVC") - cmake_policy(GET CMP0141 msvc_debug_info_format_policy) - if (msvc_debug_info_format_policy STREQUAL "NEW") - if (NOT CMAKE_MSVC_DEBUG_INFORMATION_FORMAT) - message(WARNING "CMAKE_MSVC_DEBUG_INFORMATION_FORMAT is not set, set it to \"Embedded\" for compiler cache to work") - set(CCACHE_SUPPORTED NO) - elseif (NOT CMAKE_MSVC_DEBUG_INFORMATION_FORMAT STREQUAL "Embedded") - message(WARNING "Unsupported MSVC debug information format for compiler cache: ${CMAKE_MSVC_DEBUG_INFORMATION_FORMAT}") - set(CCACHE_SUPPORTED NO) - endif() - else() - # Use the old way to try to switch from /Zi or /ZI to /Z7 (it is known not to work for some third-party CMake projects) - - # Determine if this is being generated by a multi-config CMake generator - get_property(IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) - - # If the user has not provided us with the build target then we generate sensible defaults - if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) - if (IS_MULTI_CONFIG) - message(WARNING "Multi-config generator is used without build types defined, setting CMAKE_CONFIGURATION_TYPES using default values") - set(CMAKE_CONFIGURATION_TYPES "Debug;MinSizeRel;Release;RelWithDebInfo") - else() - message(WARNING "Single-config generator is used without build type defined, setting CMAKE_BUILD_TYPE using default value") - set(CMAKE_BUILD_TYPE "Debug") - endif() - endif() - - # For cache to work debug information should be included within object files (/Z7 flag) - # and will be combined in pdb during linking phase - set(flag_pattern "[/\-]Z[iI]") - if (IS_MULTI_CONFIG) - foreach(config ${CMAKE_CONFIGURATION_TYPES}) - string(TOUPPER "${config}" config) - string(REGEX REPLACE "${flag_pattern}" "/Z7" CMAKE_CXX_FLAGS_${config} "${CMAKE_CXX_FLAGS_${config}}") - string(REGEX REPLACE "${flag_pattern}" "/Z7" CMAKE_C_FLAGS_${config} "${CMAKE_C_FLAGS_${config}}") - endforeach() - else() - string(TOUPPER "${CMAKE_BUILD_TYPE}" config) - string(REGEX REPLACE "${flag_pattern}" "/Z7" CMAKE_CXX_FLAGS_${config} "${CMAKE_CXX_FLAGS_${config}}") - string(REGEX REPLACE "${flag_pattern}" "/Z7" CMAKE_C_FLAGS_${config} "${CMAKE_C_FLAGS_${config}}") - endif() - endif() - endif() - message(STATUS "Using compiler cache: ${CCACHE_SUPPORTED}") - mark_as_advanced(CCACHE_PROGRAM) +if(CCACHE_PROGRAM) + message(STATUS "ccache found: ${CCACHE_PROGRAM}, enabling via CMake launcher and environment.") + # Method 1: Set CMake launcher variables + set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_PROGRAM} CACHE FILEPATH "CXX compiler cache used" FORCE) + set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_PROGRAM} CACHE FILEPATH "C compiler cache used" FORCE) +else() + message(WARNING "ccache not found. Not enabling ccache integration.") endif() - - -# include_guard() -# -# # Enable cache if available -# set(CACHE_OPTION "ccache" CACHE STRING "Compiler cache to be used") -# set(CACHE_OPTION_VALUES "ccache" "sccache") -# set(CCACHE_ARGS "base_dir=;hash_dir=false") -# set_property(CACHE CACHE_OPTION PROPERTY STRINGS ${CACHE_OPTION_VALUES}) -# list(FIND CACHE_OPTION_VALUES ${CACHE_OPTION} CACHE_OPTION_INDEX) -# -# if(${CACHE_OPTION_INDEX} EQUAL -1) -# message( -# STATUS -# "Using custom compiler cache system: '${CACHE_OPTION}', explicitly supported entries are ${CACHE_OPTION_VALUES}" -# ) -# endif() -# -# find_program(CACHE_BINARY NAMES ${CACHE_OPTION_VALUES}) -# if(CACHE_BINARY) -# message(STATUS "${CACHE_BINARY} version ${ccache_VERSION} found and enabled") -# set(CMAKE_CXX_COMPILER_LAUNCHER "${CACHE_BINARY};${CCACHE_ARGS}" CACHE FILEPATH "CXX compiler cache used") -# set(CMAKE_C_COMPILER_LAUNCHER "${CACHE_BINARY};${CCACHE_ARGS}" CACHE FILEPATH "C compiler cache used") -# else() -# message(WARNING "${CACHE_OPTION} is enabled but was not found. Not using it") -# endif() - - -# include_guard() -# -# # Find ccache executable -# find_program(CCACHE_PROGRAM NAMES ccache) -# -# if(CCACHE_PROGRAM) -# message(STATUS "ccache found: ${CCACHE_PROGRAM}, enabling via CMake launcher and environment.") -# # Method 1: Set CMake launcher variables -# set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_PROGRAM} CACHE FILEPATH "CXX compiler cache used" FORCE) -# set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_PROGRAM} CACHE FILEPATH "C compiler cache used" FORCE) -# -# # Method 2: Set environment variables (ccache reads these automatically) -# # This is often more robust and recommended for hash_dir/base_dir. -# set(ENV{CCACHE_NOHASHDIR}) -# if(DEFINED ENV{HOME}) -# set(ENV{CCACHE_BASEDIR} "$ENV{HOME}") # Use HOME if defined -# elseif(DEFINED ENV{CI_PROJECT_DIR}) -# set(ENV{CCACHE_BASEDIR} "$ENV{CI_PROJECT_DIR}") # Example for GitLab CI -# elseif(DEFINED ENV{GITHUB_WORKSPACE}) -# set(ENV{CCACHE_BASEDIR} "$ENV{GITHUB_WORKSPACE}") # Example for GitHub Actions -# # Add more conditions for your specific CI/dev environments if needed -# else() -# message(WARNING "Could not determine a suitable CCACHE_BASEDIR automatically.") -# endif() -# # Ensure base_dir exists (ccache might require this) -# if(DEFINED ENV{CCACHE_BASEDIR} AND NOT IS_DIRECTORY "$ENV{CCACHE_BASEDIR}") -# message(WARNING "CCACHE_BASEDIR '$ENV{CCACHE_BASEDIR}' is not a directory.") -# endif() -# else() -# message(WARNING "ccache not found. Not enabling ccache integration.") -# endif() diff --git a/recipes/ccache/binary/conandata.yml b/recipes/ccache/binary/conandata.yml index 2a9ead5..e1c5aea 100644 --- a/recipes/ccache/binary/conandata.yml +++ b/recipes/ccache/binary/conandata.yml @@ -1,14 +1,17 @@ sources: - "4.10.2": + "4.11.3": Linux: x86_64: - url: "https://github.com/ccache/ccache/releases/download/v4.10.2/ccache-4.10.2-linux-x86_64.tar.xz" - sha256: "80cab87bd510eca796467aee8e663c398239e0df1c4800a0b5dff11dca0b4f18" + url: "https://github.com/ccache/ccache/releases/download/v4.11.3/ccache-4.11.3-linux-x86_64.tar.xz" + sha256: "" Macos: universal: - url: "https://github.com/ccache/ccache/releases/download/v4.10.2/ccache-4.10.2-darwin.tar.gz" - sha256: "d90514fff15943a8607e84e3f42d45f823915a92f99984f3fc88202f6295d1e8" + url: "https://github.com/ccache/ccache/releases/download/v4.11.3/ccache-4.11.3-darwin.tar.gz" + sha256: "6f187a79fc57864d900aff28f9c3f93d020ed7a849be2f2ead6799959ccf30b0" Windows: x86_64: - url: "https://github.com/ccache/ccache/releases/download/v4.10.2/ccache-4.10.2-windows-x86_64.zip" - sha256: "6252f081876a9a9f700fae13a5aec5d0d486b28261d7f1f72ac11c7ad9df4da9" + url: "https://github.com/ccache/ccache/releases/download/v4.10.2/ccache-4.11.3-windows-x86_64.zip" + sha256: "" + x86: + url: "https://github.com/ccache/ccache/releases/download/v4.11.3/ccache-4.11.3-windows-i686.zip" + sha256: "" diff --git a/recipes/ccache/binary/conanfile.py b/recipes/ccache/binary/conanfile.py index 1cc07f2..2042479 100644 --- a/recipes/ccache/binary/conanfile.py +++ b/recipes/ccache/binary/conanfile.py @@ -3,9 +3,9 @@ from conan import ConanFile from conan.errors import ConanInvalidConfiguration -from conan.tools.files import get, copy, replace_in_file +from conan.tools.files import get, copy -required_conan_version = ">=2.7" +required_conan_version = ">=2.1" AUTOIJECT_CMAKE = "ccache-autoinject.cmake" @@ -24,18 +24,21 @@ class CcacheConan(ConanFile): settings = "os", "arch" exports_sources = [AUTOIJECT_CMAKE] + @property + def _arch(self): + return str(self.settings.arch) if self.settings.os != "Macos" else "universal" + def validate(self): - if self.settings.os != "Macos" and self.settings.arch != "x86_64": - raise ConanInvalidConfiguration("ccache binaries are only provided for x86_64 architectures") + if self.conan_data["sources"][self.version].get(str(self.settings.os), {}).get(self._arch) is None: + raise ConanInvalidConfiguration(f"ccache binaries do not support '{self.settings.os} - {self._arch}'") def build(self): - arch = str(self.settings.arch) if self.settings.os != "Macos" else "universal" - get(self, **self.conan_data["sources"][self.version][str(self.settings.os)][arch], + get(self, **self.conan_data["sources"][self.version][str(self.settings.os)][self._arch], destination=self.source_folder, strip_root=True) def package_id(self): if self.info.settings.os == "Macos": - del self.info.settings.arch + self.info.settings.arch = "universal" def package(self): copy(self, "*GPL-*.txt", src=self.build_folder, dst=os.path.join(self.package_folder, "licenses")) @@ -43,17 +46,13 @@ def package(self): copy(self, "ccache", src=self.build_folder, dst=os.path.join(self.package_folder, "bin")) copy(self, AUTOIJECT_CMAKE, src=self.build_folder, dst=self.package_folder) - def finalize(self): - copy(self, "*", src=self.immutable_package_folder, dst=self.package_folder) - # TODO: find a way of retrieving conan home without accessing private API - # replace_in_file(self, os.path.join(self.package_folder, AUTOIJECT_CMAKE), "", self._conan_helpers.cache.store) - replace_in_file(self, os.path.join(self.package_folder, AUTOIJECT_CMAKE), "", str(Path.home())) - def package_info(self): self.cpp_info.libdirs = [] self.cpp_info.includedirs = [] if self.conf.get("user.ccache:auto_inject", default=True, check_type=bool): self.conf_info.append("tools.cmake.cmaketoolchain:user_toolchain", os.path.join(self.package_folder, AUTOIJECT_CMAKE)) + # Set environment variables to allow ccache work correctly within conan build/create workflow + base_dir = self.conf.get("user.ccache:base_dir", default=str(Path.home()), check_type=str) + self.buildenv_info.define("CCACHE_BASEDIR", base_dir) self.buildenv_info.define("CCACHE_NOHASHDIR", "1") - self.buildenv_info.define("CCACHE_BASEDIR", str(Path.home())) diff --git a/recipes/ccache/binary/test_package/conanfile.py b/recipes/ccache/binary/test_package/conanfile.py index faeb532..1c490c7 100644 --- a/recipes/ccache/binary/test_package/conanfile.py +++ b/recipes/ccache/binary/test_package/conanfile.py @@ -30,3 +30,5 @@ def test(self): if can_run(self): self.run("ccache --version", env="conanbuild") + self.run("ccache --get-config hash_dir", env="conanbuild") + self.run("ccache --get-config base_dir", env="conanbuild") diff --git a/recipes/ccache/config.yml b/recipes/ccache/config.yml index 0e00862..5acb80a 100644 --- a/recipes/ccache/config.yml +++ b/recipes/ccache/config.yml @@ -1,3 +1,3 @@ versions: - "4.10.2": + "4.11.3": folder: binary From c808e9bc690e95c625aba808df4da9f9f2df725a Mon Sep 17 00:00:00 2001 From: PerseoGI Date: Wed, 2 Jul 2025 13:06:05 +0200 Subject: [PATCH 4/7] Updated autoinject --- recipes/ccache/binary/ccache-autoinject.cmake | 23 ++++++++++++++++--- recipes/ccache/binary/conandata.yml | 8 +++---- recipes/ccache/binary/conanfile.py | 2 +- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/recipes/ccache/binary/ccache-autoinject.cmake b/recipes/ccache/binary/ccache-autoinject.cmake index 6e38f6d..c79deeb 100644 --- a/recipes/ccache/binary/ccache-autoinject.cmake +++ b/recipes/ccache/binary/ccache-autoinject.cmake @@ -5,9 +5,26 @@ find_program(CCACHE_PROGRAM NAMES ccache) if(CCACHE_PROGRAM) message(STATUS "ccache found: ${CCACHE_PROGRAM}, enabling via CMake launcher and environment.") - # Method 1: Set CMake launcher variables - set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_PROGRAM} CACHE FILEPATH "CXX compiler cache used" FORCE) - set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_PROGRAM} CACHE FILEPATH "C compiler cache used" FORCE) + if (CMAKE_GENERATOR MATCHES "Visual Studio") + # Copy original ccache.exe and rename to cl.exe, this way intermediate cmd file is not needed + file(COPY_FILE ${CCACHE_PROGRAM} ${CMAKE_BINARY_DIR}/cl.exe ONLY_IF_DIFFERENT) + + # Set Visual Studio global variables: + # - Use above cl.exe (ccache.exe) as a compiler + # - Enable parallel compilation + list(APPEND CMAKE_VS_GLOBALS + "CLToolExe=cl.exe" + "CLToolPath=${CMAKE_BINARY_DIR}" + "UseMultiToolTask=true" + "UseStructuredOutput=false" + ) + elseif(CMAKE_GENERATOR MATCHES "Ninja" OR CMAKE_GENERATOR MATCHES "Unix Makefiles") + message(STATUS "Using ccache as compiler launcher for Ninja or Makefiles.") + set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_PROGRAM} CACHE FILEPATH "CXX compiler cache used" FORCE) + set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_PROGRAM} CACHE FILEPATH "C compiler cache used" FORCE) + else() + message(WARNING "Unsupported generator for ccache integration: ${CMAKE_GENERATOR}. ccache will not be used.") + endif() else() message(WARNING "ccache not found. Not enabling ccache integration.") endif() diff --git a/recipes/ccache/binary/conandata.yml b/recipes/ccache/binary/conandata.yml index e1c5aea..5017034 100644 --- a/recipes/ccache/binary/conandata.yml +++ b/recipes/ccache/binary/conandata.yml @@ -3,15 +3,15 @@ sources: Linux: x86_64: url: "https://github.com/ccache/ccache/releases/download/v4.11.3/ccache-4.11.3-linux-x86_64.tar.xz" - sha256: "" + sha256: "7766991b91b3a5a177ab33fa043fe09e72c68586d5a86d20a563a05b74f119c0" Macos: universal: url: "https://github.com/ccache/ccache/releases/download/v4.11.3/ccache-4.11.3-darwin.tar.gz" sha256: "6f187a79fc57864d900aff28f9c3f93d020ed7a849be2f2ead6799959ccf30b0" Windows: x86_64: - url: "https://github.com/ccache/ccache/releases/download/v4.10.2/ccache-4.11.3-windows-x86_64.zip" - sha256: "" + url: "https://github.com/ccache/ccache/releases/download/v4.11.3/ccache-4.11.3-windows-x86_64.zip" + sha256: "bfd031cad091b7db7e68c3303be542b0f7fee7a3e716d76ec6f7e6c7ef4b3526" x86: url: "https://github.com/ccache/ccache/releases/download/v4.11.3/ccache-4.11.3-windows-i686.zip" - sha256: "" + sha256: "ad0248edcce9959fe4075ddc41496a099366b0c785aee062a8d59d26c1385178" diff --git a/recipes/ccache/binary/conanfile.py b/recipes/ccache/binary/conanfile.py index 2042479..a0b4b7a 100644 --- a/recipes/ccache/binary/conanfile.py +++ b/recipes/ccache/binary/conanfile.py @@ -43,7 +43,7 @@ def package_id(self): def package(self): copy(self, "*GPL-*.txt", src=self.build_folder, dst=os.path.join(self.package_folder, "licenses")) copy(self, "LICENSE.*", src=self.build_folder, dst=os.path.join(self.package_folder, "licenses")) - copy(self, "ccache", src=self.build_folder, dst=os.path.join(self.package_folder, "bin")) + copy(self, "ccache*", src=self.build_folder, dst=os.path.join(self.package_folder, "bin")) copy(self, AUTOIJECT_CMAKE, src=self.build_folder, dst=self.package_folder) def package_info(self): From 49ed2131e4f186a7c246f9e60130a10263dbe448 Mon Sep 17 00:00:00 2001 From: PerseoGI Date: Tue, 8 Jul 2025 13:32:02 +0200 Subject: [PATCH 5/7] Add warning --- recipes/ccache/binary/conanfile.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/recipes/ccache/binary/conanfile.py b/recipes/ccache/binary/conanfile.py index a0b4b7a..651ab1f 100644 --- a/recipes/ccache/binary/conanfile.py +++ b/recipes/ccache/binary/conanfile.py @@ -56,3 +56,6 @@ def package_info(self): base_dir = self.conf.get("user.ccache:base_dir", default=str(Path.home()), check_type=str) self.buildenv_info.define("CCACHE_BASEDIR", base_dir) self.buildenv_info.define("CCACHE_NOHASHDIR", "1") + + self.output.warning("ccache recipe can autoinject itself into CMake projects but you need to define CC/CXX " + "environment variables to use it in other build systems such as Meson, Autotools, Premake, etc.") From 602bf2eaecb420ceeeeff3276c9080ab4d195d14 Mon Sep 17 00:00:00 2001 From: PerseoGI Date: Wed, 1 Oct 2025 10:56:53 +0200 Subject: [PATCH 6/7] Added latest ccache version 4.12 which supports windows arm --- recipes/ccache/binary/conandata.yml | 26 ++++++++++++++++---------- recipes/ccache/config.yml | 2 +- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/recipes/ccache/binary/conandata.yml b/recipes/ccache/binary/conandata.yml index 5017034..3d92022 100644 --- a/recipes/ccache/binary/conandata.yml +++ b/recipes/ccache/binary/conandata.yml @@ -1,17 +1,23 @@ sources: - "4.11.3": + "4.12": Linux: x86_64: - url: "https://github.com/ccache/ccache/releases/download/v4.11.3/ccache-4.11.3-linux-x86_64.tar.xz" - sha256: "7766991b91b3a5a177ab33fa043fe09e72c68586d5a86d20a563a05b74f119c0" + url: "https://github.com/ccache/ccache/releases/download/v4.12/ccache-4.12-linux-x86_64.tar.xz" + sha256: "d77e140d0403175b93f979f0b0d36e821bf31728b282f4bfda939f65836bcabe" + armv8: + url: "https://github.com/ccache/ccache/releases/download/v4.12/ccache-4.12-linux-aarch64.tar.xz" + sha256: "378ed4b9f645f5aab691447e4ec45b4c68508a424ac37c9be7baa28ded385791" Macos: universal: - url: "https://github.com/ccache/ccache/releases/download/v4.11.3/ccache-4.11.3-darwin.tar.gz" - sha256: "6f187a79fc57864d900aff28f9c3f93d020ed7a849be2f2ead6799959ccf30b0" + url: "https://github.com/ccache/ccache/releases/download/v4.12/ccache-4.12-darwin.tar.gz" + sha256: "95cb03de0f2e0edb264d2443f2fe4500a13086689cc9ecd1095eb274dd8d9aee" Windows: - x86_64: - url: "https://github.com/ccache/ccache/releases/download/v4.11.3/ccache-4.11.3-windows-x86_64.zip" - sha256: "bfd031cad091b7db7e68c3303be542b0f7fee7a3e716d76ec6f7e6c7ef4b3526" + armv8: + url: "https://github.com/ccache/ccache/releases/download/v4.12/ccache-4.12-windows-aarch64.zip" + sha256: "12d8a95507ce19bb90cff49faa5f5de07919d5d8d91f129bcf597dbc30d0c250" x86: - url: "https://github.com/ccache/ccache/releases/download/v4.11.3/ccache-4.11.3-windows-i686.zip" - sha256: "ad0248edcce9959fe4075ddc41496a099366b0c785aee062a8d59d26c1385178" + url: "https://github.com/ccache/ccache/releases/download/v4.12/ccache-4.12-windows-i686.zip" + sha256: "c046ad7159d312312662c380da5932d441407f56164e451b09c16dad8db01051" + x86_64: + url: "https://github.com/ccache/ccache/releases/download/v4.12/ccache-4.12-windows-x86_64.zip" + sha256: "85c963b154dcf5e38dc6839d660218433a3b0b86387c302675d236e17ae7220d" diff --git a/recipes/ccache/config.yml b/recipes/ccache/config.yml index 5acb80a..0d6ab71 100644 --- a/recipes/ccache/config.yml +++ b/recipes/ccache/config.yml @@ -1,3 +1,3 @@ versions: - "4.11.3": + "4.12": folder: binary From 4881ece5a981a2d7d2b5f5a8bf020c7a9abcd372 Mon Sep 17 00:00:00 2001 From: PerseoGI Date: Fri, 31 Oct 2025 10:50:05 +0100 Subject: [PATCH 7/7] Added latest version 4.12.1 --- recipes/ccache/binary/conandata.yml | 24 ++++++++++++------------ recipes/ccache/config.yml | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/recipes/ccache/binary/conandata.yml b/recipes/ccache/binary/conandata.yml index 3d92022..a962a89 100644 --- a/recipes/ccache/binary/conandata.yml +++ b/recipes/ccache/binary/conandata.yml @@ -1,23 +1,23 @@ sources: - "4.12": + "4.12.1": Linux: x86_64: - url: "https://github.com/ccache/ccache/releases/download/v4.12/ccache-4.12-linux-x86_64.tar.xz" - sha256: "d77e140d0403175b93f979f0b0d36e821bf31728b282f4bfda939f65836bcabe" + url: "https://github.com/ccache/ccache/releases/download/v4.12.1/ccache-4.12.1-linux-x86_64.tar.xz" + sha256: "742e6a6e17c0a060046874eece2949b221c228e1119698a4c6e0b096cbc87152" armv8: - url: "https://github.com/ccache/ccache/releases/download/v4.12/ccache-4.12-linux-aarch64.tar.xz" - sha256: "378ed4b9f645f5aab691447e4ec45b4c68508a424ac37c9be7baa28ded385791" + url: "https://github.com/ccache/ccache/releases/download/v4.12.1/ccache-4.12.1-linux-aarch64.tar.xz" + sha256: "05d349e8f14aebecce13102e803a441b7466b91c01b943bb744ad1db754434e0" Macos: universal: - url: "https://github.com/ccache/ccache/releases/download/v4.12/ccache-4.12-darwin.tar.gz" + url: "https://github.com/ccache/ccache/releases/download/v4.12.1/ccache-4.12.1-darwin.tar.gz" sha256: "95cb03de0f2e0edb264d2443f2fe4500a13086689cc9ecd1095eb274dd8d9aee" Windows: armv8: - url: "https://github.com/ccache/ccache/releases/download/v4.12/ccache-4.12-windows-aarch64.zip" - sha256: "12d8a95507ce19bb90cff49faa5f5de07919d5d8d91f129bcf597dbc30d0c250" + url: "https://github.com/ccache/ccache/releases/download/v4.12.1/ccache-4.12.1-windows-aarch64.zip" + sha256: "a846c1e75c90178b8a5e369eba8658e6bbca5b3a8de9225b8f43efa7ff5b2116" x86: - url: "https://github.com/ccache/ccache/releases/download/v4.12/ccache-4.12-windows-i686.zip" - sha256: "c046ad7159d312312662c380da5932d441407f56164e451b09c16dad8db01051" + url: "https://github.com/ccache/ccache/releases/download/v4.12.1/ccache-4.12.1-windows-i686.zip" + sha256: "2012b76631366dded52c3a983d8bda154dd76badb05bd6d8cde63e184cd5538a" x86_64: - url: "https://github.com/ccache/ccache/releases/download/v4.12/ccache-4.12-windows-x86_64.zip" - sha256: "85c963b154dcf5e38dc6839d660218433a3b0b86387c302675d236e17ae7220d" + url: "https://github.com/ccache/ccache/releases/download/v4.12.1/ccache-4.12.1-windows-x86_64.zip" + sha256: "98aea520d66905b8ba7a8e648a4cc0ca941d5e119d441f1e879a4a9045bf18f6" diff --git a/recipes/ccache/config.yml b/recipes/ccache/config.yml index 0d6ab71..4291a3a 100644 --- a/recipes/ccache/config.yml +++ b/recipes/ccache/config.yml @@ -1,3 +1,3 @@ versions: - "4.12": + "4.12.1": folder: binary