We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[request] mimalloc/1.7.5
### Package Details
  * Package Name/Version: **mimalloc/1.7.5**
  * Changelog: **https://github.com/microsoft/mimalloc/releases/tag/v1.7.5**


The above mentioned version is newly released by the upstream project and not yet available as a recipe. Please add this version.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `recipes/mimalloc/all/conanfile.py`
Content:
```
1 from conans import ConanFile, CMake, tools
2 from conans.errors import ConanInvalidConfiguration
3 import os
4 import shutil
5 import textwrap
6 
7 required_conan_version = ">=1.43.0"
8 
9 
10 class MimallocConan(ConanFile):
11     name = "mimalloc"
12     license = "MIT"
13     url = "https://github.com/conan-io/conan-center-index"
14     homepage = "https://github.com/microsoft/mimalloc"
15     description = "mimalloc is a compact general purpose allocator with excellent performance."
16     topics = ("mimalloc", "allocator", "performance", "microsoft")
17 
18     settings = "os", "arch", "compiler", "build_type"
19     options = {
20         "shared": [True, False],
21         "fPIC": [True, False],
22         "secure": [True, False],
23         "override": [True, False],
24         "inject": [True, False],
25         "single_object": [True, False],
26     }
27     default_options = {
28         "shared": False,
29         "fPIC": True,
30         "secure": False,
31         "override": False,
32         "inject": False,
33         "single_object": False,
34     }
35 
36     generators = "cmake"
37     _cmake = None
38 
39     @property
40     def _source_subfolder(self):
41         return "source_subfolder"
42 
43     @property
44     def _build_subfolder(self):
45         return "build_subfolder"
46 
47     @property
48     def _compilers_minimum_version(self):
49         return {
50             "gcc": "7",
51             "Visual Studio": "15",
52             "clang": "5",
53             "apple-clang": "10",
54         }
55 
56     def export_sources(self):
57         self.copy("CMakeLists.txt")
58         for patch in self.conan_data.get("patches", {}).get(self.version, []):
59             self.copy(patch["patch_file"])
60 
61     def config_options(self):
62         if self.settings.os == "Windows":
63             del self.options.fPIC
64 
65         # single_object and inject are options
66         # only when overriding on Unix-like platforms:
67         if self.settings.compiler == "Visual Studio":
68             del self.options.single_object
69             del self.options.inject
70 
71     def configure(self):
72         if self.options.shared:
73             del self.options.fPIC
74 
75             # single_object is valid only for static
76             # override:
77             if self.options.get_safe("single_object"):
78                 del self.options.single_object
79 
80         # inject is valid only for Unix-like dynamic override:
81         if not self.options.shared and self.options.get_safe("inject"):
82             del self.options.inject
83 
84         # single_object and inject are valid only when
85         # overriding on Unix-like platforms:
86         if not self.options.override:
87             if self.options.get_safe("single_object"):
88                 del self.options.single_object
89             if self.options.get_safe("inject"):
90                 del self.options.inject
91 
92     def validate(self):
93         # Shared overriding requires dynamic runtime for MSVC:
94         if self.options.override and \
95            self.options.shared and \
96            self.settings.compiler == "Visual Studio" and \
97            "MT" in str(self.settings.compiler.runtime):
98             raise ConanInvalidConfiguration(
99                 "Dynamic runtime (MD/MDd) is required when using mimalloc as a shared library for override")
100 
101         if self.options.override and \
102            self.options.get_safe("single_object") and \
103            self.options.get_safe("inject"):
104             raise ConanInvalidConfiguration("Single object is incompatible with library injection");
105 
106         if self.settings.compiler.get_safe("cppstd"):
107             tools.check_min_cppstd(self, "17")
108 
109         minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False)
110 
111         if not minimum_version:
112             self.output.warn("mimalloc requires C++17. Your compiler is unknown. Assuming it supports C++17.")
113         elif tools.Version(self.settings.compiler.version) < minimum_version:
114             raise ConanInvalidConfiguration("mimalloc requires a compiler that supports at least C++17")
115 
116     def source(self):
117         tools.get(**self.conan_data["sources"][self.version],
118             destination=self._source_subfolder, strip_root=True)
119 
120     def _configure_cmake(self):
121         if self._cmake:
122             return self._cmake
123         self._cmake = CMake(self)
124         if self._cmake.is_multi_configuration:
125             self._cmake.definitions["CMAKE_BUILD_TYPE"] = self.settings.build_type
126         self._cmake.definitions["MI_BUILD_TESTS"] = "OFF"
127         self._cmake.definitions["MI_BUILD_SHARED"] = self.options.shared
128         self._cmake.definitions["MI_BUILD_STATIC"] = not self.options.shared
129         self._cmake.definitions["MI_BUILD_OBJECT"] = self.options.get_safe("single_object", False)
130         self._cmake.definitions["MI_OVERRIDE"] = "ON" if self.options.override else "OFF"
131         self._cmake.definitions["MI_SECURE"] = "ON" if self.options.secure else "OFF"
132         if tools.Version(self.version) >= "1.7.0":
133             self._cmake.definitions["MI_INSTALL_TOPLEVEL"] = "ON"
134         self._cmake.configure(build_folder=self._build_subfolder)
135         return self._cmake
136 
137     def build(self):
138         for patch in self.conan_data.get("patches", {}).get(self.version, []):
139             tools.patch(**patch)
140         if self.settings.compiler == "Visual Studio" and self.settings.arch == "x86":
141             tools.replace_path_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"),
142                                        "mimalloc-redirect.lib", "mimalloc-redirect32.lib")
143         with tools.vcvars(self.settings) if self.settings.compiler == "Visual Studio" else tools.no_op():
144             cmake = self._configure_cmake()
145             cmake.build()
146 
147     def package(self):
148         self.copy("LICENSE", dst="licenses", src=self._source_subfolder)
149         with tools.vcvars(self.settings) if self.settings.compiler == "Visual Studio" else tools.no_op():
150             cmake = self._configure_cmake()
151             cmake.install()
152 
153         tools.rmdir(os.path.join(self.package_folder, "cmake"))
154         tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))
155 
156         if self.options.get_safe("single_object"):
157             tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"),
158                                        "*.a")
159             shutil.move(os.path.join(self.package_folder, self._obj_name + ".o"),
160                         os.path.join(self.package_folder, "lib"))
161             shutil.copy(os.path.join(self.package_folder, "lib", self._obj_name + ".o"),
162                         os.path.join(self.package_folder, "lib", self._obj_name))
163 
164         if self.settings.os == "Windows" and self.options.shared:
165             if self.settings.arch == "x86_64":
166                 self.copy("mimalloc-redirect.dll", src=os.path.join(self._source_subfolder, "bin"),
167                           dst="bin")
168             elif self.settings.arch == "x86":
169                 self.copy("mimalloc-redirect32.dll", src=os.path.join(self._source_subfolder, "bin"),
170                           dst="bin")
171 
172         tools.rmdir(os.path.join(self.package_folder, "share"))
173 
174         cmake_target = "mimalloc" if self.options.shared else "mimalloc-static"
175         self._create_cmake_module_alias_targets(
176             os.path.join(self.package_folder, self._module_file_rel_path),
177             {cmake_target: "mimalloc::mimalloc"}
178         )
179 
180     @staticmethod
181     def _create_cmake_module_alias_targets(module_file, targets):
182         content = ""
183         for alias, aliased in targets.items():
184             content += textwrap.dedent("""\
185                 if(TARGET {aliased} AND NOT TARGET {alias})
186                     add_library({alias} INTERFACE IMPORTED)
187                     set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased})
188                 endif()
189             """.format(alias=alias, aliased=aliased))
190         tools.save(module_file, content)
191 
192     @property
193     def _module_subfolder(self):
194         return os.path.join("lib", "cmake")
195 
196     @property
197     def _module_file_rel_path(self):
198         return os.path.join(self._module_subfolder,
199                             "conan-official-{}-targets.cmake".format(self.name))
200 
201     @property
202     def _obj_name(self):
203         name = "mimalloc"
204         if self.options.secure:
205             name += "-secure"
206         if self.settings.build_type not in ("Release", "RelWithDebInfo", "MinSizeRel"):
207             name += "-{}".format(str(self.settings.build_type).lower())
208         return name
209 
210     @property
211     def _lib_name(self):
212         name = "mimalloc" if self.settings.os == "Windows" else "libmimalloc"
213 
214         if self.settings.os == "Windows" and not self.options.shared:
215             name += "-static"
216         if self.options.secure:
217             name += "-secure"
218         if self.settings.build_type not in ("Release", "RelWithDebInfo", "MinSizeRel"):
219             name += "-{}".format(str(self.settings.build_type).lower())
220         return name
221 
222     def package_info(self):
223         self.cpp_info.set_property("cmake_file_name", "mimalloc")
224         self.cpp_info.set_property("cmake_target_name", "mimalloc" if self.options.shared else "mimalloc-static")
225 
226         self.cpp_info.names["cmake_find_package"] = "mimalloc"
227         self.cpp_info.names["cmake_find_package_multi"] = "mimalloc"
228         self.cpp_info.builddirs.append(self._module_subfolder)
229         self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path]
230         self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path]
231 
232         if self.options.get_safe("inject"):
233             self.cpp_info.includedirs = []
234             self.cpp_info.libdirs = []
235             self.cpp_info.resdirs = []
236             return
237 
238         if self.options.get_safe("single_object"):
239             obj_ext = "o"
240             obj_file = "{}.{}".format(self._obj_name, obj_ext)
241             obj_path = os.path.join(self.package_folder, "lib", obj_file)
242             self.cpp_info.exelinkflags = [obj_path]
243             self.cpp_info.sharedlinkflags = [obj_path]
244             self.cpp_info.libdirs = []
245             self.cpp_info.bindirs = []
246         else:
247             self.cpp_info.libs = tools.collect_libs(self)
248 
249         if self.settings.os == "Linux":
250             self.cpp_info.system_libs.append("pthread")
251         if not self.options.shared:
252             if self.settings.os == "Windows":
253                 self.cpp_info.system_libs.extend(["psapi", "shell32", "user32", "bcrypt"])
254             elif self.settings.os == "Linux":
255                 self.cpp_info.system_libs.append("rt")
256
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/recipes/mimalloc/all/conanfile.py b/recipes/mimalloc/all/conanfile.py
--- a/recipes/mimalloc/all/conanfile.py
+++ b/recipes/mimalloc/all/conanfile.py
@@ -101,7 +101,7 @@
         if self.options.override and \
            self.options.get_safe("single_object") and \
            self.options.get_safe("inject"):
-            raise ConanInvalidConfiguration("Single object is incompatible with library injection");
+            raise ConanInvalidConfiguration("Single object is incompatible with library injection")
 
         if self.settings.compiler.get_safe("cppstd"):
             tools.check_min_cppstd(self, "17")

{"golden_diff": "diff --git a/recipes/mimalloc/all/conanfile.py b/recipes/mimalloc/all/conanfile.py\n--- a/recipes/mimalloc/all/conanfile.py\n+++ b/recipes/mimalloc/all/conanfile.py\n@@ -101,7 +101,7 @@\n         if self.options.override and \\\n            self.options.get_safe(\"single_object\") and \\\n            self.options.get_safe(\"inject\"):\n-            raise ConanInvalidConfiguration(\"Single object is incompatible with library injection\");\n+            raise ConanInvalidConfiguration(\"Single object is incompatible with library injection\")\n \n         if self.settings.compiler.get_safe(\"cppstd\"):\n             tools.check_min_cppstd(self, \"17\")\n", "issue": "[request] mimalloc/1.7.5\n### Package Details\r\n  * Package Name/Version: **mimalloc/1.7.5**\r\n  * Changelog: **https://github.com/microsoft/mimalloc/releases/tag/v1.7.5**\r\n\r\n\r\nThe above mentioned version is newly released by the upstream project and not yet available as a recipe. Please add this version.\r\n\n", "before_files": [{"content": "from conans import ConanFile, CMake, tools\nfrom conans.errors import ConanInvalidConfiguration\nimport os\nimport shutil\nimport textwrap\n\nrequired_conan_version = \">=1.43.0\"\n\n\nclass MimallocConan(ConanFile):\n    name = \"mimalloc\"\n    license = \"MIT\"\n    url = \"https://github.com/conan-io/conan-center-index\"\n    homepage = \"https://github.com/microsoft/mimalloc\"\n    description = \"mimalloc is a compact general purpose allocator with excellent performance.\"\n    topics = (\"mimalloc\", \"allocator\", \"performance\", \"microsoft\")\n\n    settings = \"os\", \"arch\", \"compiler\", \"build_type\"\n    options = {\n        \"shared\": [True, False],\n        \"fPIC\": [True, False],\n        \"secure\": [True, False],\n        \"override\": [True, False],\n        \"inject\": [True, False],\n        \"single_object\": [True, False],\n    }\n    default_options = {\n        \"shared\": False,\n        \"fPIC\": True,\n        \"secure\": False,\n        \"override\": False,\n        \"inject\": False,\n        \"single_object\": False,\n    }\n\n    generators = \"cmake\"\n    _cmake = None\n\n    @property\n    def _source_subfolder(self):\n        return \"source_subfolder\"\n\n    @property\n    def _build_subfolder(self):\n        return \"build_subfolder\"\n\n    @property\n    def _compilers_minimum_version(self):\n        return {\n            \"gcc\": \"7\",\n            \"Visual Studio\": \"15\",\n            \"clang\": \"5\",\n            \"apple-clang\": \"10\",\n        }\n\n    def export_sources(self):\n        self.copy(\"CMakeLists.txt\")\n        for patch in self.conan_data.get(\"patches\", {}).get(self.version, []):\n            self.copy(patch[\"patch_file\"])\n\n    def config_options(self):\n        if self.settings.os == \"Windows\":\n            del self.options.fPIC\n\n        # single_object and inject are options\n        # only when overriding on Unix-like platforms:\n        if self.settings.compiler == \"Visual Studio\":\n            del self.options.single_object\n            del self.options.inject\n\n    def configure(self):\n        if self.options.shared:\n            del self.options.fPIC\n\n            # single_object is valid only for static\n            # override:\n            if self.options.get_safe(\"single_object\"):\n                del self.options.single_object\n\n        # inject is valid only for Unix-like dynamic override:\n        if not self.options.shared and self.options.get_safe(\"inject\"):\n            del self.options.inject\n\n        # single_object and inject are valid only when\n        # overriding on Unix-like platforms:\n        if not self.options.override:\n            if self.options.get_safe(\"single_object\"):\n                del self.options.single_object\n            if self.options.get_safe(\"inject\"):\n                del self.options.inject\n\n    def validate(self):\n        # Shared overriding requires dynamic runtime for MSVC:\n        if self.options.override and \\\n           self.options.shared and \\\n           self.settings.compiler == \"Visual Studio\" and \\\n           \"MT\" in str(self.settings.compiler.runtime):\n            raise ConanInvalidConfiguration(\n                \"Dynamic runtime (MD/MDd) is required when using mimalloc as a shared library for override\")\n\n        if self.options.override and \\\n           self.options.get_safe(\"single_object\") and \\\n           self.options.get_safe(\"inject\"):\n            raise ConanInvalidConfiguration(\"Single object is incompatible with library injection\");\n\n        if self.settings.compiler.get_safe(\"cppstd\"):\n            tools.check_min_cppstd(self, \"17\")\n\n        minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False)\n\n        if not minimum_version:\n            self.output.warn(\"mimalloc requires C++17. Your compiler is unknown. Assuming it supports C++17.\")\n        elif tools.Version(self.settings.compiler.version) < minimum_version:\n            raise ConanInvalidConfiguration(\"mimalloc requires a compiler that supports at least C++17\")\n\n    def source(self):\n        tools.get(**self.conan_data[\"sources\"][self.version],\n            destination=self._source_subfolder, strip_root=True)\n\n    def _configure_cmake(self):\n        if self._cmake:\n            return self._cmake\n        self._cmake = CMake(self)\n        if self._cmake.is_multi_configuration:\n            self._cmake.definitions[\"CMAKE_BUILD_TYPE\"] = self.settings.build_type\n        self._cmake.definitions[\"MI_BUILD_TESTS\"] = \"OFF\"\n        self._cmake.definitions[\"MI_BUILD_SHARED\"] = self.options.shared\n        self._cmake.definitions[\"MI_BUILD_STATIC\"] = not self.options.shared\n        self._cmake.definitions[\"MI_BUILD_OBJECT\"] = self.options.get_safe(\"single_object\", False)\n        self._cmake.definitions[\"MI_OVERRIDE\"] = \"ON\" if self.options.override else \"OFF\"\n        self._cmake.definitions[\"MI_SECURE\"] = \"ON\" if self.options.secure else \"OFF\"\n        if tools.Version(self.version) >= \"1.7.0\":\n            self._cmake.definitions[\"MI_INSTALL_TOPLEVEL\"] = \"ON\"\n        self._cmake.configure(build_folder=self._build_subfolder)\n        return self._cmake\n\n    def build(self):\n        for patch in self.conan_data.get(\"patches\", {}).get(self.version, []):\n            tools.patch(**patch)\n        if self.settings.compiler == \"Visual Studio\" and self.settings.arch == \"x86\":\n            tools.replace_path_in_file(os.path.join(self._source_subfolder, \"CMakeLists.txt\"),\n                                       \"mimalloc-redirect.lib\", \"mimalloc-redirect32.lib\")\n        with tools.vcvars(self.settings) if self.settings.compiler == \"Visual Studio\" else tools.no_op():\n            cmake = self._configure_cmake()\n            cmake.build()\n\n    def package(self):\n        self.copy(\"LICENSE\", dst=\"licenses\", src=self._source_subfolder)\n        with tools.vcvars(self.settings) if self.settings.compiler == \"Visual Studio\" else tools.no_op():\n            cmake = self._configure_cmake()\n            cmake.install()\n\n        tools.rmdir(os.path.join(self.package_folder, \"cmake\"))\n        tools.rmdir(os.path.join(self.package_folder, \"lib\", \"cmake\"))\n\n        if self.options.get_safe(\"single_object\"):\n            tools.remove_files_by_mask(os.path.join(self.package_folder, \"lib\"),\n                                       \"*.a\")\n            shutil.move(os.path.join(self.package_folder, self._obj_name + \".o\"),\n                        os.path.join(self.package_folder, \"lib\"))\n            shutil.copy(os.path.join(self.package_folder, \"lib\", self._obj_name + \".o\"),\n                        os.path.join(self.package_folder, \"lib\", self._obj_name))\n\n        if self.settings.os == \"Windows\" and self.options.shared:\n            if self.settings.arch == \"x86_64\":\n                self.copy(\"mimalloc-redirect.dll\", src=os.path.join(self._source_subfolder, \"bin\"),\n                          dst=\"bin\")\n            elif self.settings.arch == \"x86\":\n                self.copy(\"mimalloc-redirect32.dll\", src=os.path.join(self._source_subfolder, \"bin\"),\n                          dst=\"bin\")\n\n        tools.rmdir(os.path.join(self.package_folder, \"share\"))\n\n        cmake_target = \"mimalloc\" if self.options.shared else \"mimalloc-static\"\n        self._create_cmake_module_alias_targets(\n            os.path.join(self.package_folder, self._module_file_rel_path),\n            {cmake_target: \"mimalloc::mimalloc\"}\n        )\n\n    @staticmethod\n    def _create_cmake_module_alias_targets(module_file, targets):\n        content = \"\"\n        for alias, aliased in targets.items():\n            content += textwrap.dedent(\"\"\"\\\n                if(TARGET {aliased} AND NOT TARGET {alias})\n                    add_library({alias} INTERFACE IMPORTED)\n                    set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased})\n                endif()\n            \"\"\".format(alias=alias, aliased=aliased))\n        tools.save(module_file, content)\n\n    @property\n    def _module_subfolder(self):\n        return os.path.join(\"lib\", \"cmake\")\n\n    @property\n    def _module_file_rel_path(self):\n        return os.path.join(self._module_subfolder,\n                            \"conan-official-{}-targets.cmake\".format(self.name))\n\n    @property\n    def _obj_name(self):\n        name = \"mimalloc\"\n        if self.options.secure:\n            name += \"-secure\"\n        if self.settings.build_type not in (\"Release\", \"RelWithDebInfo\", \"MinSizeRel\"):\n            name += \"-{}\".format(str(self.settings.build_type).lower())\n        return name\n\n    @property\n    def _lib_name(self):\n        name = \"mimalloc\" if self.settings.os == \"Windows\" else \"libmimalloc\"\n\n        if self.settings.os == \"Windows\" and not self.options.shared:\n            name += \"-static\"\n        if self.options.secure:\n            name += \"-secure\"\n        if self.settings.build_type not in (\"Release\", \"RelWithDebInfo\", \"MinSizeRel\"):\n            name += \"-{}\".format(str(self.settings.build_type).lower())\n        return name\n\n    def package_info(self):\n        self.cpp_info.set_property(\"cmake_file_name\", \"mimalloc\")\n        self.cpp_info.set_property(\"cmake_target_name\", \"mimalloc\" if self.options.shared else \"mimalloc-static\")\n\n        self.cpp_info.names[\"cmake_find_package\"] = \"mimalloc\"\n        self.cpp_info.names[\"cmake_find_package_multi\"] = \"mimalloc\"\n        self.cpp_info.builddirs.append(self._module_subfolder)\n        self.cpp_info.build_modules[\"cmake_find_package\"] = [self._module_file_rel_path]\n        self.cpp_info.build_modules[\"cmake_find_package_multi\"] = [self._module_file_rel_path]\n\n        if self.options.get_safe(\"inject\"):\n            self.cpp_info.includedirs = []\n            self.cpp_info.libdirs = []\n            self.cpp_info.resdirs = []\n            return\n\n        if self.options.get_safe(\"single_object\"):\n            obj_ext = \"o\"\n            obj_file = \"{}.{}\".format(self._obj_name, obj_ext)\n            obj_path = os.path.join(self.package_folder, \"lib\", obj_file)\n            self.cpp_info.exelinkflags = [obj_path]\n            self.cpp_info.sharedlinkflags = [obj_path]\n            self.cpp_info.libdirs = []\n            self.cpp_info.bindirs = []\n        else:\n            self.cpp_info.libs = tools.collect_libs(self)\n\n        if self.settings.os == \"Linux\":\n            self.cpp_info.system_libs.append(\"pthread\")\n        if not self.options.shared:\n            if self.settings.os == \"Windows\":\n                self.cpp_info.system_libs.extend([\"psapi\", \"shell32\", \"user32\", \"bcrypt\"])\n            elif self.settings.os == \"Linux\":\n                self.cpp_info.system_libs.append(\"rt\")\n", "path": "recipes/mimalloc/all/conanfile.py"}], "after_files": [{"content": "from conans import ConanFile, CMake, tools\nfrom conans.errors import ConanInvalidConfiguration\nimport os\nimport shutil\nimport textwrap\n\nrequired_conan_version = \">=1.43.0\"\n\n\nclass MimallocConan(ConanFile):\n    name = \"mimalloc\"\n    license = \"MIT\"\n    url = \"https://github.com/conan-io/conan-center-index\"\n    homepage = \"https://github.com/microsoft/mimalloc\"\n    description = \"mimalloc is a compact general purpose allocator with excellent performance.\"\n    topics = (\"mimalloc\", \"allocator\", \"performance\", \"microsoft\")\n\n    settings = \"os\", \"arch\", \"compiler\", \"build_type\"\n    options = {\n        \"shared\": [True, False],\n        \"fPIC\": [True, False],\n        \"secure\": [True, False],\n        \"override\": [True, False],\n        \"inject\": [True, False],\n        \"single_object\": [True, False],\n    }\n    default_options = {\n        \"shared\": False,\n        \"fPIC\": True,\n        \"secure\": False,\n        \"override\": False,\n        \"inject\": False,\n        \"single_object\": False,\n    }\n\n    generators = \"cmake\"\n    _cmake = None\n\n    @property\n    def _source_subfolder(self):\n        return \"source_subfolder\"\n\n    @property\n    def _build_subfolder(self):\n        return \"build_subfolder\"\n\n    @property\n    def _compilers_minimum_version(self):\n        return {\n            \"gcc\": \"7\",\n            \"Visual Studio\": \"15\",\n            \"clang\": \"5\",\n            \"apple-clang\": \"10\",\n        }\n\n    def export_sources(self):\n        self.copy(\"CMakeLists.txt\")\n        for patch in self.conan_data.get(\"patches\", {}).get(self.version, []):\n            self.copy(patch[\"patch_file\"])\n\n    def config_options(self):\n        if self.settings.os == \"Windows\":\n            del self.options.fPIC\n\n        # single_object and inject are options\n        # only when overriding on Unix-like platforms:\n        if self.settings.compiler == \"Visual Studio\":\n            del self.options.single_object\n            del self.options.inject\n\n    def configure(self):\n        if self.options.shared:\n            del self.options.fPIC\n\n            # single_object is valid only for static\n            # override:\n            if self.options.get_safe(\"single_object\"):\n                del self.options.single_object\n\n        # inject is valid only for Unix-like dynamic override:\n        if not self.options.shared and self.options.get_safe(\"inject\"):\n            del self.options.inject\n\n        # single_object and inject are valid only when\n        # overriding on Unix-like platforms:\n        if not self.options.override:\n            if self.options.get_safe(\"single_object\"):\n                del self.options.single_object\n            if self.options.get_safe(\"inject\"):\n                del self.options.inject\n\n    def validate(self):\n        # Shared overriding requires dynamic runtime for MSVC:\n        if self.options.override and \\\n           self.options.shared and \\\n           self.settings.compiler == \"Visual Studio\" and \\\n           \"MT\" in str(self.settings.compiler.runtime):\n            raise ConanInvalidConfiguration(\n                \"Dynamic runtime (MD/MDd) is required when using mimalloc as a shared library for override\")\n\n        if self.options.override and \\\n           self.options.get_safe(\"single_object\") and \\\n           self.options.get_safe(\"inject\"):\n            raise ConanInvalidConfiguration(\"Single object is incompatible with library injection\")\n\n        if self.settings.compiler.get_safe(\"cppstd\"):\n            tools.check_min_cppstd(self, \"17\")\n\n        minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False)\n\n        if not minimum_version:\n            self.output.warn(\"mimalloc requires C++17. Your compiler is unknown. Assuming it supports C++17.\")\n        elif tools.Version(self.settings.compiler.version) < minimum_version:\n            raise ConanInvalidConfiguration(\"mimalloc requires a compiler that supports at least C++17\")\n\n    def source(self):\n        tools.get(**self.conan_data[\"sources\"][self.version],\n            destination=self._source_subfolder, strip_root=True)\n\n    def _configure_cmake(self):\n        if self._cmake:\n            return self._cmake\n        self._cmake = CMake(self)\n        if self._cmake.is_multi_configuration:\n            self._cmake.definitions[\"CMAKE_BUILD_TYPE\"] = self.settings.build_type\n        self._cmake.definitions[\"MI_BUILD_TESTS\"] = \"OFF\"\n        self._cmake.definitions[\"MI_BUILD_SHARED\"] = self.options.shared\n        self._cmake.definitions[\"MI_BUILD_STATIC\"] = not self.options.shared\n        self._cmake.definitions[\"MI_BUILD_OBJECT\"] = self.options.get_safe(\"single_object\", False)\n        self._cmake.definitions[\"MI_OVERRIDE\"] = \"ON\" if self.options.override else \"OFF\"\n        self._cmake.definitions[\"MI_SECURE\"] = \"ON\" if self.options.secure else \"OFF\"\n        if tools.Version(self.version) >= \"1.7.0\":\n            self._cmake.definitions[\"MI_INSTALL_TOPLEVEL\"] = \"ON\"\n        self._cmake.configure(build_folder=self._build_subfolder)\n        return self._cmake\n\n    def build(self):\n        for patch in self.conan_data.get(\"patches\", {}).get(self.version, []):\n            tools.patch(**patch)\n        if self.settings.compiler == \"Visual Studio\" and self.settings.arch == \"x86\":\n            tools.replace_path_in_file(os.path.join(self._source_subfolder, \"CMakeLists.txt\"),\n                                       \"mimalloc-redirect.lib\", \"mimalloc-redirect32.lib\")\n        with tools.vcvars(self.settings) if self.settings.compiler == \"Visual Studio\" else tools.no_op():\n            cmake = self._configure_cmake()\n            cmake.build()\n\n    def package(self):\n        self.copy(\"LICENSE\", dst=\"licenses\", src=self._source_subfolder)\n        with tools.vcvars(self.settings) if self.settings.compiler == \"Visual Studio\" else tools.no_op():\n            cmake = self._configure_cmake()\n            cmake.install()\n\n        tools.rmdir(os.path.join(self.package_folder, \"cmake\"))\n        tools.rmdir(os.path.join(self.package_folder, \"lib\", \"cmake\"))\n\n        if self.options.get_safe(\"single_object\"):\n            tools.remove_files_by_mask(os.path.join(self.package_folder, \"lib\"),\n                                       \"*.a\")\n            shutil.move(os.path.join(self.package_folder, self._obj_name + \".o\"),\n                        os.path.join(self.package_folder, \"lib\"))\n            shutil.copy(os.path.join(self.package_folder, \"lib\", self._obj_name + \".o\"),\n                        os.path.join(self.package_folder, \"lib\", self._obj_name))\n\n        if self.settings.os == \"Windows\" and self.options.shared:\n            if self.settings.arch == \"x86_64\":\n                self.copy(\"mimalloc-redirect.dll\", src=os.path.join(self._source_subfolder, \"bin\"),\n                          dst=\"bin\")\n            elif self.settings.arch == \"x86\":\n                self.copy(\"mimalloc-redirect32.dll\", src=os.path.join(self._source_subfolder, \"bin\"),\n                          dst=\"bin\")\n\n        tools.rmdir(os.path.join(self.package_folder, \"share\"))\n\n        cmake_target = \"mimalloc\" if self.options.shared else \"mimalloc-static\"\n        self._create_cmake_module_alias_targets(\n            os.path.join(self.package_folder, self._module_file_rel_path),\n            {cmake_target: \"mimalloc::mimalloc\"}\n        )\n\n    @staticmethod\n    def _create_cmake_module_alias_targets(module_file, targets):\n        content = \"\"\n        for alias, aliased in targets.items():\n            content += textwrap.dedent(\"\"\"\\\n                if(TARGET {aliased} AND NOT TARGET {alias})\n                    add_library({alias} INTERFACE IMPORTED)\n                    set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased})\n                endif()\n            \"\"\".format(alias=alias, aliased=aliased))\n        tools.save(module_file, content)\n\n    @property\n    def _module_subfolder(self):\n        return os.path.join(\"lib\", \"cmake\")\n\n    @property\n    def _module_file_rel_path(self):\n        return os.path.join(self._module_subfolder,\n                            \"conan-official-{}-targets.cmake\".format(self.name))\n\n    @property\n    def _obj_name(self):\n        name = \"mimalloc\"\n        if self.options.secure:\n            name += \"-secure\"\n        if self.settings.build_type not in (\"Release\", \"RelWithDebInfo\", \"MinSizeRel\"):\n            name += \"-{}\".format(str(self.settings.build_type).lower())\n        return name\n\n    @property\n    def _lib_name(self):\n        name = \"mimalloc\" if self.settings.os == \"Windows\" else \"libmimalloc\"\n\n        if self.settings.os == \"Windows\" and not self.options.shared:\n            name += \"-static\"\n        if self.options.secure:\n            name += \"-secure\"\n        if self.settings.build_type not in (\"Release\", \"RelWithDebInfo\", \"MinSizeRel\"):\n            name += \"-{}\".format(str(self.settings.build_type).lower())\n        return name\n\n    def package_info(self):\n        self.cpp_info.set_property(\"cmake_file_name\", \"mimalloc\")\n        self.cpp_info.set_property(\"cmake_target_name\", \"mimalloc\" if self.options.shared else \"mimalloc-static\")\n\n        self.cpp_info.names[\"cmake_find_package\"] = \"mimalloc\"\n        self.cpp_info.names[\"cmake_find_package_multi\"] = \"mimalloc\"\n        self.cpp_info.builddirs.append(self._module_subfolder)\n        self.cpp_info.build_modules[\"cmake_find_package\"] = [self._module_file_rel_path]\n        self.cpp_info.build_modules[\"cmake_find_package_multi\"] = [self._module_file_rel_path]\n\n        if self.options.get_safe(\"inject\"):\n            self.cpp_info.includedirs = []\n            self.cpp_info.libdirs = []\n            self.cpp_info.resdirs = []\n            return\n\n        if self.options.get_safe(\"single_object\"):\n            obj_ext = \"o\"\n            obj_file = \"{}.{}\".format(self._obj_name, obj_ext)\n            obj_path = os.path.join(self.package_folder, \"lib\", obj_file)\n            self.cpp_info.exelinkflags = [obj_path]\n            self.cpp_info.sharedlinkflags = [obj_path]\n            self.cpp_info.libdirs = []\n            self.cpp_info.bindirs = []\n        else:\n            self.cpp_info.libs = tools.collect_libs(self)\n\n        if self.settings.os == \"Linux\":\n            self.cpp_info.system_libs.append(\"pthread\")\n        if not self.options.shared:\n            if self.settings.os == \"Windows\":\n                self.cpp_info.system_libs.extend([\"psapi\", \"shell32\", \"user32\", \"bcrypt\"])\n            elif self.settings.os == \"Linux\":\n                self.cpp_info.system_libs.append(\"rt\")\n", "path": "recipes/mimalloc/all/conanfile.py"}]}