Repository: conan-io/conan-center-index

Issue:
[request]  effcee/2019.1
### Package Details
  * Package Name/Version: **effcee/2019.1**
  * Website: **https://github.com/google/effcee/tree/main**
  * Source code: **https://github.com/google/effcee**


### Description Of The Library / Tool
Effcee is a C++ library for stateful pattern matching of strings, inspired by LLVM's FileCheck command.


Discussion:

Resolving patch:
diff --git a/recipes/effcee/all/conanfile.py b/recipes/effcee/all/conanfile.py
new file mode 100644
--- /dev/null
+++ b/recipes/effcee/all/conanfile.py
@@ -0,0 +1,77 @@
+import os
+from conans import ConanFile, CMake, tools
+from conans.errors import ConanInvalidConfiguration
+
+class EffceeConan(ConanFile):
+    name = "effcee"
+    url = "https://github.com/conan-io/conan-center-index"
+    homepage = "https://github.com/google/effcee/"
+    description = "Zstandard - Fast real-time compression algorithm"
+    topics = ("conan", "effcee", "strings", "algorithm", "matcher")
+    license = "Apache-2.0"
+    exports_sources = ["CMakeLists.txt", "patches/**"]
+    generators = "cmake", "cmake_find_package_multi"
+    settings = "os", "arch", "compiler", "build_type"
+    options = {"shared": [True, False], "fPIC": [True, False]}
+    default_options = {"shared": False, "fPIC": True}
+
+    _cmake = None
+
+    @property
+    def _source_subfolder(self):
+        return "source_subfolder"
+
+    @property
+    def _build_subfolder(self):
+        return "build_subfolder"
+
+    def config_options(self):
+        if self.settings.os == "Windows":
+            del self.options.fPIC
+
+    def configure(self):
+        if self.options.shared:
+            del self.options.fPIC
+
+    def validate(self):
+        if self.settings.compiler.get_safe("cppstd"):
+            tools.check_min_cppstd(self, "11")
+        if self.settings.compiler == "Visual Studio" and "MT" in self.settings.compiler.runtime:
+            raise ConanInvalidConfiguration("Visual Studio build for shared library with MT runtime is not supported")
+
+    def source(self):
+        tools.get(**self.conan_data["sources"][self.version],
+                  destination=self._source_subfolder, strip_root=True)
+
+    def _configure_cmake(self):
+        if self._cmake:
+            return self._cmake
+        self._cmake = CMake(self)
+        self._cmake.definitions["EFFCEE_BUILD_TESTING"] = False
+        self._cmake.definitions["EFFCEE_BUILD_SAMPLES"] = False
+        self._cmake.definitions["RE2_BUILD_TESTING"] = False
+        if self.settings.compiler == "Visual Studio":
+            self._cmake.definitions["EFFCEE_ENABLE_SHARED_CRT"] = (self.settings.compiler.runtime in ["MD", "MDd"])
+
+        self._cmake.configure(build_folder=self._build_subfolder)
+        return self._cmake
+
+    def _patch_sources(self):
+        for patch in self.conan_data.get("patches", {}).get(self.version, []):
+            tools.patch(**patch)
+
+    def requirements(self):
+        self.requires('re2/20210601')
+
+    def build(self):
+        self._patch_sources()
+        cmake = self._configure_cmake()
+        cmake.build()
+
+    def package(self):
+        self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder)
+        cmake = self._configure_cmake()
+        cmake.install()
+
+    def package_info(self):
+        self.cpp_info.libs = tools.collect_libs(self)


Test patch:
diff --git a/recipes/effcee/all/test_package/CMakeLists.txt b/recipes/effcee/all/test_package/CMakeLists.txt
new file mode 100644
--- /dev/null
+++ b/recipes/effcee/all/test_package/CMakeLists.txt
@@ -0,0 +1,13 @@
+cmake_minimum_required(VERSION 3.1)
+project(test_package)
+
+
+include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
+conan_basic_setup(TARGETS)
+
+find_package(effcee REQUIRED)
+
+add_executable(effcee-example main.cc)
+
+target_link_libraries(effcee-example effcee::effcee)
+set_property(TARGET effcee-example PROPERTY CXX_STANDARD 11)
diff --git a/recipes/effcee/all/test_package/conanfile.py b/recipes/effcee/all/test_package/conanfile.py
new file mode 100644
--- /dev/null
+++ b/recipes/effcee/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", "cmake_find_package"
+
+    def build(self):
+        cmake = CMake(self)
+        cmake.configure()
+        cmake.build()
+
+    def test(self):
+        if tools.cross_building(self.settings):
+            bin_path = os.path.join("bin", "effcee-example")
+            self.run(bin_path, run_environment=True)
diff --git a/recipes/effcee/all/test_package/main.cc b/recipes/effcee/all/test_package/main.cc
new file mode 100644
--- /dev/null
+++ b/recipes/effcee/all/test_package/main.cc
@@ -0,0 +1,7 @@
+#include "effcee/effcee.h"
+
+int main(void) {
+  auto match = effcee::Match("foo bar qux", "foo",
+                              effcee::Options().SetChecksName("checks"));
+  return 0;
+}