Repository: conan-io/conan-center-index

Issue:
[request] flecs/v2.3.1
### Package Details
  * Package Name/Version: **flecs/v2.3.1**
  * Website: **https://github.com/SanderMertens/flecs**
  * Source code: **https://github.com/SanderMertens/flecs**
  * Platform/Compiler:
     * Windows: msvc
     * Ubuntu: gcc (7, 8, 9, 10), clang (8, 9)
     * MacOS: gcc 10, clang 9
  * Conan recipe repository: https://github.com/rawbby/conan-flecs
    (As I am new to the Conan Community I dont know if the package is perfectly polished yet)

### Description Of The Library / Tool
Flecs is a fast and lightweight Entity Component System with a focus on high performance game development.



Discussion:
Since you already have a recipe, feel free to create a pull request 

Resolving patch:
diff --git a/recipes/flecs/all/conanfile.py b/recipes/flecs/all/conanfile.py
new file mode 100644
--- /dev/null
+++ b/recipes/flecs/all/conanfile.py
@@ -0,0 +1,70 @@
+from conans import ConanFile, CMake, tools
+import os
+
+
+class FlecsConan(ConanFile):
+    name = "flecs"
+    description = "A fast entity component system (ECS) for C & C++"
+    license = "MIT"
+    topics = ("gamedev", "cpp", "data-oriented-design", "c99",
+              "game-development", "ecs", "entity-component-system",
+              "cpp11", "ecs-framework")
+    homepage = "https://github.com/SanderMertens/flecs"
+    url = "https://github.com/conan-io/conan-center-index"
+
+    settings = "os", "arch", "compiler", "build_type"
+    options = {"shared": [True, False], "fPIC": [True, False]}
+    default_options = {"shared": False, "fPIC": True}
+
+    exports_sources = "CMakeLists.txt"
+    generators = "cmake"
+    _cmake = None
+
+    @property
+    def _source_subfolder(self):
+        return "source_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
+        del self.settings.compiler.libcxx
+        del self.settings.compiler.cppstd
+
+    def source(self):
+        tools.get(**self.conan_data["sources"][self.version])
+        os.rename(self.name + "-" + self.version, self._source_subfolder)
+
+    def _configure_cmake(self):
+        if self._cmake:
+            return self._cmake
+        self._cmake = CMake(self)
+        self._cmake.definitions["FLECS_STATIC_LIBS"] = not self.options.shared
+        self._cmake.definitions["FLECS_PIC"] = self.options.get_safe("fPIC", True)
+        self._cmake.definitions["FLECS_SHARED_LIBS"] = self.options.shared
+        self._cmake.definitions["FLECS_DEVELOPER_WARNINGS"] = False
+        self._cmake.configure()
+        return self._cmake
+
+    def build(self):
+        cmake = self._configure_cmake()
+        cmake.build()
+
+    def package(self):
+        self.copy("LICENSE", dst="licenses", src=self._source_subfolder)
+        cmake = self._configure_cmake()
+        cmake.install()
+        tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))
+
+    def package_info(self):
+        self.cpp_info.names["cmake_find_package"] = "flecs"
+        self.cpp_info.names["cmake_find_package_multi"] = "flecs"
+        target_and_lib_name = "flecs" if self.options.shared else "flecs_static"
+        self.cpp_info.components["_flecs"].names["cmake_find_package"] = target_and_lib_name
+        self.cpp_info.components["_flecs"].names["cmake_find_package_multi"] = target_and_lib_name
+        self.cpp_info.components["_flecs"].libs = [target_and_lib_name]
+        if not self.options.shared:
+            self.cpp_info.components["_flecs"].defines.append("flecs_STATIC")


Test patch:
diff --git a/recipes/flecs/all/test_package/CMakeLists.txt b/recipes/flecs/all/test_package/CMakeLists.txt
new file mode 100644
--- /dev/null
+++ b/recipes/flecs/all/test_package/CMakeLists.txt
@@ -0,0 +1,15 @@
+cmake_minimum_required(VERSION 3.1)
+project(test_package C)
+
+include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
+
+conan_basic_setup(TARGETS)
+
+find_package(flecs REQUIRED CONFIG)
+
+add_executable(${PROJECT_NAME} test_package.c)
+if(FLECS_SHARED)
+  target_link_libraries(${PROJECT_NAME} flecs::flecs)
+else()
+  target_link_libraries(${PROJECT_NAME} flecs::flecs_static)
+endif()
diff --git a/recipes/flecs/all/test_package/conanfile.py b/recipes/flecs/all/test_package/conanfile.py
new file mode 100644
--- /dev/null
+++ b/recipes/flecs/all/test_package/conanfile.py
@@ -0,0 +1,18 @@
+from conans import ConanFile, CMake, tools
+import os
+
+
+class TestPackageConan(ConanFile):
+    settings = "os", "arch", "compiler", "build_type"
+    generators = "cmake", "cmake_find_package_multi"
+
+    def build(self):
+        cmake = CMake(self)
+        cmake.definitions["FLECS_SHARED"] = self.options["flecs"].shared
+        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/flecs/all/test_package/test_package.c b/recipes/flecs/all/test_package/test_package.c
new file mode 100644
--- /dev/null
+++ b/recipes/flecs/all/test_package/test_package.c
@@ -0,0 +1,23 @@
+#include <flecs.h>
+
+#include <stdio.h>
+
+typedef struct {
+    float x;
+    float y;
+} Position;
+
+int main() {
+    ecs_world_t *world = ecs_init();
+
+    ECS_COMPONENT(world, Position);
+
+    ecs_entity_t e = ecs_set(world, 0, EcsName, {"MyEntity"});
+    ecs_set(world, e, Position, {10.0f, 20.0f});
+
+    const char *name = ecs_get_name(world, e);
+    const Position *p = ecs_get(world, e, Position);
+    printf("Position of %s is {%f, %f}\n", name, p->x, p->y);
+
+    return 0;
+}