conanfile.py 2.0 KB

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