Repository: conan-io/conan-center-index

Issue:
[package] websocketpp/0.8.2: header-only library has unneccessary dependencies.
The websocketpp recipe pulls in boost (or standalone asio), openssl and libzip even thought it is a header-only library. I have no need for ssl, and I have boost from other places. Since this library is header only it should at least be possible to make the dependencies optional. 


Discussion:
Looking at the requirement, I think only asio or boost are essential.
Adding an option for the other two (=openssl and zlib) would indeed be a useful modification.

About using boost from "another place", the recipes at this repo only support getting its dependencies from other conan packages.
You can work around this by making e.g. a `boost/system` package.


For reference:
https://github.com/conan-io/conan-center-index/blob/c2c4c0c0949b0153b46a05a2597a1eb2900c515d/recipes/websocketpp/all/conanfile.py#L21-L27
Yeah, I get that conan packages assume that other dependencies come from conan too. As for the boost/system package you suggest I use, do you have a link or something to explain what you mean and how to do that?

In my project I do use boos.asiot from the linux package repos, but from reading the websocketpp documentation it does seem like you can use websocketpp without either boost.asio or standalone asio. So I think it could make sense to add a "none" as an option for asio.

Should I make a PR for this?
> Yeah, I get that conan packages assume that other dependencies come from conan too. As for the boost/system package you suggest I use, do you have a link or something to explain what you mean and how to do that?

I think you can adopt the way the cci recipes package system libraries, such as the egl, glu, opengl, vaapi and xorg recipes.
I can't provide you with conan documentation, but I have found some relevant links in the cci documentation: [here](https://github.com/conan-io/conan-center-index/blob/master/docs/faqs.md#can-i-install-packages-from-the-system-package-manager) and [here](https://github.com/conan-io/conan-center-index/blob/master/docs/how_to_add_packages.md#system-packages).

I think you can create a recipe doing the following (untested):
```python
from conans import ConanFile

class BoostSystemConan(ConanFile):
    name = "boost"
    version = "system"
    # options = # You might need to replicate all options of cci's boost recipe for compatibility with cci recipes
    def system_requirements(self):
        packages = []
        if tools.os_info.is_linux and self.settings.os == "Linux":
            if tools.os_info.with_yum or tools.os_info.with_dnf:
                packages = ["boost-devel"]
            elif tools.os_info.with_apt:
                packages = ["boost-dev"]
        if packages:
            package_tool = tools.SystemPackageTool(conanfile=self, default_mode="verify")
            package_tool.install_packages(update=True, packages=packages)
```


> In my project I do use boos.asiot from the linux package repos, but from reading the websocketpp documentation it does seem like you can use websocketpp without either boost.asio or standalone asio. So I think it could make sense to add a "none" as an option for asio.
> 
> Should I make a PR for this?

I glanced over websocketpp's cmake script.
Its test suite doesn't test without boost, so I am unsure about this.

Can we wait with removing the boost/asio dependency until you can prove this with an implementation of a websocketpp server/client?

Sure, I'll give it a whirl. Thanks for the help!
Reading the websocketpp documentation a bit more closely I found this:
"It uses interchangeable network transport modules including one based on raw char buffers, one based on C++ iostreams, and one based on Asio (either via Boost or standalone). End users can write additional transport policies to support other networking or event libraries as needed."

They also have an example of a iostream_server, that only uses iostreams and has no asio requirement at all. I have managed to write a partially functional iostream_client too. So I think it would make sense to have a "none" option for asio too.
That settles it :)
I'm expecting a PR adding this `None` option from you soon 😛 .

Resolving patch:
diff --git a/recipes/websocketpp/all/conanfile.py b/recipes/websocketpp/all/conanfile.py
--- a/recipes/websocketpp/all/conanfile.py
+++ b/recipes/websocketpp/all/conanfile.py
@@ -1,35 +1,48 @@
 import os
 from conans import ConanFile, tools
 
+required_conan_version = ">=1.33.0"
+
 
 class WebsocketPPConan(ConanFile):
     name = "websocketpp"
     description = "Header only C++ library that implements RFC6455 The WebSocket Protocol"
-    topics = ("conan", "websocketpp", "websocket", "network", "web", "rfc6455", "header-only")
+    topics = ("websocketpp", "websocket", "network", "web", "rfc6455", "header-only")
     url = "https://github.com/conan-io/conan-center-index"
     homepage = "https://github.com/zaphoyd/websocketpp"
     license = "BSD-3-Clause"
     settings = "os", "arch", "compiler", "build_type"
     exports_sources = ["patches/*"]
-    options = {"asio": ["boost", "standalone"]}
-    default_options = {"asio": "boost"}
-    
+    options = {
+        "asio": ["boost", "standalone", False],
+        "with_openssl": [True, False],
+        "with_zlib": [True, False],
+    }
+    default_options = {
+        "asio": "boost",
+        "with_openssl": True,
+        "with_zlib": True,
+    }
+
     @property
     def _source_subfolder(self):
         return "source_subfolder"
 
     def requirements(self):
-        self.requires("openssl/1.1.1k")
-        self.requires("zlib/1.2.11")
+        if self.options.with_openssl:
+            self.requires("openssl/1.1.1l")
+
+        if self.options.with_zlib:
+            self.requires("zlib/1.2.11")
+
         if self.options.asio == "standalone":
-            self.requires("asio/1.19.2")
-        else:
-            self.requires("boost/1.76.0")
+            self.requires("asio/1.21.0")
+        elif self.options.asio == "boost":
+            self.requires("boost/1.77.0")
 
     def source(self):
-        tools.get(**self.conan_data["sources"][self.version])
-        extracted_dir = self.name + "-" + self.version
-        os.rename(extracted_dir, self._source_subfolder)
+        tools.get(**self.conan_data["sources"][self.version],
+                  destination=self._source_subfolder, strip_root=True)
 
     def build(self):
         for patch in self.conan_data.get("patches", {}).get(self.version, []):


Test patch: