We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[feature] Consider using CMake's `include_guard()` in `conan_toolchain.cmake`
Right now at the beginning of `conan_toolchain.cmake` `CMakeToolchain` generates:

```cmake
# Avoid including toolchain file several times (bad if appending to variables like
#   CMAKE_CXX_FLAGS. See https://github.com/android/ndk/issues/323
if(CONAN_TOOLCHAIN_INCLUDED)
  return()
endif()
set(CONAN_TOOLCHAIN_INCLUDED TRUE)
```

When minimum version of CMake (3.10) will not be an issue anymore please consider using: https://cmake.org/cmake/help/latest/command/include_guard.html

- [x] I've read the [CONTRIBUTING guide](https://github.com/conan-io/conan/blob/develop/.github/CONTRIBUTING.md).


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `conan/tools/cmake/base.py`
Content:
```
1 import textwrap
2 from collections import OrderedDict
3 
4 import six
5 from jinja2 import DictLoader, Environment
6 
7 from conans.util.files import save
8 
9 
10 class Variables(OrderedDict):
11     _configuration_types = None  # Needed for py27 to avoid infinite recursion
12 
13     def __init__(self):
14         super(Variables, self).__init__()
15         self._configuration_types = {}
16 
17     def __getattribute__(self, config):
18         try:
19             return super(Variables, self).__getattribute__(config)
20         except AttributeError:
21             return self._configuration_types.setdefault(config, OrderedDict())
22 
23     @property
24     def configuration_types(self):
25         # Reverse index for the configuration_types variables
26         ret = OrderedDict()
27         for conf, definitions in self._configuration_types.items():
28             for k, v in definitions.items():
29                 ret.setdefault(k, []).append((conf, v))
30         return ret
31 
32     def quote_preprocessor_strings(self):
33         for key, var in self.items():
34             if isinstance(var, six.string_types):
35                 self[key] = '"{}"'.format(var)
36         for config, data in self._configuration_types.items():
37             for key, var in data.items():
38                 if isinstance(var, six.string_types):
39                     data[key] = '"{}"'.format(var)
40 
41 
42 class CMakeToolchainBase(object):
43     filename = "conan_toolchain.cmake"
44 
45     _toolchain_macros_tpl = textwrap.dedent("""
46         {% macro iterate_configs(var_config, action) -%}
47             {% for it, values in var_config.items() -%}
48                 {%- set genexpr = namespace(str='') %}
49                 {%- for conf, value in values -%}
50                     {%- set genexpr.str = genexpr.str +
51                                           '$<IF:$<CONFIG:' + conf + '>,' + value|string + ',' %}
52                     {%- if loop.last %}{% set genexpr.str = genexpr.str + '""' -%}{%- endif -%}
53                 {%- endfor -%}
54                 {% for i in range(values|count) %}{%- set genexpr.str = genexpr.str + '>' %}
55                 {%- endfor -%}
56                 {% if action=='set' %}
57                 set({{ it }} {{ genexpr.str }} CACHE STRING
58                     "Variable {{ it }} conan-toolchain defined")
59                 {% elif action=='add_definitions' %}
60                 add_definitions(-D{{ it }}={{ genexpr.str }})
61                 {% endif %}
62             {%- endfor %}
63         {% endmacro %}
64         """)
65 
66     _base_toolchain_tpl = textwrap.dedent("""
67         {% import 'toolchain_macros' as toolchain_macros %}
68 
69         # Conan automatically generated toolchain file
70         # DO NOT EDIT MANUALLY, it will be overwritten
71 
72         # Avoid including toolchain file several times (bad if appending to variables like
73         #   CMAKE_CXX_FLAGS. See https://github.com/android/ndk/issues/323
74         if(CONAN_TOOLCHAIN_INCLUDED)
75           return()
76         endif()
77         set(CONAN_TOOLCHAIN_INCLUDED TRUE)
78 
79         {% block before_try_compile %}
80             {# build_type (Release, Debug, etc) is only defined for single-config generators #}
81             {%- if build_type %}
82             set(CMAKE_BUILD_TYPE "{{ build_type }}" CACHE STRING "Choose the type of build." FORCE)
83             {%- endif %}
84         {% endblock %}
85 
86         get_property( _CMAKE_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE )
87         if(_CMAKE_IN_TRY_COMPILE)
88             message(STATUS "Running toolchain IN_TRY_COMPILE")
89             return()
90         endif()
91 
92         message("Using Conan toolchain through ${CMAKE_TOOLCHAIN_FILE}.")
93 
94         {% block main %}
95             # We are going to adjust automagically many things as requested by Conan
96             #   these are the things done by 'conan_basic_setup()'
97             set(CMAKE_EXPORT_NO_PACKAGE_REGISTRY ON)
98             {%- if find_package_prefer_config %}
99             set(CMAKE_FIND_PACKAGE_PREFER_CONFIG {{ find_package_prefer_config }})
100             {%- endif %}
101             # To support the cmake_find_package generators
102             {% if cmake_module_path -%}
103             set(CMAKE_MODULE_PATH {{ cmake_module_path }} ${CMAKE_MODULE_PATH})
104             {%- endif %}
105             {% if cmake_prefix_path -%}
106             set(CMAKE_PREFIX_PATH {{ cmake_prefix_path }} ${CMAKE_PREFIX_PATH})
107             {%- endif %}
108         {% endblock %}
109 
110         {% if shared_libs -%}
111         message(STATUS "Conan toolchain: Setting BUILD_SHARED_LIBS= {{ shared_libs }}")
112         set(BUILD_SHARED_LIBS {{ shared_libs }})
113         {%- endif %}
114 
115         {% if parallel -%}
116         set(CONAN_CXX_FLAGS "${CONAN_CXX_FLAGS} {{ parallel }}")
117         set(CONAN_C_FLAGS "${CONAN_C_FLAGS} {{ parallel }}")
118         {%- endif %}
119 
120         {% if cppstd -%}
121         message(STATUS "Conan C++ Standard {{ cppstd }} with extensions {{ cppstd_extensions }}}")
122         set(CMAKE_CXX_STANDARD {{ cppstd }})
123         set(CMAKE_CXX_EXTENSIONS {{ cppstd_extensions }})
124         {%- endif %}
125 
126         set(CMAKE_CXX_FLAGS_INIT "${CONAN_CXX_FLAGS}" CACHE STRING "" FORCE)
127         set(CMAKE_C_FLAGS_INIT "${CONAN_C_FLAGS}" CACHE STRING "" FORCE)
128         set(CMAKE_SHARED_LINKER_FLAGS_INIT "${CONAN_SHARED_LINKER_FLAGS}" CACHE STRING "" FORCE)
129         set(CMAKE_EXE_LINKER_FLAGS_INIT "${CONAN_EXE_LINKER_FLAGS}" CACHE STRING "" FORCE)
130 
131         # Variables
132         {% for it, value in variables.items() %}
133         set({{ it }} "{{ value }}" CACHE STRING "Variable {{ it }} conan-toolchain defined")
134         {%- endfor %}
135         # Variables  per configuration
136         {{ toolchain_macros.iterate_configs(variables_config, action='set') }}
137 
138         # Preprocessor definitions
139         {% for it, value in preprocessor_definitions.items() -%}
140         # add_compile_definitions only works in cmake >= 3.12
141         add_definitions(-D{{ it }}={{ value }})
142         {%- endfor %}
143         # Preprocessor definitions per configuration
144         {{ toolchain_macros.iterate_configs(preprocessor_definitions_config,
145                                             action='add_definitions') }}
146         """)
147 
148     def __init__(self, conanfile, **kwargs):
149         self._conanfile = conanfile
150         self.variables = Variables()
151         self.preprocessor_definitions = Variables()
152 
153         # To find the generated cmake_find_package finders
154         self.cmake_prefix_path = "${CMAKE_BINARY_DIR}"
155         self.cmake_module_path = "${CMAKE_BINARY_DIR}"
156 
157         self.build_type = None
158 
159         self.find_package_prefer_config = "ON"  # assume ON by default if not specified in conf
160         prefer_config = conanfile.conf["tools.cmake.cmaketoolchain"].find_package_prefer_config
161         if prefer_config is not None and prefer_config.lower() in ("false", "0", "off"):
162             self.find_package_prefer_config = "OFF"
163 
164     def _get_templates(self):
165         return {
166             'toolchain_macros': self._toolchain_macros_tpl,
167             'base_toolchain': self._base_toolchain_tpl
168         }
169 
170     def _get_template_context_data(self):
171         """ Returns dict, the context for the '_template_toolchain'
172         """
173         self.preprocessor_definitions.quote_preprocessor_strings()
174 
175         ctxt_toolchain = {
176             "variables": self.variables,
177             "variables_config": self.variables.configuration_types,
178             "preprocessor_definitions": self.preprocessor_definitions,
179             "preprocessor_definitions_config": self.preprocessor_definitions.configuration_types,
180             "cmake_prefix_path": self.cmake_prefix_path,
181             "cmake_module_path": self.cmake_module_path,
182             "build_type": self.build_type,
183             "find_package_prefer_config": self.find_package_prefer_config,
184         }
185         return ctxt_toolchain
186 
187     def generate(self):
188         # Prepare templates to be loaded
189         dict_loader = DictLoader(self._get_templates())
190         env = Environment(loader=dict_loader)
191 
192         ctxt_toolchain = self._get_template_context_data()
193         t = env.get_template(self.filename)
194         content = t.render(**ctxt_toolchain)
195         save(self.filename, content)
196
```
--- 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/conan/tools/cmake/base.py b/conan/tools/cmake/base.py
--- a/conan/tools/cmake/base.py
+++ b/conan/tools/cmake/base.py
@@ -71,10 +71,8 @@
 
         # Avoid including toolchain file several times (bad if appending to variables like
         #   CMAKE_CXX_FLAGS. See https://github.com/android/ndk/issues/323
-        if(CONAN_TOOLCHAIN_INCLUDED)
-          return()
-        endif()
-        set(CONAN_TOOLCHAIN_INCLUDED TRUE)
+        include_guard()
+
 
         {% block before_try_compile %}
             {# build_type (Release, Debug, etc) is only defined for single-config generators #}

{"golden_diff": "diff --git a/conan/tools/cmake/base.py b/conan/tools/cmake/base.py\n--- a/conan/tools/cmake/base.py\n+++ b/conan/tools/cmake/base.py\n@@ -71,10 +71,8 @@\n \n         # Avoid including toolchain file several times (bad if appending to variables like\n         #   CMAKE_CXX_FLAGS. See https://github.com/android/ndk/issues/323\n-        if(CONAN_TOOLCHAIN_INCLUDED)\n-          return()\n-        endif()\n-        set(CONAN_TOOLCHAIN_INCLUDED TRUE)\n+        include_guard()\n+\n \n         {% block before_try_compile %}\n             {# build_type (Release, Debug, etc) is only defined for single-config generators #}\n", "issue": "[feature] Consider using CMake's `include_guard()` in `conan_toolchain.cmake`\nRight now at the beginning of `conan_toolchain.cmake` `CMakeToolchain` generates:\r\n\r\n```cmake\r\n# Avoid including toolchain file several times (bad if appending to variables like\r\n#   CMAKE_CXX_FLAGS. See https://github.com/android/ndk/issues/323\r\nif(CONAN_TOOLCHAIN_INCLUDED)\r\n  return()\r\nendif()\r\nset(CONAN_TOOLCHAIN_INCLUDED TRUE)\r\n```\r\n\r\nWhen minimum version of CMake (3.10) will not be an issue anymore please consider using: https://cmake.org/cmake/help/latest/command/include_guard.html\r\n\r\n- [x] I've read the [CONTRIBUTING guide](https://github.com/conan-io/conan/blob/develop/.github/CONTRIBUTING.md).\r\n\n", "before_files": [{"content": "import textwrap\nfrom collections import OrderedDict\n\nimport six\nfrom jinja2 import DictLoader, Environment\n\nfrom conans.util.files import save\n\n\nclass Variables(OrderedDict):\n    _configuration_types = None  # Needed for py27 to avoid infinite recursion\n\n    def __init__(self):\n        super(Variables, self).__init__()\n        self._configuration_types = {}\n\n    def __getattribute__(self, config):\n        try:\n            return super(Variables, self).__getattribute__(config)\n        except AttributeError:\n            return self._configuration_types.setdefault(config, OrderedDict())\n\n    @property\n    def configuration_types(self):\n        # Reverse index for the configuration_types variables\n        ret = OrderedDict()\n        for conf, definitions in self._configuration_types.items():\n            for k, v in definitions.items():\n                ret.setdefault(k, []).append((conf, v))\n        return ret\n\n    def quote_preprocessor_strings(self):\n        for key, var in self.items():\n            if isinstance(var, six.string_types):\n                self[key] = '\"{}\"'.format(var)\n        for config, data in self._configuration_types.items():\n            for key, var in data.items():\n                if isinstance(var, six.string_types):\n                    data[key] = '\"{}\"'.format(var)\n\n\nclass CMakeToolchainBase(object):\n    filename = \"conan_toolchain.cmake\"\n\n    _toolchain_macros_tpl = textwrap.dedent(\"\"\"\n        {% macro iterate_configs(var_config, action) -%}\n            {% for it, values in var_config.items() -%}\n                {%- set genexpr = namespace(str='') %}\n                {%- for conf, value in values -%}\n                    {%- set genexpr.str = genexpr.str +\n                                          '$<IF:$<CONFIG:' + conf + '>,' + value|string + ',' %}\n                    {%- if loop.last %}{% set genexpr.str = genexpr.str + '\"\"' -%}{%- endif -%}\n                {%- endfor -%}\n                {% for i in range(values|count) %}{%- set genexpr.str = genexpr.str + '>' %}\n                {%- endfor -%}\n                {% if action=='set' %}\n                set({{ it }} {{ genexpr.str }} CACHE STRING\n                    \"Variable {{ it }} conan-toolchain defined\")\n                {% elif action=='add_definitions' %}\n                add_definitions(-D{{ it }}={{ genexpr.str }})\n                {% endif %}\n            {%- endfor %}\n        {% endmacro %}\n        \"\"\")\n\n    _base_toolchain_tpl = textwrap.dedent(\"\"\"\n        {% import 'toolchain_macros' as toolchain_macros %}\n\n        # Conan automatically generated toolchain file\n        # DO NOT EDIT MANUALLY, it will be overwritten\n\n        # Avoid including toolchain file several times (bad if appending to variables like\n        #   CMAKE_CXX_FLAGS. See https://github.com/android/ndk/issues/323\n        if(CONAN_TOOLCHAIN_INCLUDED)\n          return()\n        endif()\n        set(CONAN_TOOLCHAIN_INCLUDED TRUE)\n\n        {% block before_try_compile %}\n            {# build_type (Release, Debug, etc) is only defined for single-config generators #}\n            {%- if build_type %}\n            set(CMAKE_BUILD_TYPE \"{{ build_type }}\" CACHE STRING \"Choose the type of build.\" FORCE)\n            {%- endif %}\n        {% endblock %}\n\n        get_property( _CMAKE_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE )\n        if(_CMAKE_IN_TRY_COMPILE)\n            message(STATUS \"Running toolchain IN_TRY_COMPILE\")\n            return()\n        endif()\n\n        message(\"Using Conan toolchain through ${CMAKE_TOOLCHAIN_FILE}.\")\n\n        {% block main %}\n            # We are going to adjust automagically many things as requested by Conan\n            #   these are the things done by 'conan_basic_setup()'\n            set(CMAKE_EXPORT_NO_PACKAGE_REGISTRY ON)\n            {%- if find_package_prefer_config %}\n            set(CMAKE_FIND_PACKAGE_PREFER_CONFIG {{ find_package_prefer_config }})\n            {%- endif %}\n            # To support the cmake_find_package generators\n            {% if cmake_module_path -%}\n            set(CMAKE_MODULE_PATH {{ cmake_module_path }} ${CMAKE_MODULE_PATH})\n            {%- endif %}\n            {% if cmake_prefix_path -%}\n            set(CMAKE_PREFIX_PATH {{ cmake_prefix_path }} ${CMAKE_PREFIX_PATH})\n            {%- endif %}\n        {% endblock %}\n\n        {% if shared_libs -%}\n        message(STATUS \"Conan toolchain: Setting BUILD_SHARED_LIBS= {{ shared_libs }}\")\n        set(BUILD_SHARED_LIBS {{ shared_libs }})\n        {%- endif %}\n\n        {% if parallel -%}\n        set(CONAN_CXX_FLAGS \"${CONAN_CXX_FLAGS} {{ parallel }}\")\n        set(CONAN_C_FLAGS \"${CONAN_C_FLAGS} {{ parallel }}\")\n        {%- endif %}\n\n        {% if cppstd -%}\n        message(STATUS \"Conan C++ Standard {{ cppstd }} with extensions {{ cppstd_extensions }}}\")\n        set(CMAKE_CXX_STANDARD {{ cppstd }})\n        set(CMAKE_CXX_EXTENSIONS {{ cppstd_extensions }})\n        {%- endif %}\n\n        set(CMAKE_CXX_FLAGS_INIT \"${CONAN_CXX_FLAGS}\" CACHE STRING \"\" FORCE)\n        set(CMAKE_C_FLAGS_INIT \"${CONAN_C_FLAGS}\" CACHE STRING \"\" FORCE)\n        set(CMAKE_SHARED_LINKER_FLAGS_INIT \"${CONAN_SHARED_LINKER_FLAGS}\" CACHE STRING \"\" FORCE)\n        set(CMAKE_EXE_LINKER_FLAGS_INIT \"${CONAN_EXE_LINKER_FLAGS}\" CACHE STRING \"\" FORCE)\n\n        # Variables\n        {% for it, value in variables.items() %}\n        set({{ it }} \"{{ value }}\" CACHE STRING \"Variable {{ it }} conan-toolchain defined\")\n        {%- endfor %}\n        # Variables  per configuration\n        {{ toolchain_macros.iterate_configs(variables_config, action='set') }}\n\n        # Preprocessor definitions\n        {% for it, value in preprocessor_definitions.items() -%}\n        # add_compile_definitions only works in cmake >= 3.12\n        add_definitions(-D{{ it }}={{ value }})\n        {%- endfor %}\n        # Preprocessor definitions per configuration\n        {{ toolchain_macros.iterate_configs(preprocessor_definitions_config,\n                                            action='add_definitions') }}\n        \"\"\")\n\n    def __init__(self, conanfile, **kwargs):\n        self._conanfile = conanfile\n        self.variables = Variables()\n        self.preprocessor_definitions = Variables()\n\n        # To find the generated cmake_find_package finders\n        self.cmake_prefix_path = \"${CMAKE_BINARY_DIR}\"\n        self.cmake_module_path = \"${CMAKE_BINARY_DIR}\"\n\n        self.build_type = None\n\n        self.find_package_prefer_config = \"ON\"  # assume ON by default if not specified in conf\n        prefer_config = conanfile.conf[\"tools.cmake.cmaketoolchain\"].find_package_prefer_config\n        if prefer_config is not None and prefer_config.lower() in (\"false\", \"0\", \"off\"):\n            self.find_package_prefer_config = \"OFF\"\n\n    def _get_templates(self):\n        return {\n            'toolchain_macros': self._toolchain_macros_tpl,\n            'base_toolchain': self._base_toolchain_tpl\n        }\n\n    def _get_template_context_data(self):\n        \"\"\" Returns dict, the context for the '_template_toolchain'\n        \"\"\"\n        self.preprocessor_definitions.quote_preprocessor_strings()\n\n        ctxt_toolchain = {\n            \"variables\": self.variables,\n            \"variables_config\": self.variables.configuration_types,\n            \"preprocessor_definitions\": self.preprocessor_definitions,\n            \"preprocessor_definitions_config\": self.preprocessor_definitions.configuration_types,\n            \"cmake_prefix_path\": self.cmake_prefix_path,\n            \"cmake_module_path\": self.cmake_module_path,\n            \"build_type\": self.build_type,\n            \"find_package_prefer_config\": self.find_package_prefer_config,\n        }\n        return ctxt_toolchain\n\n    def generate(self):\n        # Prepare templates to be loaded\n        dict_loader = DictLoader(self._get_templates())\n        env = Environment(loader=dict_loader)\n\n        ctxt_toolchain = self._get_template_context_data()\n        t = env.get_template(self.filename)\n        content = t.render(**ctxt_toolchain)\n        save(self.filename, content)\n", "path": "conan/tools/cmake/base.py"}], "after_files": [{"content": "import textwrap\nfrom collections import OrderedDict\n\nimport six\nfrom jinja2 import DictLoader, Environment\n\nfrom conans.util.files import save\n\n\nclass Variables(OrderedDict):\n    _configuration_types = None  # Needed for py27 to avoid infinite recursion\n\n    def __init__(self):\n        super(Variables, self).__init__()\n        self._configuration_types = {}\n\n    def __getattribute__(self, config):\n        try:\n            return super(Variables, self).__getattribute__(config)\n        except AttributeError:\n            return self._configuration_types.setdefault(config, OrderedDict())\n\n    @property\n    def configuration_types(self):\n        # Reverse index for the configuration_types variables\n        ret = OrderedDict()\n        for conf, definitions in self._configuration_types.items():\n            for k, v in definitions.items():\n                ret.setdefault(k, []).append((conf, v))\n        return ret\n\n    def quote_preprocessor_strings(self):\n        for key, var in self.items():\n            if isinstance(var, six.string_types):\n                self[key] = '\"{}\"'.format(var)\n        for config, data in self._configuration_types.items():\n            for key, var in data.items():\n                if isinstance(var, six.string_types):\n                    data[key] = '\"{}\"'.format(var)\n\n\nclass CMakeToolchainBase(object):\n    filename = \"conan_toolchain.cmake\"\n\n    _toolchain_macros_tpl = textwrap.dedent(\"\"\"\n        {% macro iterate_configs(var_config, action) -%}\n            {% for it, values in var_config.items() -%}\n                {%- set genexpr = namespace(str='') %}\n                {%- for conf, value in values -%}\n                    {%- set genexpr.str = genexpr.str +\n                                          '$<IF:$<CONFIG:' + conf + '>,' + value|string + ',' %}\n                    {%- if loop.last %}{% set genexpr.str = genexpr.str + '\"\"' -%}{%- endif -%}\n                {%- endfor -%}\n                {% for i in range(values|count) %}{%- set genexpr.str = genexpr.str + '>' %}\n                {%- endfor -%}\n                {% if action=='set' %}\n                set({{ it }} {{ genexpr.str }} CACHE STRING\n                    \"Variable {{ it }} conan-toolchain defined\")\n                {% elif action=='add_definitions' %}\n                add_definitions(-D{{ it }}={{ genexpr.str }})\n                {% endif %}\n            {%- endfor %}\n        {% endmacro %}\n        \"\"\")\n\n    _base_toolchain_tpl = textwrap.dedent(\"\"\"\n        {% import 'toolchain_macros' as toolchain_macros %}\n\n        # Conan automatically generated toolchain file\n        # DO NOT EDIT MANUALLY, it will be overwritten\n\n        # Avoid including toolchain file several times (bad if appending to variables like\n        #   CMAKE_CXX_FLAGS. See https://github.com/android/ndk/issues/323\n        include_guard()\n\n\n        {% block before_try_compile %}\n            {# build_type (Release, Debug, etc) is only defined for single-config generators #}\n            {%- if build_type %}\n            set(CMAKE_BUILD_TYPE \"{{ build_type }}\" CACHE STRING \"Choose the type of build.\" FORCE)\n            {%- endif %}\n        {% endblock %}\n\n        get_property( _CMAKE_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE )\n        if(_CMAKE_IN_TRY_COMPILE)\n            message(STATUS \"Running toolchain IN_TRY_COMPILE\")\n            return()\n        endif()\n\n        message(\"Using Conan toolchain through ${CMAKE_TOOLCHAIN_FILE}.\")\n\n        {% block main %}\n            # We are going to adjust automagically many things as requested by Conan\n            #   these are the things done by 'conan_basic_setup()'\n            set(CMAKE_EXPORT_NO_PACKAGE_REGISTRY ON)\n            {%- if find_package_prefer_config %}\n            set(CMAKE_FIND_PACKAGE_PREFER_CONFIG {{ find_package_prefer_config }})\n            {%- endif %}\n            # To support the cmake_find_package generators\n            {% if cmake_module_path -%}\n            set(CMAKE_MODULE_PATH {{ cmake_module_path }} ${CMAKE_MODULE_PATH})\n            {%- endif %}\n            {% if cmake_prefix_path -%}\n            set(CMAKE_PREFIX_PATH {{ cmake_prefix_path }} ${CMAKE_PREFIX_PATH})\n            {%- endif %}\n        {% endblock %}\n\n        {% if shared_libs -%}\n        message(STATUS \"Conan toolchain: Setting BUILD_SHARED_LIBS= {{ shared_libs }}\")\n        set(BUILD_SHARED_LIBS {{ shared_libs }})\n        {%- endif %}\n\n        {% if parallel -%}\n        set(CONAN_CXX_FLAGS \"${CONAN_CXX_FLAGS} {{ parallel }}\")\n        set(CONAN_C_FLAGS \"${CONAN_C_FLAGS} {{ parallel }}\")\n        {%- endif %}\n\n        {% if cppstd -%}\n        message(STATUS \"Conan C++ Standard {{ cppstd }} with extensions {{ cppstd_extensions }}}\")\n        set(CMAKE_CXX_STANDARD {{ cppstd }})\n        set(CMAKE_CXX_EXTENSIONS {{ cppstd_extensions }})\n        {%- endif %}\n\n        set(CMAKE_CXX_FLAGS_INIT \"${CONAN_CXX_FLAGS}\" CACHE STRING \"\" FORCE)\n        set(CMAKE_C_FLAGS_INIT \"${CONAN_C_FLAGS}\" CACHE STRING \"\" FORCE)\n        set(CMAKE_SHARED_LINKER_FLAGS_INIT \"${CONAN_SHARED_LINKER_FLAGS}\" CACHE STRING \"\" FORCE)\n        set(CMAKE_EXE_LINKER_FLAGS_INIT \"${CONAN_EXE_LINKER_FLAGS}\" CACHE STRING \"\" FORCE)\n\n        # Variables\n        {% for it, value in variables.items() %}\n        set({{ it }} \"{{ value }}\" CACHE STRING \"Variable {{ it }} conan-toolchain defined\")\n        {%- endfor %}\n        # Variables  per configuration\n        {{ toolchain_macros.iterate_configs(variables_config, action='set') }}\n\n        # Preprocessor definitions\n        {% for it, value in preprocessor_definitions.items() -%}\n        # add_compile_definitions only works in cmake >= 3.12\n        add_definitions(-D{{ it }}={{ value }})\n        {%- endfor %}\n        # Preprocessor definitions per configuration\n        {{ toolchain_macros.iterate_configs(preprocessor_definitions_config,\n                                            action='add_definitions') }}\n        \"\"\")\n\n    def __init__(self, conanfile, **kwargs):\n        self._conanfile = conanfile\n        self.variables = Variables()\n        self.preprocessor_definitions = Variables()\n\n        # To find the generated cmake_find_package finders\n        self.cmake_prefix_path = \"${CMAKE_BINARY_DIR}\"\n        self.cmake_module_path = \"${CMAKE_BINARY_DIR}\"\n\n        self.build_type = None\n\n        self.find_package_prefer_config = \"ON\"  # assume ON by default if not specified in conf\n        prefer_config = conanfile.conf[\"tools.cmake.cmaketoolchain\"].find_package_prefer_config\n        if prefer_config is not None and prefer_config.lower() in (\"false\", \"0\", \"off\"):\n            self.find_package_prefer_config = \"OFF\"\n\n    def _get_templates(self):\n        return {\n            'toolchain_macros': self._toolchain_macros_tpl,\n            'base_toolchain': self._base_toolchain_tpl\n        }\n\n    def _get_template_context_data(self):\n        \"\"\" Returns dict, the context for the '_template_toolchain'\n        \"\"\"\n        self.preprocessor_definitions.quote_preprocessor_strings()\n\n        ctxt_toolchain = {\n            \"variables\": self.variables,\n            \"variables_config\": self.variables.configuration_types,\n            \"preprocessor_definitions\": self.preprocessor_definitions,\n            \"preprocessor_definitions_config\": self.preprocessor_definitions.configuration_types,\n            \"cmake_prefix_path\": self.cmake_prefix_path,\n            \"cmake_module_path\": self.cmake_module_path,\n            \"build_type\": self.build_type,\n            \"find_package_prefer_config\": self.find_package_prefer_config,\n        }\n        return ctxt_toolchain\n\n    def generate(self):\n        # Prepare templates to be loaded\n        dict_loader = DictLoader(self._get_templates())\n        env = Environment(loader=dict_loader)\n\n        ctxt_toolchain = self._get_template_context_data()\n        t = env.get_template(self.filename)\n        content = t.render(**ctxt_toolchain)\n        save(self.filename, content)\n", "path": "conan/tools/cmake/base.py"}]}