We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[package] onetbb/2021.3.0: Invalid character escape '\l'
### Description

For details on this, see : https://github.com/conan-io/conan/issues/10539

`conan_toolchain.cmake` is broken due to unescaped backslashes on windows. See log.

### Package and Environment Details

* Package Name/Version: **onetbb/2021.3.0#e447f12564bd0a5df3f2bd5781cf5cc7**
* Operating System+version: **Windows 11**
* Compiler+version: **MSVC 2022**
* Docker image: **?**
* Conan version: **conan 2.0.9**
* Python version: **Python 3.7.9**


### Conan profile

======== Input profiles ========
Profile host:
[settings]
arch=x86
build_type=Debug
compiler=msvc
compiler.cppstd=14
compiler.runtime=dynamic
compiler.runtime_type=Debug
compiler.version=193
os=Windows

Profile build:
[settings]
arch=x86_64
build_type=Release
compiler=msvc
compiler.cppstd=14
compiler.runtime=dynamic
compiler.runtime_type=Release
compiler.version=193
os=Windows


### Steps to reproduce

Install (build) onetbb/2021.3.0#e447f12564bd0a5df3f2bd5781cf5cc7 with cmakedeps / cmaketoolchain generator.

### Logs

<details><summary>Click to expand log</summary>

```
CMake Error at C:/Users/pgroarke/.conan2/p/b/onetb3e83bbcb22a9a/b/build/generators/conan_toolchain.cmake:117 (set):
  Syntax error in cmake code at

    C:/Users/pgroarke/.conan2/p/b/onetb3e83bbcb22a9a/b/build/generators/conan_toolchain.cmake:117

  when parsing string

    C:/Users/pgroarke/.conan2/p/b/hwloc93107a9ec9dfe/p\lib\hwloc.lib

  Invalid character escape '\l'.
```

</details>


--- 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/onetbb/all/conanfile.py`
Content:
```
1 from conan import ConanFile
2 from conan.errors import ConanInvalidConfiguration
3 from conan.tools.build import cross_building
4 from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
5 from conan.tools.files import apply_conandata_patches, export_conandata_patches, copy, get, load, rmdir
6 from conan.tools.gnu import PkgConfigDeps
7 from conan.tools.scm import Version
8 import os
9 import re
10 
11 required_conan_version = ">=1.53.0"
12 
13 
14 class OneTBBConan(ConanFile):
15     name = "onetbb"
16     license = "Apache-2.0"
17     url = "https://github.com/conan-io/conan-center-index"
18     homepage = "https://github.com/oneapi-src/oneTBB"
19     description = (
20         "oneAPI Threading Building Blocks (oneTBB) lets you easily write parallel C++"
21         " programs that take full advantage of multicore performance, that are portable, composable"
22         " and have future-proof scalability.")
23     topics = ("tbb", "threading", "parallelism", "tbbmalloc")
24 
25     settings = "os", "arch", "compiler", "build_type"
26     options = {
27         "shared": [True, False],
28         "fPIC": [True, False],
29         "tbbmalloc": [True, False],
30         "tbbproxy": [True, False],
31         "tbbbind": [True, False],
32         "interprocedural_optimization": [True, False],
33     }
34     default_options = {
35         "shared": True,
36         "fPIC": True,
37         "tbbmalloc": True,
38         "tbbproxy": True,
39         "tbbbind": True,
40         "interprocedural_optimization": True,
41     }
42 
43     @property
44     def _tbbbind_hwloc_version(self):
45         # TBB expects different variables depending on the version
46         return "2_5" if Version(self.version) >= "2021.4.0" else "2_4"
47 
48     @property
49     def _tbbbind_supported(self):
50         return Version(self.version) >= "2021.1.1" and not self.settings.os == "Macos"
51 
52     @property
53     def _tbbbind_build(self):
54         return self.options.get_safe("tbbbind", False) and self._tbbbind_supported
55 
56     @property
57     def _tbbbind_explicit_hwloc(self):
58         # during cross-compilation, oneTBB does not search for HWLOC and we need to specify it explicitly
59         # but then oneTBB creates an imported SHARED target from provided paths, so we have to set shared=True
60         return self._tbbbind_build and cross_building(self)
61 
62     def export_sources(self):
63         export_conandata_patches(self)
64 
65     def config_options(self):
66         if self.settings.os == "Windows":
67             del self.options.fPIC
68         if not self._tbbbind_supported:
69             del self.options.tbbbind
70         if Version(self.version) < "2021.6.0" or self.settings.os == "Android":
71             del self.options.interprocedural_optimization
72         if Version(self.version) < "2021.2.0":
73             del self.options.shared
74             self.options.rm_safe("fPIC")
75 
76     def configure(self):
77         if self.options.get_safe("shared", True):
78             self.options.rm_safe("fPIC")
79         else:
80             del self.options.tbbproxy
81             self.options.rm_safe("tbbbind")
82         if not self.options.tbbmalloc:
83             self.options.rm_safe("tbbproxy")
84         if self._tbbbind_explicit_hwloc:
85             self.options["hwloc"].shared = True
86 
87     def requirements(self):
88         if self._tbbbind_build:
89             self.requires("hwloc/2.9.1")
90 
91     def layout(self):
92         cmake_layout(self, src_folder="src")
93 
94     def package_id(self):
95         if Version(self.version) < "2021.5.0":
96             self.info.options.tbbmalloc = True
97         if Version(self.version) < "2021.6.0" and self.info.options.get_safe("tbbproxy"):
98             self.info.options.tbbproxy = True
99 
100     def validate_build(self):
101         if self.settings.compiler == "apple-clang" and Version(self.settings.compiler.version) < "11.0":
102             raise ConanInvalidConfiguration(f"{self.ref} couldn't be built by apple-clang < 11.0")
103         if not self.options.get_safe("shared", True):
104             if Version(self.version) >= "2021.6.0":
105                 raise ConanInvalidConfiguration(
106                     "Building oneTBB as a static library is highly discouraged and not supported "
107                     "to avoid unforeseen issues like https://github.com/oneapi-src/oneTBB/issues/920. "
108                     "Please consider fixing at least the aforementioned issue in upstream."
109                 )
110             self.output.warning("oneTBB strongly discourages usage of static linkage")
111         if self._tbbbind_explicit_hwloc and not self.dependencies["hwloc"].options.shared:
112             raise ConanInvalidConfiguration(f"{self.ref} requires hwloc:shared=True to be built.")
113 
114     def source(self):
115         get(self, **self.conan_data["sources"][self.version], strip_root=True)
116 
117     def generate(self):
118         toolchain = CMakeToolchain(self)
119         toolchain.variables["TBB_TEST"] = False
120         toolchain.variables["TBB_STRICT"] = False
121         if Version(self.version) >= "2021.5.0":
122             toolchain.variables["TBBMALLOC_BUILD"] = self.options.tbbmalloc
123         if self.options.get_safe("interprocedural_optimization"):
124             toolchain.variables["TBB_ENABLE_IPO"] = self.options.interprocedural_optimization
125         if Version(self.version) >= "2021.6.0" and self.options.get_safe("tbbproxy"):
126             toolchain.variables["TBBMALLOC_PROXY_BUILD"] = self.options.tbbproxy
127         toolchain.variables["TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH"] = not self._tbbbind_build
128         if self._tbbbind_build:
129             deps = PkgConfigDeps(self)
130             deps.generate()
131         if self._tbbbind_explicit_hwloc:
132             hwloc_package_folder = self.dependencies["hwloc"].package_folder.replace("\\", "/")
133             hwloc_lib_name = "hwloc.lib" if self.settings.os == "Windows" else "libhwloc.so"
134             toolchain.variables[f"CMAKE_HWLOC_{self._tbbbind_hwloc_version}_LIBRARY_PATH"] = os.path.join(hwloc_package_folder, "lib", hwloc_lib_name)
135             toolchain.variables[f"CMAKE_HWLOC_{self._tbbbind_hwloc_version}_INCLUDE_PATH"] = os.path.join(hwloc_package_folder, "include")
136             if self.settings.os == "Windows":
137                 toolchain.variables[f"CMAKE_HWLOC_{self._tbbbind_hwloc_version}_DLL_PATH"] = os.path.join(hwloc_package_folder, "bin", "hwloc.dll")
138         toolchain.generate()
139 
140     def build(self):
141         apply_conandata_patches(self)
142         cmake = CMake(self)
143         cmake.configure()
144         cmake.build()
145 
146     def package(self):
147         cmake = CMake(self)
148         cmake.install()
149         copy(self, "LICENSE.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
150         rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
151         rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
152         rmdir(self, os.path.join(self.package_folder, "share"))
153 
154     def package_info(self):
155         self.cpp_info.set_property("cmake_file_name", "TBB")
156         self.cpp_info.set_property("pkg_config_name", "tbb")
157         self.cpp_info.set_property("cmake_config_version_compat", "AnyNewerVersion")
158 
159         def lib_name(name):
160             if self.settings.build_type == "Debug":
161                 return name + "_debug"
162             return name
163 
164         # tbb
165         tbb = self.cpp_info.components["libtbb"]
166 
167         tbb.set_property("cmake_target_name", "TBB::tbb")
168         tbb.libs = [lib_name("tbb")]
169         if self.settings.os == "Windows":
170             version_info = load(self,
171                 os.path.join(self.package_folder, "include", "oneapi", "tbb",
172                              "version.h"))
173             binary_version = re.sub(
174                 r".*" + re.escape("#define __TBB_BINARY_VERSION ") +
175                 r"(\d+).*",
176                 r"\1",
177                 version_info,
178                 flags=re.MULTILINE | re.DOTALL,
179             )
180             tbb.libs.append(lib_name(f"tbb{binary_version}"))
181         if self.settings.os in ["Linux", "FreeBSD"]:
182             tbb.system_libs = ["m", "dl", "rt", "pthread"]
183 
184         # tbbmalloc
185         if self.options.tbbmalloc:
186             tbbmalloc = self.cpp_info.components["tbbmalloc"]
187 
188             tbbmalloc.set_property("cmake_target_name", "TBB::tbbmalloc")
189             tbbmalloc.libs = [lib_name("tbbmalloc")]
190             if self.settings.os in ["Linux", "FreeBSD"]:
191                 tbbmalloc.system_libs = ["dl", "pthread"]
192 
193             # tbbmalloc_proxy
194             if self.options.get_safe("tbbproxy", False):
195                 tbbproxy = self.cpp_info.components["tbbmalloc_proxy"]
196 
197                 tbbproxy.set_property("cmake_target_name", "TBB::tbbmalloc_proxy")
198                 tbbproxy.libs = [lib_name("tbbmalloc_proxy")]
199                 tbbproxy.requires = ["tbbmalloc"]
200                 if self.settings.os in ["Linux", "FreeBSD"]:
201                     tbbproxy.system_libs = ["m", "dl", "pthread"]
202 
203         # TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed
204         self.cpp_info.names["cmake_find_package"] = "TBB"
205         self.cpp_info.names["cmake_find_package_multi"] = "TBB"
206         self.cpp_info.names["pkg_config"] = "tbb"
207         tbb.names["cmake_find_package"] = "tbb"
208         tbb.names["cmake_find_package_multi"] = "tbb"
209
```
--- 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/onetbb/all/conanfile.py b/recipes/onetbb/all/conanfile.py
--- a/recipes/onetbb/all/conanfile.py
+++ b/recipes/onetbb/all/conanfile.py
@@ -125,18 +125,22 @@
         if Version(self.version) >= "2021.6.0" and self.options.get_safe("tbbproxy"):
             toolchain.variables["TBBMALLOC_PROXY_BUILD"] = self.options.tbbproxy
         toolchain.variables["TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH"] = not self._tbbbind_build
-        if self._tbbbind_build:
-            deps = PkgConfigDeps(self)
-            deps.generate()
         if self._tbbbind_explicit_hwloc:
-            hwloc_package_folder = self.dependencies["hwloc"].package_folder.replace("\\", "/")
+            hwloc_package_folder = self.dependencies["hwloc"].package_folder
             hwloc_lib_name = "hwloc.lib" if self.settings.os == "Windows" else "libhwloc.so"
-            toolchain.variables[f"CMAKE_HWLOC_{self._tbbbind_hwloc_version}_LIBRARY_PATH"] = os.path.join(hwloc_package_folder, "lib", hwloc_lib_name)
-            toolchain.variables[f"CMAKE_HWLOC_{self._tbbbind_hwloc_version}_INCLUDE_PATH"] = os.path.join(hwloc_package_folder, "include")
+            toolchain.variables[f"CMAKE_HWLOC_{self._tbbbind_hwloc_version}_LIBRARY_PATH"] = \
+                os.path.join(hwloc_package_folder, "lib", hwloc_lib_name).replace("\\", "/")
+            toolchain.variables[f"CMAKE_HWLOC_{self._tbbbind_hwloc_version}_INCLUDE_PATH"] = \
+                os.path.join(hwloc_package_folder, "include").replace("\\", "/")
             if self.settings.os == "Windows":
-                toolchain.variables[f"CMAKE_HWLOC_{self._tbbbind_hwloc_version}_DLL_PATH"] = os.path.join(hwloc_package_folder, "bin", "hwloc.dll")
+                toolchain.variables[f"CMAKE_HWLOC_{self._tbbbind_hwloc_version}_DLL_PATH"] = \
+                    os.path.join(hwloc_package_folder, "bin", "hwloc.dll").replace("\\", "/")
         toolchain.generate()
 
+        if self._tbbbind_build:
+            deps = PkgConfigDeps(self)
+            deps.generate()
+
     def build(self):
         apply_conandata_patches(self)
         cmake = CMake(self)

{"golden_diff": "diff --git a/recipes/onetbb/all/conanfile.py b/recipes/onetbb/all/conanfile.py\n--- a/recipes/onetbb/all/conanfile.py\n+++ b/recipes/onetbb/all/conanfile.py\n@@ -125,18 +125,22 @@\n         if Version(self.version) >= \"2021.6.0\" and self.options.get_safe(\"tbbproxy\"):\n             toolchain.variables[\"TBBMALLOC_PROXY_BUILD\"] = self.options.tbbproxy\n         toolchain.variables[\"TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH\"] = not self._tbbbind_build\n-        if self._tbbbind_build:\n-            deps = PkgConfigDeps(self)\n-            deps.generate()\n         if self._tbbbind_explicit_hwloc:\n-            hwloc_package_folder = self.dependencies[\"hwloc\"].package_folder.replace(\"\\\\\", \"/\")\n+            hwloc_package_folder = self.dependencies[\"hwloc\"].package_folder\n             hwloc_lib_name = \"hwloc.lib\" if self.settings.os == \"Windows\" else \"libhwloc.so\"\n-            toolchain.variables[f\"CMAKE_HWLOC_{self._tbbbind_hwloc_version}_LIBRARY_PATH\"] = os.path.join(hwloc_package_folder, \"lib\", hwloc_lib_name)\n-            toolchain.variables[f\"CMAKE_HWLOC_{self._tbbbind_hwloc_version}_INCLUDE_PATH\"] = os.path.join(hwloc_package_folder, \"include\")\n+            toolchain.variables[f\"CMAKE_HWLOC_{self._tbbbind_hwloc_version}_LIBRARY_PATH\"] = \\\n+                os.path.join(hwloc_package_folder, \"lib\", hwloc_lib_name).replace(\"\\\\\", \"/\")\n+            toolchain.variables[f\"CMAKE_HWLOC_{self._tbbbind_hwloc_version}_INCLUDE_PATH\"] = \\\n+                os.path.join(hwloc_package_folder, \"include\").replace(\"\\\\\", \"/\")\n             if self.settings.os == \"Windows\":\n-                toolchain.variables[f\"CMAKE_HWLOC_{self._tbbbind_hwloc_version}_DLL_PATH\"] = os.path.join(hwloc_package_folder, \"bin\", \"hwloc.dll\")\n+                toolchain.variables[f\"CMAKE_HWLOC_{self._tbbbind_hwloc_version}_DLL_PATH\"] = \\\n+                    os.path.join(hwloc_package_folder, \"bin\", \"hwloc.dll\").replace(\"\\\\\", \"/\")\n         toolchain.generate()\n \n+        if self._tbbbind_build:\n+            deps = PkgConfigDeps(self)\n+            deps.generate()\n+\n     def build(self):\n         apply_conandata_patches(self)\n         cmake = CMake(self)\n", "issue": "[package] onetbb/2021.3.0: Invalid character escape '\\l'\n### Description\n\nFor details on this, see : https://github.com/conan-io/conan/issues/10539\r\n\r\n`conan_toolchain.cmake` is broken due to unescaped backslashes on windows. See log.\n\n### Package and Environment Details\n\n* Package Name/Version: **onetbb/2021.3.0#e447f12564bd0a5df3f2bd5781cf5cc7**\r\n* Operating System+version: **Windows 11**\r\n* Compiler+version: **MSVC 2022**\r\n* Docker image: **?**\r\n* Conan version: **conan 2.0.9**\r\n* Python version: **Python 3.7.9**\r\n\n\n### Conan profile\n\n======== Input profiles ========\r\nProfile host:\r\n[settings]\r\narch=x86\r\nbuild_type=Debug\r\ncompiler=msvc\r\ncompiler.cppstd=14\r\ncompiler.runtime=dynamic\r\ncompiler.runtime_type=Debug\r\ncompiler.version=193\r\nos=Windows\r\n\r\nProfile build:\r\n[settings]\r\narch=x86_64\r\nbuild_type=Release\r\ncompiler=msvc\r\ncompiler.cppstd=14\r\ncompiler.runtime=dynamic\r\ncompiler.runtime_type=Release\r\ncompiler.version=193\r\nos=Windows\r\n\n\n### Steps to reproduce\n\nInstall (build) onetbb/2021.3.0#e447f12564bd0a5df3f2bd5781cf5cc7 with cmakedeps / cmaketoolchain generator.\n\n### Logs\n\n<details><summary>Click to expand log</summary>\r\n\r\n```\r\nCMake Error at C:/Users/pgroarke/.conan2/p/b/onetb3e83bbcb22a9a/b/build/generators/conan_toolchain.cmake:117 (set):\r\n  Syntax error in cmake code at\r\n\r\n    C:/Users/pgroarke/.conan2/p/b/onetb3e83bbcb22a9a/b/build/generators/conan_toolchain.cmake:117\r\n\r\n  when parsing string\r\n\r\n    C:/Users/pgroarke/.conan2/p/b/hwloc93107a9ec9dfe/p\\lib\\hwloc.lib\r\n\r\n  Invalid character escape '\\l'.\r\n```\r\n\r\n</details>\r\n\n", "before_files": [{"content": "from conan import ConanFile\nfrom conan.errors import ConanInvalidConfiguration\nfrom conan.tools.build import cross_building\nfrom conan.tools.cmake import CMake, CMakeToolchain, cmake_layout\nfrom conan.tools.files import apply_conandata_patches, export_conandata_patches, copy, get, load, rmdir\nfrom conan.tools.gnu import PkgConfigDeps\nfrom conan.tools.scm import Version\nimport os\nimport re\n\nrequired_conan_version = \">=1.53.0\"\n\n\nclass OneTBBConan(ConanFile):\n    name = \"onetbb\"\n    license = \"Apache-2.0\"\n    url = \"https://github.com/conan-io/conan-center-index\"\n    homepage = \"https://github.com/oneapi-src/oneTBB\"\n    description = (\n        \"oneAPI Threading Building Blocks (oneTBB) lets you easily write parallel C++\"\n        \" programs that take full advantage of multicore performance, that are portable, composable\"\n        \" and have future-proof scalability.\")\n    topics = (\"tbb\", \"threading\", \"parallelism\", \"tbbmalloc\")\n\n    settings = \"os\", \"arch\", \"compiler\", \"build_type\"\n    options = {\n        \"shared\": [True, False],\n        \"fPIC\": [True, False],\n        \"tbbmalloc\": [True, False],\n        \"tbbproxy\": [True, False],\n        \"tbbbind\": [True, False],\n        \"interprocedural_optimization\": [True, False],\n    }\n    default_options = {\n        \"shared\": True,\n        \"fPIC\": True,\n        \"tbbmalloc\": True,\n        \"tbbproxy\": True,\n        \"tbbbind\": True,\n        \"interprocedural_optimization\": True,\n    }\n\n    @property\n    def _tbbbind_hwloc_version(self):\n        # TBB expects different variables depending on the version\n        return \"2_5\" if Version(self.version) >= \"2021.4.0\" else \"2_4\"\n\n    @property\n    def _tbbbind_supported(self):\n        return Version(self.version) >= \"2021.1.1\" and not self.settings.os == \"Macos\"\n\n    @property\n    def _tbbbind_build(self):\n        return self.options.get_safe(\"tbbbind\", False) and self._tbbbind_supported\n\n    @property\n    def _tbbbind_explicit_hwloc(self):\n        # during cross-compilation, oneTBB does not search for HWLOC and we need to specify it explicitly\n        # but then oneTBB creates an imported SHARED target from provided paths, so we have to set shared=True\n        return self._tbbbind_build and cross_building(self)\n\n    def export_sources(self):\n        export_conandata_patches(self)\n\n    def config_options(self):\n        if self.settings.os == \"Windows\":\n            del self.options.fPIC\n        if not self._tbbbind_supported:\n            del self.options.tbbbind\n        if Version(self.version) < \"2021.6.0\" or self.settings.os == \"Android\":\n            del self.options.interprocedural_optimization\n        if Version(self.version) < \"2021.2.0\":\n            del self.options.shared\n            self.options.rm_safe(\"fPIC\")\n\n    def configure(self):\n        if self.options.get_safe(\"shared\", True):\n            self.options.rm_safe(\"fPIC\")\n        else:\n            del self.options.tbbproxy\n            self.options.rm_safe(\"tbbbind\")\n        if not self.options.tbbmalloc:\n            self.options.rm_safe(\"tbbproxy\")\n        if self._tbbbind_explicit_hwloc:\n            self.options[\"hwloc\"].shared = True\n\n    def requirements(self):\n        if self._tbbbind_build:\n            self.requires(\"hwloc/2.9.1\")\n\n    def layout(self):\n        cmake_layout(self, src_folder=\"src\")\n\n    def package_id(self):\n        if Version(self.version) < \"2021.5.0\":\n            self.info.options.tbbmalloc = True\n        if Version(self.version) < \"2021.6.0\" and self.info.options.get_safe(\"tbbproxy\"):\n            self.info.options.tbbproxy = True\n\n    def validate_build(self):\n        if self.settings.compiler == \"apple-clang\" and Version(self.settings.compiler.version) < \"11.0\":\n            raise ConanInvalidConfiguration(f\"{self.ref} couldn't be built by apple-clang < 11.0\")\n        if not self.options.get_safe(\"shared\", True):\n            if Version(self.version) >= \"2021.6.0\":\n                raise ConanInvalidConfiguration(\n                    \"Building oneTBB as a static library is highly discouraged and not supported \"\n                    \"to avoid unforeseen issues like https://github.com/oneapi-src/oneTBB/issues/920. \"\n                    \"Please consider fixing at least the aforementioned issue in upstream.\"\n                )\n            self.output.warning(\"oneTBB strongly discourages usage of static linkage\")\n        if self._tbbbind_explicit_hwloc and not self.dependencies[\"hwloc\"].options.shared:\n            raise ConanInvalidConfiguration(f\"{self.ref} requires hwloc:shared=True to be built.\")\n\n    def source(self):\n        get(self, **self.conan_data[\"sources\"][self.version], strip_root=True)\n\n    def generate(self):\n        toolchain = CMakeToolchain(self)\n        toolchain.variables[\"TBB_TEST\"] = False\n        toolchain.variables[\"TBB_STRICT\"] = False\n        if Version(self.version) >= \"2021.5.0\":\n            toolchain.variables[\"TBBMALLOC_BUILD\"] = self.options.tbbmalloc\n        if self.options.get_safe(\"interprocedural_optimization\"):\n            toolchain.variables[\"TBB_ENABLE_IPO\"] = self.options.interprocedural_optimization\n        if Version(self.version) >= \"2021.6.0\" and self.options.get_safe(\"tbbproxy\"):\n            toolchain.variables[\"TBBMALLOC_PROXY_BUILD\"] = self.options.tbbproxy\n        toolchain.variables[\"TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH\"] = not self._tbbbind_build\n        if self._tbbbind_build:\n            deps = PkgConfigDeps(self)\n            deps.generate()\n        if self._tbbbind_explicit_hwloc:\n            hwloc_package_folder = self.dependencies[\"hwloc\"].package_folder.replace(\"\\\\\", \"/\")\n            hwloc_lib_name = \"hwloc.lib\" if self.settings.os == \"Windows\" else \"libhwloc.so\"\n            toolchain.variables[f\"CMAKE_HWLOC_{self._tbbbind_hwloc_version}_LIBRARY_PATH\"] = os.path.join(hwloc_package_folder, \"lib\", hwloc_lib_name)\n            toolchain.variables[f\"CMAKE_HWLOC_{self._tbbbind_hwloc_version}_INCLUDE_PATH\"] = os.path.join(hwloc_package_folder, \"include\")\n            if self.settings.os == \"Windows\":\n                toolchain.variables[f\"CMAKE_HWLOC_{self._tbbbind_hwloc_version}_DLL_PATH\"] = os.path.join(hwloc_package_folder, \"bin\", \"hwloc.dll\")\n        toolchain.generate()\n\n    def build(self):\n        apply_conandata_patches(self)\n        cmake = CMake(self)\n        cmake.configure()\n        cmake.build()\n\n    def package(self):\n        cmake = CMake(self)\n        cmake.install()\n        copy(self, \"LICENSE.txt\", src=self.source_folder, dst=os.path.join(self.package_folder, \"licenses\"))\n        rmdir(self, os.path.join(self.package_folder, \"lib\", \"cmake\"))\n        rmdir(self, os.path.join(self.package_folder, \"lib\", \"pkgconfig\"))\n        rmdir(self, os.path.join(self.package_folder, \"share\"))\n\n    def package_info(self):\n        self.cpp_info.set_property(\"cmake_file_name\", \"TBB\")\n        self.cpp_info.set_property(\"pkg_config_name\", \"tbb\")\n        self.cpp_info.set_property(\"cmake_config_version_compat\", \"AnyNewerVersion\")\n\n        def lib_name(name):\n            if self.settings.build_type == \"Debug\":\n                return name + \"_debug\"\n            return name\n\n        # tbb\n        tbb = self.cpp_info.components[\"libtbb\"]\n\n        tbb.set_property(\"cmake_target_name\", \"TBB::tbb\")\n        tbb.libs = [lib_name(\"tbb\")]\n        if self.settings.os == \"Windows\":\n            version_info = load(self,\n                os.path.join(self.package_folder, \"include\", \"oneapi\", \"tbb\",\n                             \"version.h\"))\n            binary_version = re.sub(\n                r\".*\" + re.escape(\"#define __TBB_BINARY_VERSION \") +\n                r\"(\\d+).*\",\n                r\"\\1\",\n                version_info,\n                flags=re.MULTILINE | re.DOTALL,\n            )\n            tbb.libs.append(lib_name(f\"tbb{binary_version}\"))\n        if self.settings.os in [\"Linux\", \"FreeBSD\"]:\n            tbb.system_libs = [\"m\", \"dl\", \"rt\", \"pthread\"]\n\n        # tbbmalloc\n        if self.options.tbbmalloc:\n            tbbmalloc = self.cpp_info.components[\"tbbmalloc\"]\n\n            tbbmalloc.set_property(\"cmake_target_name\", \"TBB::tbbmalloc\")\n            tbbmalloc.libs = [lib_name(\"tbbmalloc\")]\n            if self.settings.os in [\"Linux\", \"FreeBSD\"]:\n                tbbmalloc.system_libs = [\"dl\", \"pthread\"]\n\n            # tbbmalloc_proxy\n            if self.options.get_safe(\"tbbproxy\", False):\n                tbbproxy = self.cpp_info.components[\"tbbmalloc_proxy\"]\n\n                tbbproxy.set_property(\"cmake_target_name\", \"TBB::tbbmalloc_proxy\")\n                tbbproxy.libs = [lib_name(\"tbbmalloc_proxy\")]\n                tbbproxy.requires = [\"tbbmalloc\"]\n                if self.settings.os in [\"Linux\", \"FreeBSD\"]:\n                    tbbproxy.system_libs = [\"m\", \"dl\", \"pthread\"]\n\n        # TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed\n        self.cpp_info.names[\"cmake_find_package\"] = \"TBB\"\n        self.cpp_info.names[\"cmake_find_package_multi\"] = \"TBB\"\n        self.cpp_info.names[\"pkg_config\"] = \"tbb\"\n        tbb.names[\"cmake_find_package\"] = \"tbb\"\n        tbb.names[\"cmake_find_package_multi\"] = \"tbb\"\n", "path": "recipes/onetbb/all/conanfile.py"}], "after_files": [{"content": "from conan import ConanFile\nfrom conan.errors import ConanInvalidConfiguration\nfrom conan.tools.build import cross_building\nfrom conan.tools.cmake import CMake, CMakeToolchain, cmake_layout\nfrom conan.tools.files import apply_conandata_patches, export_conandata_patches, copy, get, load, rmdir\nfrom conan.tools.gnu import PkgConfigDeps\nfrom conan.tools.scm import Version\nimport os\nimport re\n\nrequired_conan_version = \">=1.53.0\"\n\n\nclass OneTBBConan(ConanFile):\n    name = \"onetbb\"\n    license = \"Apache-2.0\"\n    url = \"https://github.com/conan-io/conan-center-index\"\n    homepage = \"https://github.com/oneapi-src/oneTBB\"\n    description = (\n        \"oneAPI Threading Building Blocks (oneTBB) lets you easily write parallel C++\"\n        \" programs that take full advantage of multicore performance, that are portable, composable\"\n        \" and have future-proof scalability.\")\n    topics = (\"tbb\", \"threading\", \"parallelism\", \"tbbmalloc\")\n\n    settings = \"os\", \"arch\", \"compiler\", \"build_type\"\n    options = {\n        \"shared\": [True, False],\n        \"fPIC\": [True, False],\n        \"tbbmalloc\": [True, False],\n        \"tbbproxy\": [True, False],\n        \"tbbbind\": [True, False],\n        \"interprocedural_optimization\": [True, False],\n    }\n    default_options = {\n        \"shared\": True,\n        \"fPIC\": True,\n        \"tbbmalloc\": True,\n        \"tbbproxy\": True,\n        \"tbbbind\": True,\n        \"interprocedural_optimization\": True,\n    }\n\n    @property\n    def _tbbbind_hwloc_version(self):\n        # TBB expects different variables depending on the version\n        return \"2_5\" if Version(self.version) >= \"2021.4.0\" else \"2_4\"\n\n    @property\n    def _tbbbind_supported(self):\n        return Version(self.version) >= \"2021.1.1\" and not self.settings.os == \"Macos\"\n\n    @property\n    def _tbbbind_build(self):\n        return self.options.get_safe(\"tbbbind\", False) and self._tbbbind_supported\n\n    @property\n    def _tbbbind_explicit_hwloc(self):\n        # during cross-compilation, oneTBB does not search for HWLOC and we need to specify it explicitly\n        # but then oneTBB creates an imported SHARED target from provided paths, so we have to set shared=True\n        return self._tbbbind_build and cross_building(self)\n\n    def export_sources(self):\n        export_conandata_patches(self)\n\n    def config_options(self):\n        if self.settings.os == \"Windows\":\n            del self.options.fPIC\n        if not self._tbbbind_supported:\n            del self.options.tbbbind\n        if Version(self.version) < \"2021.6.0\" or self.settings.os == \"Android\":\n            del self.options.interprocedural_optimization\n        if Version(self.version) < \"2021.2.0\":\n            del self.options.shared\n            self.options.rm_safe(\"fPIC\")\n\n    def configure(self):\n        if self.options.get_safe(\"shared\", True):\n            self.options.rm_safe(\"fPIC\")\n        else:\n            del self.options.tbbproxy\n            self.options.rm_safe(\"tbbbind\")\n        if not self.options.tbbmalloc:\n            self.options.rm_safe(\"tbbproxy\")\n        if self._tbbbind_explicit_hwloc:\n            self.options[\"hwloc\"].shared = True\n\n    def requirements(self):\n        if self._tbbbind_build:\n            self.requires(\"hwloc/2.9.1\")\n\n    def layout(self):\n        cmake_layout(self, src_folder=\"src\")\n\n    def package_id(self):\n        if Version(self.version) < \"2021.5.0\":\n            self.info.options.tbbmalloc = True\n        if Version(self.version) < \"2021.6.0\" and self.info.options.get_safe(\"tbbproxy\"):\n            self.info.options.tbbproxy = True\n\n    def validate_build(self):\n        if self.settings.compiler == \"apple-clang\" and Version(self.settings.compiler.version) < \"11.0\":\n            raise ConanInvalidConfiguration(f\"{self.ref} couldn't be built by apple-clang < 11.0\")\n        if not self.options.get_safe(\"shared\", True):\n            if Version(self.version) >= \"2021.6.0\":\n                raise ConanInvalidConfiguration(\n                    \"Building oneTBB as a static library is highly discouraged and not supported \"\n                    \"to avoid unforeseen issues like https://github.com/oneapi-src/oneTBB/issues/920. \"\n                    \"Please consider fixing at least the aforementioned issue in upstream.\"\n                )\n            self.output.warning(\"oneTBB strongly discourages usage of static linkage\")\n        if self._tbbbind_explicit_hwloc and not self.dependencies[\"hwloc\"].options.shared:\n            raise ConanInvalidConfiguration(f\"{self.ref} requires hwloc:shared=True to be built.\")\n\n    def source(self):\n        get(self, **self.conan_data[\"sources\"][self.version], strip_root=True)\n\n    def generate(self):\n        toolchain = CMakeToolchain(self)\n        toolchain.variables[\"TBB_TEST\"] = False\n        toolchain.variables[\"TBB_STRICT\"] = False\n        if Version(self.version) >= \"2021.5.0\":\n            toolchain.variables[\"TBBMALLOC_BUILD\"] = self.options.tbbmalloc\n        if self.options.get_safe(\"interprocedural_optimization\"):\n            toolchain.variables[\"TBB_ENABLE_IPO\"] = self.options.interprocedural_optimization\n        if Version(self.version) >= \"2021.6.0\" and self.options.get_safe(\"tbbproxy\"):\n            toolchain.variables[\"TBBMALLOC_PROXY_BUILD\"] = self.options.tbbproxy\n        toolchain.variables[\"TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH\"] = not self._tbbbind_build\n        if self._tbbbind_explicit_hwloc:\n            hwloc_package_folder = self.dependencies[\"hwloc\"].package_folder\n            hwloc_lib_name = \"hwloc.lib\" if self.settings.os == \"Windows\" else \"libhwloc.so\"\n            toolchain.variables[f\"CMAKE_HWLOC_{self._tbbbind_hwloc_version}_LIBRARY_PATH\"] = \\\n                os.path.join(hwloc_package_folder, \"lib\", hwloc_lib_name).replace(\"\\\\\", \"/\")\n            toolchain.variables[f\"CMAKE_HWLOC_{self._tbbbind_hwloc_version}_INCLUDE_PATH\"] = \\\n                os.path.join(hwloc_package_folder, \"include\").replace(\"\\\\\", \"/\")\n            if self.settings.os == \"Windows\":\n                toolchain.variables[f\"CMAKE_HWLOC_{self._tbbbind_hwloc_version}_DLL_PATH\"] = \\\n                    os.path.join(hwloc_package_folder, \"bin\", \"hwloc.dll\").replace(\"\\\\\", \"/\")\n        toolchain.generate()\n\n        if self._tbbbind_build:\n            deps = PkgConfigDeps(self)\n            deps.generate()\n\n    def build(self):\n        apply_conandata_patches(self)\n        cmake = CMake(self)\n        cmake.configure()\n        cmake.build()\n\n    def package(self):\n        cmake = CMake(self)\n        cmake.install()\n        copy(self, \"LICENSE.txt\", src=self.source_folder, dst=os.path.join(self.package_folder, \"licenses\"))\n        rmdir(self, os.path.join(self.package_folder, \"lib\", \"cmake\"))\n        rmdir(self, os.path.join(self.package_folder, \"lib\", \"pkgconfig\"))\n        rmdir(self, os.path.join(self.package_folder, \"share\"))\n\n    def package_info(self):\n        self.cpp_info.set_property(\"cmake_file_name\", \"TBB\")\n        self.cpp_info.set_property(\"pkg_config_name\", \"tbb\")\n        self.cpp_info.set_property(\"cmake_config_version_compat\", \"AnyNewerVersion\")\n\n        def lib_name(name):\n            if self.settings.build_type == \"Debug\":\n                return name + \"_debug\"\n            return name\n\n        # tbb\n        tbb = self.cpp_info.components[\"libtbb\"]\n\n        tbb.set_property(\"cmake_target_name\", \"TBB::tbb\")\n        tbb.libs = [lib_name(\"tbb\")]\n        if self.settings.os == \"Windows\":\n            version_info = load(self,\n                os.path.join(self.package_folder, \"include\", \"oneapi\", \"tbb\",\n                             \"version.h\"))\n            binary_version = re.sub(\n                r\".*\" + re.escape(\"#define __TBB_BINARY_VERSION \") +\n                r\"(\\d+).*\",\n                r\"\\1\",\n                version_info,\n                flags=re.MULTILINE | re.DOTALL,\n            )\n            tbb.libs.append(lib_name(f\"tbb{binary_version}\"))\n        if self.settings.os in [\"Linux\", \"FreeBSD\"]:\n            tbb.system_libs = [\"m\", \"dl\", \"rt\", \"pthread\"]\n\n        # tbbmalloc\n        if self.options.tbbmalloc:\n            tbbmalloc = self.cpp_info.components[\"tbbmalloc\"]\n\n            tbbmalloc.set_property(\"cmake_target_name\", \"TBB::tbbmalloc\")\n            tbbmalloc.libs = [lib_name(\"tbbmalloc\")]\n            if self.settings.os in [\"Linux\", \"FreeBSD\"]:\n                tbbmalloc.system_libs = [\"dl\", \"pthread\"]\n\n            # tbbmalloc_proxy\n            if self.options.get_safe(\"tbbproxy\", False):\n                tbbproxy = self.cpp_info.components[\"tbbmalloc_proxy\"]\n\n                tbbproxy.set_property(\"cmake_target_name\", \"TBB::tbbmalloc_proxy\")\n                tbbproxy.libs = [lib_name(\"tbbmalloc_proxy\")]\n                tbbproxy.requires = [\"tbbmalloc\"]\n                if self.settings.os in [\"Linux\", \"FreeBSD\"]:\n                    tbbproxy.system_libs = [\"m\", \"dl\", \"pthread\"]\n\n        # TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed\n        self.cpp_info.names[\"cmake_find_package\"] = \"TBB\"\n        self.cpp_info.names[\"cmake_find_package_multi\"] = \"TBB\"\n        self.cpp_info.names[\"pkg_config\"] = \"tbb\"\n        tbb.names[\"cmake_find_package\"] = \"tbb\"\n        tbb.names[\"cmake_find_package_multi\"] = \"tbb\"\n", "path": "recipes/onetbb/all/conanfile.py"}]}