conanfile.py 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*
  3. from conans import ConanFile, tools, CMake
  4. class civetwebConan(ConanFile):
  5. name = "civetweb"
  6. license = "MIT"
  7. url = "https://github.com/civetweb/civetweb"
  8. description = "Embedded C/C++ web server"
  9. author = "Bernhard Lehner <bel2125@gmail.com>"
  10. topics = ("conan", "civetweb", "web-server", "embedded")
  11. exports = ("LICENSE.md", "README.md")
  12. exports_sources = ("src/*", "cmake/*", "include/*", "CMakeLists.txt")
  13. generators = "cmake"
  14. settings = "os", "compiler", "build_type", "arch"
  15. options = {
  16. "shared" : [True, False],
  17. "fPIC" : [True, False],
  18. "enable_ssl" : [True, False],
  19. "enable_websockets" : [True, False],
  20. "enable_cxx" : [True, False]
  21. }
  22. default_options = {
  23. "shared" : False,
  24. "fPIC" : True,
  25. "enable_ssl" : True,
  26. "enable_websockets" : True,
  27. "enable_cxx" : True
  28. }
  29. requires = "OpenSSL/1.0.2q@conan/stable"
  30. def config_options(self):
  31. if self.settings.os == 'Windows':
  32. del self.options.fPIC
  33. def configure(self):
  34. if not self.options.enable_cxx:
  35. del self.settings.compiler.libcxx
  36. def _configure_cmake(self):
  37. cmake = CMake(self)
  38. cmake.definitions["CIVETWEB_ENABLE_SSL"] = self.options.enable_ssl
  39. cmake.definitions["CIVETWEB_ENABLE_WEBSOCKETS"] = self.options.enable_websockets
  40. cmake.definitions["CIVETWEB_ENABLE_CXX"] = self.options.enable_cxx
  41. cmake.definitions["CIVETWEB_BUILD_TESTING"] = False
  42. cmake.definitions["CIVETWEB_ENABLE_ASAN"] = False
  43. cmake.configure(build_dir="build_subfolder")
  44. return cmake
  45. def build(self):
  46. tools.replace_in_file(file_path="CMakeLists.txt",
  47. search="project (civetweb)",
  48. replace="""project (civetweb)
  49. include(conanbuildinfo.cmake)
  50. conan_basic_setup()""")
  51. cmake = self._configure_cmake()
  52. cmake.build()
  53. def package(self):
  54. self.copy("LICENSE.md", dst="licenses")
  55. cmake = self._configure_cmake()
  56. cmake.install()
  57. def package_info(self):
  58. self.cpp_info.libs = tools.collect_libs(self)
  59. if self.settings.os == "Linux":
  60. self.cpp_info.libs.append("pthread")
  61. if self.options.enable_cxx:
  62. self.cpp_info.libs.append("m")
  63. elif self.settings.os == "Windows":
  64. self.cpp_info.libs.append("Ws2_32")