Uilian Ries | 32930d7 | 2018-12-03 17:52:53 -0200 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # -*- coding: utf-8 -*- |
ahedberg | e41b5b1 | 2018-12-20 13:51:25 -0500 | [diff] [blame] | 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 | |
Uilian Ries | 32930d7 | 2018-12-03 17:52:53 -0200 | [diff] [blame] | 8 | from conans import ConanFile, CMake, tools |
| 9 | from conans.errors import ConanInvalidConfiguration |
| 10 | from conans.model.version import Version |
| 11 | |
| 12 | |
| 13 | class AbseilConan(ConanFile): |
| 14 | name = "abseil" |
| 15 | url = "https://github.com/abseil/abseil-cpp" |
| 16 | homepage = url |
Uilian Ries | 325cf0d | 2018-12-20 09:41:53 -0200 | [diff] [blame] | 17 | author = "Abseil <abseil-io@googlegroups.com>" |
Uilian Ries | 32930d7 | 2018-12-03 17:52:53 -0200 | [diff] [blame] | 18 | description = "Abseil Common Libraries (C++) from Google" |
| 19 | license = "Apache-2.0" |
Uilian Ries | 1aa550f | 2018-12-13 08:33:39 -0200 | [diff] [blame] | 20 | topics = ("conan", "abseil", "abseil-cpp", "google", "common-libraries") |
Uilian Ries | 32930d7 | 2018-12-03 17:52:53 -0200 | [diff] [blame] | 21 | exports = ["LICENSE"] |
| 22 | exports_sources = ["CMakeLists.txt", "CMake/*", "absl/*"] |
| 23 | generators = "cmake" |
| 24 | settings = "os", "arch", "compiler", "build_type" |
Uilian Ries | 32930d7 | 2018-12-03 17:52:53 -0200 | [diff] [blame] | 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): |
jwest591 | 0f2cea5 | 2022-08-17 17:59:44 +0100 | [diff] [blame] | 33 | tools.replace_in_file("CMakeLists.txt", "project(absl LANGUAGES CXX)", "project(absl LANGUAGES CXX)\ninclude(conanbuildinfo.cmake)\nconan_basic_setup()") |
Uilian Ries | 32930d7 | 2018-12-03 17:52:53 -0200 | [diff] [blame] | 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") |
Uilian Ries | 7ec3270 | 2019-01-22 19:53:42 -0200 | [diff] [blame] | 41 | self.copy("*.h", dst="include", src=".") |
| 42 | self.copy("*.inc", dst="include", src=".") |
Uilian Ries | 32930d7 | 2018-12-03 17:52:53 -0200 | [diff] [blame] | 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): |
Uilian Ries | 32930d7 | 2018-12-03 17:52:53 -0200 | [diff] [blame] | 47 | if self.settings.os == "Linux": |
Uilian Ries | 7ec3270 | 2019-01-22 19:53:42 -0200 | [diff] [blame] | 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"]) |