conanfile.py 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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.configure(build_dir="build_subfolder")
  43. return cmake
  44. def build(self):
  45. tools.replace_in_file(file_path="CMakeLists.txt",
  46. search="project (civetweb)",
  47. replace="""project (civetweb)
  48. include(conanbuildinfo.cmake)
  49. conan_basic_setup()""")
  50. cmake = self._configure_cmake()
  51. cmake.build()
  52. def package(self):
  53. self.copy("LICENSE.md", dst="licenses")
  54. cmake = self._configure_cmake()
  55. cmake.install()
  56. def package_info(self):
  57. self.cpp_info.libs = tools.collect_libs(self)
  58. if self.settings.os == "Linux":
  59. self.cpp_info.libs.append("pthread")
  60. if self.options.enable_cxx:
  61. self.cpp_info.libs.append("m")
  62. elif self.settings.os == "Windows":
  63. self.cpp_info.libs.append("Ws2_32")