Repository: conan-io/conan-center-index

Issue:
[request] wineditline/2.206
### Package Details
  * Package Name/Version: **wineditline/2.206**
  * Website: **http://mingweditline.sourceforge.net/**
  * Source code: **https://sourceforge.net/p/mingweditline/code/**

### Description Of The Library / Tool
An EditLine API implementation for the native Windows Console. This BSD-licensed library provides command line editing and history functions similar to those found in GNU Readline.

This library is a dependency of something else I want to use Conan with.


Discussion:

Resolving patch:
diff --git a/recipes/wineditline/all/conanfile.py b/recipes/wineditline/all/conanfile.py
new file mode 100644
--- /dev/null
+++ b/recipes/wineditline/all/conanfile.py
@@ -0,0 +1,76 @@
+import functools
+import os
+
+from conans import ConanFile, CMake, tools
+from conans.errors import ConanInvalidConfiguration
+
+required_conan_version = ">=1.43.0"
+
+
+class WineditlineConan(ConanFile):
+    name = "wineditline"
+    description = (
+        "A BSD-licensed EditLine API implementation for the native "
+        "Windows Console"
+    )
+    url = "https://github.com/conan-io/conan-center-index"
+    homepage = "http://mingweditline.sourceforge.net/"
+    topics = ("readline", "editline", "windows")
+    license = "BSD-3-Clause"
+    generators = ("cmake",)
+    settings = ("os", "arch", "compiler", "build_type")
+    options = {
+        "shared": [True, False],
+    }
+    default_options = {
+        "shared": False,
+    }
+
+    exports_sources = ("CMakeLists.txt",)
+
+    @property
+    def _source_subfolder(self):
+        return "source_subfolder"
+
+    def validate(self):
+        if self.settings.os != "Windows":
+            message = "wineditline is supported only on Windows."
+            raise ConanInvalidConfiguration(message)
+
+    def source(self):
+        root = self._source_subfolder
+        get_args = self.conan_data["sources"][self.version]
+        tools.get(**get_args, destination=root, strip_root=True)
+
+    def configure(self):
+        del self.settings.compiler.libcxx
+        del self.settings.compiler.cppstd
+
+    @functools.lru_cache(1)
+    def _configure_cmake(self):
+        cmake = CMake(self)
+        cmake.configure()
+        return cmake
+
+    def build(self):
+        cmake = self._configure_cmake()
+        cmake.build()
+
+    def package(self):
+        self.copy("COPYING", "licenses", self._source_subfolder)
+        cmake = self._configure_cmake()
+        cmake.install()
+
+    def package_info(self):
+        name = self.name
+        info = self.cpp_info
+
+        info.set_property("cmake_file_name", name)
+        info.set_property("cmake_target_name", f"{name}::{name}")
+
+        info.names.update({
+            "cmake_find_package": name,
+            "cmake_find_package_multi": name,
+        })
+
+        info.libs = ["edit"]


Test patch:
diff --git a/recipes/wineditline/all/test_package/CMakeLists.txt b/recipes/wineditline/all/test_package/CMakeLists.txt
new file mode 100644
--- /dev/null
+++ b/recipes/wineditline/all/test_package/CMakeLists.txt
@@ -0,0 +1,10 @@
+cmake_minimum_required(VERSION 3.1)
+project(test_package C)
+
+find_package(wineditline REQUIRED CONFIG)
+
+include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
+conan_basic_setup(TARGETS)
+
+add_executable(test_package test_package.c)
+target_link_libraries(test_package PRIVATE wineditline::wineditline)
diff --git a/recipes/wineditline/all/test_package/conanfile.py b/recipes/wineditline/all/test_package/conanfile.py
new file mode 100644
--- /dev/null
+++ b/recipes/wineditline/all/test_package/conanfile.py
@@ -0,0 +1,18 @@
+import os
+
+from conans import ConanFile, CMake, tools
+
+
+class TestPackageConan(ConanFile):
+    settings = ("os", "compiler", "build_type", "arch")
+    generators = ("cmake", "cmake_find_package_multi")
+
+    def build(self):
+        cmake = CMake(self)
+        cmake.configure()
+        cmake.build()
+
+    def test(self):
+        if not tools.cross_building(self):
+            bin_path = os.path.join("bin", "test_package")
+            self.run(bin_path, run_environment=True)
diff --git a/recipes/wineditline/all/test_package/test_package.c b/recipes/wineditline/all/test_package/test_package.c
new file mode 100644
--- /dev/null
+++ b/recipes/wineditline/all/test_package/test_package.c
@@ -0,0 +1,12 @@
+#include <editline/readline.h>
+#include <stddef.h>
+
+int main(int argc, char const* argv[])
+{
+  (void)argc;
+  (void)argv;
+
+  free_history_entry(NULL);
+
+  return 0;
+}