Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ccache/4.5.1 #8604

Merged
merged 1 commit into from
Jan 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions recipes/ccache/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.1)
project(cmake_wrapper)

include(conanbuildinfo.cmake)
conan_basic_setup()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
conan_basic_setup()
conan_basic_setup(TARGETS)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't really matter in cmake wrapper of the recipe, why do you want TARGETS?


add_subdirectory(source_subfolder)
8 changes: 8 additions & 0 deletions recipes/ccache/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
sources:
"4.5.1":
url: "https://github.com/ccache/ccache/releases/download/v4.5.1/ccache-4.5.1.tar.xz"
sha256: "51186ebe0326365f4e6131e1caa8911de7da4aa6718efc00680322d63a759517"
patches:
"4.5.1":
- patch_file: "patches/0001-fix-cmake.patch"
base_path: "source_subfolder"
105 changes: 105 additions & 0 deletions recipes/ccache/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
from conans import ConanFile, CMake, tools
from conans.errors import ConanInvalidConfiguration
import os

required_conan_version = ">=1.33.0"


class CcacheConan(ConanFile):
name = "ccache"
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 = ("ccache", "compiler-cache", "recompilation")
homepage = "https://ccache.dev"
url = "https://github.com/conan-io/conan-center-index"

settings = "os", "arch", "compiler", "build_type"
options = {
"redis_storage_backend": [True, False],
}
default_options = {
"redis_storage_backend": True,
}

generators = "cmake", "cmake_find_package_multi"
_cmake = None

@property
def _source_subfolder(self):
return "source_subfolder"

@property
def _min_cppstd(self):
return "17" if self.settings.compiler == "Visual Studio" else "14"

@property
def _compilers_minimum_version(self):
return {
"gcc": "6",
"clang": "6",
"apple-clang": "10",
"Visual Studio": "15.7",
}

def export_sources(self):
self.copy("CMakeLists.txt")
for patch in self.conan_data.get("patches", {}).get(self.version, []):
self.copy(patch["patch_file"])

def requirements(self):
self.requires("zstd/1.5.1")
if self.options.redis_storage_backend:
self.requires("hiredis/1.0.2")

def validate(self):
if self.settings.compiler.get_safe("cppstd"):
tools.check_min_cppstd(self, self._min_cppstd)

def lazy_lt_semver(v1, v2):
lv1 = [int(v) for v in v1.split(".")]
lv2 = [int(v) for v in v2.split(".")]
min_length = min(len(lv1), len(lv2))
return lv1[:min_length] < lv2[:min_length]

minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False)
if minimum_version and lazy_lt_semver(str(self.settings.compiler.version), minimum_version):
raise ConanInvalidConfiguration(
"{} requires C++{}, which your compiler does not support.".format(self.name, self._min_cppstd)
)

def package_id(self):
del self.info.settings.compiler

def source(self):
tools.get(**self.conan_data["sources"][self.version],
destination=self._source_subfolder, strip_root=True)

def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
self._cmake.definitions["REDIS_STORAGE_BACKEND"] = self.options.redis_storage_backend
self._cmake.definitions["ENABLE_DOCUMENTATION"] = False
self._cmake.definitions["ENABLE_TESTING"] = False
self._cmake.configure()
return self._cmake

def build(self):
for patch in self.conan_data.get("patches", {}).get(self.version, []):
tools.patch(**patch)
cmake = self._configure_cmake()
cmake.build()

def package(self):
self.copy("GPL-*.txt", dst="licenses", src=self._source_subfolder)
cmake = self._configure_cmake()
cmake.install()

def package_info(self):
bin_path = os.path.join(self.package_folder, "bin")
self.output.info("Appending PATH environment variable: {}".format(bin_path))
self.env_info.PATH.append(bin_path)
63 changes: 63 additions & 0 deletions recipes/ccache/all/patches/0001-fix-cmake.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -97,12 +97,12 @@ if(MSVC AND NOT CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg|conan")
endif()

option(ZSTD_FROM_INTERNET "Download and use libzstd from the Internet" ${ZSTD_FROM_INTERNET_DEFAULT})
-find_package(zstd 1.1.2 REQUIRED)
+find_package(zstd REQUIRED CONFIG)

option(REDIS_STORAGE_BACKEND "Enable Redis secondary storage" ON)
if(REDIS_STORAGE_BACKEND)
option(HIREDIS_FROM_INTERNET "Download and use libhiredis from the Internet" ${HIREDIS_FROM_INTERNET_DEFAULT})
- find_package(hiredis 0.13.3 REQUIRED)
+ find_package(hiredis REQUIRED CONFIG)
endif()

#
--- a/cmake/GenerateConfigurationFile.cmake
+++ b/cmake/GenerateConfigurationFile.cmake
@@ -104,5 +104,5 @@ if(HAVE_SYS_MMAN_H AND HAVE_PTHREAD_MUTEXATTR_SETPSHARED)
set(INODE_CACHE_SUPPORTED 1)
endif()

-configure_file(${CMAKE_SOURCE_DIR}/cmake/config.h.in
+configure_file(${PROJECT_SOURCE_DIR}/cmake/config.h.in
${CMAKE_BINARY_DIR}/config.h @ONLY)
--- a/cmake/GenerateVersionFile.cmake
+++ b/cmake/GenerateVersionFile.cmake
@@ -1,4 +1,4 @@
configure_file(
- ${CMAKE_SOURCE_DIR}/cmake/version.cpp.in
+ ${PROJECT_SOURCE_DIR}/cmake/version.cpp.in
${CMAKE_BINARY_DIR}/src/version.cpp
@ONLY)
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -27,7 +27,7 @@ set(
execute.cpp
hashutil.cpp
language.cpp
- version.cpp
+ ${CMAKE_BINARY_DIR}/src/version.cpp
)

if(INODE_CACHE_SUPPORTED)
@@ -65,7 +65,7 @@ set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
target_link_libraries(
ccache_framework
- PRIVATE standard_settings standard_warnings ZSTD::ZSTD Threads::Threads third_party
+ PRIVATE standard_settings standard_warnings $<IF:$<TARGET_EXISTS:zstd::libzstd_shared>,zstd::libzstd_shared,zstd::libzstd_static> Threads::Threads third_party
)

target_include_directories(ccache_framework PRIVATE ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
@@ -74,7 +74,7 @@ if(REDIS_STORAGE_BACKEND)
target_compile_definitions(ccache_framework PRIVATE -DHAVE_REDIS_STORAGE_BACKEND)
target_link_libraries(
ccache_framework
- PUBLIC standard_settings standard_warnings HIREDIS::HIREDIS third_party
+ PUBLIC standard_settings standard_warnings hiredis::hiredis third_party
)
endif()

9 changes: 9 additions & 0 deletions recipes/ccache/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from conans import ConanFile, tools


class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"

def test(self):
if not tools.cross_building(self):
self.run("ccache --version", run_environment=True)
3 changes: 3 additions & 0 deletions recipes/ccache/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"4.5.1":
folder: all