blob: 4bbc62eedd624a637cbb81f3cd00e65a6d06e92e [file] [log] [blame]
Uilian Ries32930d72018-12-03 17:52:53 -02001#!/usr/bin/env python
2# -*- coding: utf-8 -*-
ahedberge41b5b12018-12-20 13:51:25 -05003
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
Uilian Ries32930d72018-12-03 17:52:53 -02008from 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
Uilian Ries325cf0d2018-12-20 09:41:53 -020017 author = "Abseil <abseil-io@googlegroups.com>"
Uilian Ries32930d72018-12-03 17:52:53 -020018 description = "Abseil Common Libraries (C++) from Google"
19 license = "Apache-2.0"
Uilian Ries1aa550f2018-12-13 08:33:39 -020020 topics = ("conan", "abseil", "abseil-cpp", "google", "common-libraries")
Uilian Ries32930d72018-12-03 17:52:53 -020021 exports = ["LICENSE"]
22 exports_sources = ["CMakeLists.txt", "CMake/*", "absl/*"]
23 generators = "cmake"
24 settings = "os", "arch", "compiler", "build_type"
Uilian Ries32930d72018-12-03 17:52:53 -020025
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):
jwest5910f2cea52022-08-17 17:59:44 +010033 tools.replace_in_file("CMakeLists.txt", "project(absl LANGUAGES CXX)", "project(absl LANGUAGES CXX)\ninclude(conanbuildinfo.cmake)\nconan_basic_setup()")
Uilian Ries32930d72018-12-03 17:52:53 -020034 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")
Uilian Ries7ec32702019-01-22 19:53:42 -020041 self.copy("*.h", dst="include", src=".")
42 self.copy("*.inc", dst="include", src=".")
Uilian Ries32930d72018-12-03 17:52:53 -020043 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):
Uilian Ries32930d72018-12-03 17:52:53 -020047 if self.settings.os == "Linux":
Uilian Ries7ec32702019-01-22 19:53:42 -020048 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"])