Repository: conan-io/conan-center-index

Issue:
[request] websocketpp/0.8.1
### Package Details
  * Package Name/Version: **websocketpp/0.8.1**
  * Website: **http://www.zaphoyd.com/websocketpp**
  * Source code: **https://github.com/zaphoyd/websocketpp/tree/develop**

### Description Of The Library / Tool
C++ webscoket library on top of boost asio

Currently this is hosted by @bincrafters-user but I would like to migrate it to CCI.
https://github.com/bincrafters/conan-websocketpp

@Croydon would this be allowed? I would like to confirm before doing the work =)


Discussion:
Yes, please go ahead! 😄 
The patch needs to move into the `conandata.yml`, but other than that it should not need to much changed to be ready for CCI

Resolving patch:
diff --git a/recipes/websocketpp/all/conanfile.py b/recipes/websocketpp/all/conanfile.py
new file mode 100644
--- /dev/null
+++ b/recipes/websocketpp/all/conanfile.py
@@ -0,0 +1,51 @@
+import os
+from conans import ConanFile, tools, CMake
+
+
+class WebsocketPPConan(ConanFile):
+    name = "websocketpp"
+    description = "Header only C++ library that implements RFC6455 The WebSocket Protocol"
+    topics = ("conan", "websocketpp", "websocket", "network", "web", "rfc6455")
+    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 = ["CMakeLists.txt", 'patches/*']
+    generators = ["cmake"]
+    options = {'asio': ['boost', 'standalone']}
+    default_options = {'asio': 'boost'}
+
+    @property
+    def _source_subfolder(self):
+        return "source_subfolder"
+
+    def requirements(self):
+        self.requires.add('openssl/1.1.1e')
+        self.requires.add('zlib/1.2.11')
+        if self.options.asio == 'standalone':
+            self.requires.add('asio/1.14.0')
+        else:
+            self.requires.add('boost/1.72.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)
+        self._patch_sources()
+
+    def _patch_sources(self):
+        for patch in self.conan_data["patches"][self.version]:
+            tools.patch(**patch)
+
+    def package(self):
+        self._patch_sources()
+        self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder)
+        # We have to copy the headers manually, since the current cmake.install() step in the 0.8.1 release doesn't do so.
+        self.copy(pattern="*.hpp", dst="include/websocketpp", src=self._source_subfolder + '/websocketpp')
+
+    def package_info(self):    
+        if self.options.asio == 'standalone':
+            self.cpp_info.defines.extend(['ASIO_STANDALONE', '_WEBSOCKETPP_CPP11_STL_'])
+
+    def package_id(self):
+        self.info.header_only()


Test patch:
diff --git a/recipes/websocketpp/all/test_package/CMakeLists.txt b/recipes/websocketpp/all/test_package/CMakeLists.txt
new file mode 100644
--- /dev/null
+++ b/recipes/websocketpp/all/test_package/CMakeLists.txt
@@ -0,0 +1,11 @@
+cmake_minimum_required(VERSION 2.8.11)
+project(test_package)
+
+set(CMAKE_VERBOSE_MAKEFILE TRUE)
+
+include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
+conan_basic_setup()
+
+add_executable(${PROJECT_NAME} test_package.cpp)
+target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
+set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11)
diff --git a/recipes/websocketpp/all/test_package/conanfile.py b/recipes/websocketpp/all/test_package/conanfile.py
new file mode 100644
--- /dev/null
+++ b/recipes/websocketpp/all/test_package/conanfile.py
@@ -0,0 +1,17 @@
+import os
+from conans import ConanFile, CMake, tools
+
+
+class TestPackageConan(ConanFile):
+    settings = "os", "compiler", "build_type", "arch"
+    generators = "cmake"
+
+    def build(self):
+        cmake = CMake(self)
+        cmake.configure()
+        cmake.build()
+
+    def test(self):
+        if not tools.cross_building(self.settings):
+            bin_path = os.path.join("bin", "test_package")
+            self.run(bin_path, run_environment=True)
diff --git a/recipes/websocketpp/all/test_package/test_package.cpp b/recipes/websocketpp/all/test_package/test_package.cpp
new file mode 100644
--- /dev/null
+++ b/recipes/websocketpp/all/test_package/test_package.cpp
@@ -0,0 +1,7 @@
+#include <websocketpp/server.hpp>
+#include <websocketpp/config/asio_no_tls.hpp>
+
+int main()
+{
+	websocketpp::server<websocketpp::config::asio> server;
+}
\ No newline at end of file