• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3
4# Note: Conan is supported on a best-effort basis. Abseil doesn't use Conan
5# internally, so we won't know if it stops working. We may ask community
6# members to help us debug any problems that arise.
7
8from conans import ConanFile, CMake, tools
9from conans.errors import ConanInvalidConfiguration
10from conans.model.version import Version
11
12
13class AbseilConan(ConanFile):
14    name = "abseil"
15    url = "https://github.com/abseil/abseil-cpp"
16    homepage = url
17    author = "Abseil <abseil-io@googlegroups.com>"
18    description = "Abseil Common Libraries (C++) from Google"
19    license = "Apache-2.0"
20    topics = ("conan", "abseil", "abseil-cpp", "google", "common-libraries")
21    exports = ["LICENSE"]
22    exports_sources = ["CMakeLists.txt", "CMake/*", "absl/*"]
23    generators = "cmake"
24    settings = "os", "arch", "compiler", "build_type"
25
26    def configure(self):
27        if self.settings.os == "Windows" and \
28           self.settings.compiler == "Visual Studio" and \
29           Version(self.settings.compiler.version.value) < "14":
30            raise ConanInvalidConfiguration("Abseil does not support MSVC < 14")
31
32    def build(self):
33        tools.replace_in_file("CMakeLists.txt", "project(absl CXX)", "project(absl CXX)\ninclude(conanbuildinfo.cmake)\nconan_basic_setup()")
34        cmake = CMake(self)
35        cmake.definitions["BUILD_TESTING"] = False
36        cmake.configure()
37        cmake.build()
38
39    def package(self):
40        self.copy("LICENSE", dst="licenses")
41        self.copy("*.h", dst="include", src=".")
42        self.copy("*.inc", dst="include", src=".")
43        self.copy("*.a", dst="lib", src=".", keep_path=False)
44        self.copy("*.lib", dst="lib", src=".", keep_path=False)
45
46    def package_info(self):
47        if self.settings.os == "Linux":
48            self.cpp_info.libs = ["-Wl,--start-group"]
49        self.cpp_info.libs.extend(tools.collect_libs(self))
50        if self.settings.os == "Linux":
51            self.cpp_info.libs.extend(["-Wl,--end-group", "pthread"])
52