Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

civetweb: Add missing CMake options #9303

Merged
merged 5 commits into from
Feb 14, 2022
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 60 additions & 19 deletions recipes/civetweb/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,38 @@ class CivetwebConan(ConanFile):
generators = "cmake", "cmake_find_package", "cmake_find_package_multi"
settings = "os", "compiler", "build_type", "arch"
options = {
"shared" : [True, False],
"fPIC" : [True, False],
"with_ssl" : [True, False],
"fPIC": [True, False],
"shared": [True, False],
"ssl_dynamic_loading": [True, False],
"with_websockets" : [True, False],
"with_ipv6" : [True, False],
"with_cxx" : [True, False]
"with_caching": [True, False],
"with_cgi": [True, False],
"with_cxx": [True, False],
"with_duktape": [True, False],
"with_ipv6": [True, False],
"with_lua": [True, False],
"with_server_stats": [True, False],
"with_ssl": [True, False],
"with_static_files": [True, False],
"with_third_party_output": [True, False],
"with_websockets": [True, False],
"with_zlib": [True, False],
}
default_options = {
"shared" : False,
"fPIC" : True,
"with_ssl" : True,
"fPIC": True,
"shared": False,
"ssl_dynamic_loading": False,
"with_websockets" : True,
"with_ipv6" : True,
"with_cxx" : True
"with_caching": True,
"with_cgi": True,
"with_cxx": True,
"with_duktape": False,
"with_ipv6": True,
"with_lua": False,
"with_server_stats": False,
"with_ssl": True,
"with_static_files": True,
"with_third_party_output": False,
"with_websockets": True,
"with_zlib": False,
}

_cmake = None
Expand All @@ -43,6 +59,10 @@ def _source_subfolder(self):
def _build_subfolder(self):
return "build_subfolder"

@property
def _has_zlib_option(self):
return tools.Version(self.version) >= "1.15"

def export_sources(self):
self.copy("CMakeLists.txt")
for patch in self.conan_data.get("patches", {}).get(self.version, []):
Expand All @@ -51,6 +71,8 @@ def export_sources(self):
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
if not self._has_zlib_option:
del self.options.with_zlib

def configure(self):
if self.options.shared:
Expand All @@ -64,6 +86,8 @@ def configure(self):
def requirements(self):
if self.options.with_ssl:
self.requires("openssl/1.1.1m")
if self.options.get_safe("with_zlib"):
self.requires("zlib/1.2.11")

def validate(self):
if self.options.get_safe("ssl_dynamic_loading") and not self.options["openssl"].shared:
Expand All @@ -77,18 +101,32 @@ def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
self._cmake.definitions["CIVETWEB_ENABLE_SSL"] = self.options.with_ssl

if self.options.with_ssl:
openssl_version = tools.Version(self.deps_cpp_info["openssl"].version[:-1])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would break with openssl greater then 3.x 🤔 maybe a validate check?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was already there before my PR, so I didn't touch it. I am not against taking the opportunity to do that as well. What would you recommend?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the first PR since... let's not block this good work, maybe follow up with another PR 🙏

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prince-chrismc Sure, will do!

self._cmake.definitions["CIVETWEB_ENABLE_SSL"] = self.options.with_ssl
self._cmake.definitions["CIVETWEB_ENABLE_SSL_DYNAMIC_LOADING"] = self.options.ssl_dynamic_loading
self._cmake.definitions["CIVETWEB_SSL_OPENSSL_API_1_0"] = openssl_version.minor == "0"
self._cmake.definitions["CIVETWEB_SSL_OPENSSL_API_1_1"] = openssl_version.minor == "1"
self._cmake.definitions["CIVETWEB_ENABLE_SSL_DYNAMIC_LOADING"] = self.options.ssl_dynamic_loading
self._cmake.definitions["CIVETWEB_ENABLE_WEBSOCKETS"] = self.options.with_websockets
self._cmake.definitions["CIVETWEB_ENABLE_IPV6"] = self.options.with_ipv6
self._cmake.definitions["CIVETWEB_ENABLE_CXX"] = self.options.with_cxx

self._cmake.definitions["CIVETWEB_BUILD_TESTING"] = False
self._cmake.definitions["CIVETWEB_ENABLE_ASAN"] = False
self._cmake.definitions["CIVETWEB_CXX_ENABLE_LTO"] = False
self._cmake.definitions["CIVETWEB_ENABLE_ASAN"] = False

self._cmake.definitions["CIVETWEB_DISABLE_CACHING"] = not self.options.with_caching
self._cmake.definitions["CIVETWEB_DISABLE_CGI"] = not self.options.with_cgi
self._cmake.definitions["CIVETWEB_ENABLE_CXX"] = self.options.with_cxx
self._cmake.definitions["CIVETWEB_ENABLE_DUKTAPE"] = self.options.with_duktape
self._cmake.definitions["CIVETWEB_ENABLE_IPV6"] = self.options.with_ipv6
self._cmake.definitions["CIVETWEB_ENABLE_LUA"] = self.options.with_lua
self._cmake.definitions["CIVETWEB_ENABLE_SERVER_STATS"] = self.options.with_server_stats
self._cmake.definitions["CIVETWEB_ENABLE_THIRD_PARTY_OUTPUT"] = self.options.with_third_party_output
self._cmake.definitions["CIVETWEB_ENABLE_WEBSOCKETS"] = self.options.with_websockets
self._cmake.definitions["CIVETWEB_SERVE_NO_FILES"] = not self.options.with_static_files

if self.options.get_safe("with_zlib"):
self._cmake.definitions["CIVETWEB_ENABLE_ZLIB"] = True
jlouazel marked this conversation as resolved.
Show resolved Hide resolved

self._cmake.configure(build_dir=self._build_subfolder)
return self._cmake

Expand Down Expand Up @@ -126,8 +164,11 @@ def package_info(self):
self.cpp_info.components["_civetweb"].system_libs.append("ws2_32")
if self.options.shared:
self.cpp_info.components["_civetweb"].defines.append("CIVETWEB_DLL_IMPORTS")

if self.options.with_ssl:
self.cpp_info.components["_civetweb"].requires = ["openssl::openssl"]
self.cpp_info.components["_civetweb"].requires.append("openssl::openssl")
if self.options.get_safe("with_zlib"):
self.cpp_info.components["_civetweb"].requires.append("zlib::zlib")

if self.options.with_cxx:
self.cpp_info.components["civetweb-cpp"].names["cmake_find_package"] = "civetweb-cpp"
Expand Down