Repository: conan-io/conan

Issue:
[bug] conan sh environment fails to generate deactivation_file on ubuntu-20.04
### Environment Details (include every applicable attribute)
  * Github VM Ubuntu-20.04 
  * Ubuntu-20.04
  * Compiler N/A
  * up until 1.48
  * 3.10.4

### Steps to reproduce (Include if Applicable)
- Create an Virtual Run, Build or custom environment and save a script.
- Activate that VirtualEnvironment activation script with `source` or `.` on a bash shell
- it fails when running `echo echo Restoring environment >> "{deactivate_file}"`

### Logs (Executed commands with output) (Include/Attach if Applicable)

See the output of this GitHub action:
https://github.com/Ultimaker/Uranium/runs/6198574161?check_suite_focus=true

The script was generated with the following python_requires
https://github.com/Ultimaker/conan-ultimaker-index/blob/CURA-9177_Fix_CI_CD/recipes/PythonVirtualEnvironment/conanfile.py

with this recipe:
https://github.com/Ultimaker/Uranium/blob/CURA-9177_Fix_CI_CT/conanfile.py

In this workflow
https://github.com/Ultimaker/Uranium/blob/b9f291e0af04554ec2d584bb44bfe5c2378e5aea/.github/workflows/unit-tests.yml#L84

It works on most Linux and MacOS shells on which I use this, it just fails on the GitHub VM Ubuntu-20.04 and latest.

> Note:  
> Putting quote marks  around the `echo "echo Restoring environment" >> "{deactivate_file}"` fixes it.
> This seems like a nice first PR for me for your awesome product ;-) Expect my first contribution soon

Discussion:
CLAassistant: [![CLA assistant check](https://cla-assistant.io/pull/badge/not_signed)](https://cla-assistant.io/conan-io/conan?pullRequest=11123) <br/>Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our [Contributor License Agreement](https://cla-assistant.io/conan-io/conan?pullRequest=11123) before we can accept your contribution.<br/><sub>You have signed the CLA already but the status is still pending? Let us [recheck](https://cla-assistant.io/check/conan-io/conan?pullRequest=11123) it.</sub>

Patch:
diff --git a/conan/tools/cmake/cmake.py b/conan/tools/cmake/cmake.py
index e6d04073f..86aa975a6 100644
--- a/conan/tools/cmake/cmake.py
+++ b/conan/tools/cmake/cmake.py
@@ -2,7 +2,7 @@ import os
 import platform
 
 from conan.tools.build import build_jobs
-from conan.tools.cmake.presets import load_cmake_presets
+from conan.tools.cmake.presets import load_cmake_presets, get_configure_preset
 from conan.tools.cmake.utils import is_multi_configuration
 from conan.tools.files import chdir, mkdir
 from conan.tools.files.files import load_toolchain_args
@@ -55,9 +55,11 @@ class CMake(object):
         self._conanfile = conanfile
 
         cmake_presets = load_cmake_presets(conanfile.generators_folder)
-        self._generator = cmake_presets["configurePresets"][0]["generator"]
-        self._toolchain_file = cmake_presets["configurePresets"][0]["toolchainFile"]
-        self._cache_variables = cmake_presets["configurePresets"][0]["cacheVariables"]
+        configure_preset = get_configure_preset(cmake_presets,
+                                                conanfile.settings.get_safe("build_type"))
+        self._generator = configure_preset["generator"]
+        self._toolchain_file = configure_preset["toolchainFile"]
+        self._cache_variables = configure_preset["cacheVariables"]
 
         self._cmake_program = "cmake"  # Path to CMake should be handled by environment
 
diff --git a/conan/tools/cmake/layout.py b/conan/tools/cmake/layout.py
index a24e6cde6..9d5481193 100644
--- a/conan/tools/cmake/layout.py
+++ b/conan/tools/cmake/layout.py
@@ -1,5 +1,3 @@
-import os
-
 from conans.errors import ConanException
 
 
@@ -21,12 +19,11 @@ def cmake_layout(conanfile, generator=None, src_folder="."):
         raise ConanException("'build_type' setting not defined, it is necessary for cmake_layout()")
     if multi:
         conanfile.folders.build = "build"
-        conanfile.folders.generators = "build/conan"
     else:
         build_type = build_type.lower()
         conanfile.folders.build = "cmake-build-{}".format(build_type)
-        conanfile.folders.generators = os.path.join(conanfile.folders.build, "conan")
 
+    conanfile.folders.generators = "build/generators"
     conanfile.cpp.source.includedirs = ["include"]
 
     if multi:
diff --git a/conan/tools/cmake/presets.py b/conan/tools/cmake/presets.py
index dab339cad..79e02b101 100644
--- a/conan/tools/cmake/presets.py
+++ b/conan/tools/cmake/presets.py
@@ -3,21 +3,27 @@ import os
 import platform
 
 from conan.tools.cmake.utils import is_multi_configuration
+from conans.errors import ConanException
 from conans.util.files import save, load
 
 
 def _add_build_preset(conanfile, multiconfig):
     build_type = conanfile.settings.get_safe("build_type")
-    ret = {"name": "Build {}".format(build_type),
-           "configurePreset": "default"}
+    configure_preset_name = _configure_preset_name(build_type, multiconfig)
+    ret = {"name": build_type,
+           "configurePreset": configure_preset_name}
     if multiconfig:
         ret["configuration"] = build_type
     return ret
 
 
+def _configure_preset_name(build_type, multiconfig):
+    return "default" if not build_type or multiconfig else build_type
+
+
 def _add_configure_preset(conanfile, generator, cache_variables, toolchain_file, multiconfig):
     build_type = conanfile.settings.get_safe("build_type")
-    name = "default" if not build_type or multiconfig else build_type
+    name = _configure_preset_name(build_type, multiconfig)
     if not multiconfig:
         cache_variables["CMAKE_BUILD_TYPE"] = build_type
     ret = {
@@ -41,10 +47,7 @@ def _contents(conanfile, toolchain_file, cache_variables, generator):
            "cmakeMinimumRequired": {"major": 3, "minor": 15, "patch": 0},
            "configurePresets": [],
            "buildPresets": [],
-           "testPresets": [{
-              "name": "default",
-              "configurePreset": "default"
-           }]
+           "testPresets": []
           }
     multiconfig = is_multi_configuration(generator)
     ret["buildPresets"].append(_add_build_preset(conanfile, multiconfig))
@@ -61,24 +64,65 @@ def write_cmake_presets(conanfile, toolchain_file, generator):
         if cmake_make_program:
             cmake_make_program = cmake_make_program.replace("\\", "/")
             cache_variables["CMAKE_MAKE_PROGRAM"] = cmake_make_program
+    cache_variables["CMAKE_POLICY_DEFAULT_CMP0091"] = "NEW"
 
     preset_path = os.path.join(conanfile.generators_folder, "CMakePresets.json")
     multiconfig = is_multi_configuration(generator)
     build_type = conanfile.settings.get_safe("build_type")
-    if multiconfig and os.path.exists(preset_path):
+
+    if os.path.exists(preset_path):
         # We append the new configuration making sure that we don't overwrite it
         data = json.loads(load(preset_path))
-        build_presets = data["buildPresets"]
-        already_exist = any([b["configuration"] for b in build_presets if b == build_type])
-        if not already_exist:
-            data["buildPresets"].append(_add_build_preset(conanfile, multiconfig))
+        if multiconfig:
+            build_presets = data["buildPresets"]
+            already_exist = any([b["configuration"] for b in build_presets if b == build_type])
+            if not already_exist:
+                data["buildPresets"].append(_add_build_preset(conanfile, multiconfig))
+        else:
+            configure_presets = data["configurePresets"]
+            already_exist = any([c["name"]
+                                 for c in configure_presets
+                                 if c["name"] == _configure_preset_name(build_type, multiconfig)])
+            if not already_exist:
+                conf_preset = _add_configure_preset(conanfile, generator, cache_variables,
+                                                    toolchain_file, multiconfig)
+                data["configurePresets"].append(conf_preset)
+                data["buildPresets"].append(_add_build_preset(conanfile, multiconfig))
     else:
         data = _contents(conanfile, toolchain_file, cache_variables, generator)
 
     data = json.dumps(data, indent=4)
     save(preset_path, data)
 
+    # Try to save the CMakeUserPresets.json if layout declared and CMakeLists.txt found
+    if conanfile.source_folder and conanfile.source_folder != conanfile.generators_folder:
+        if os.path.exists(os.path.join(conanfile.source_folder, "CMakeLists.txt")):
+            user_presets_path = os.path.join(conanfile.source_folder, "CMakeUserPresets.json")
+            if not os.path.exists(user_presets_path):
+                data = {"version": 4, "include": [preset_path]}
+                data = json.dumps(data, indent=4)
+                save(user_presets_path, data)
+
 
 def load_cmake_presets(folder):
     tmp = load(os.path.join(folder, "CMakePresets.json"))
     return json.loads(tmp)
+
+
+def get_configure_preset(cmake_presets, build_type):
+
+    # Do we find a preset for the current build type?
+    for preset in cmake_presets["configurePresets"]:
+        if preset["name"] == build_type:
+            return preset
+
+    # In case of multi-config generator or None build_type
+    for preset in cmake_presets["configurePresets"]:
+        if preset["name"] == "default":
+            return preset
+
+    # FIXME: Might be an issue if someone perform several conan install that involves different
+    #        CMake generators (multi and single config). Would be impossible to determine which
+    #        is the correct configurePreset because the generator IS in the configure preset.
+
+    raise ConanException("Not available configurePreset for the build_type {}".format(build_type))
diff --git a/conan/tools/cmake/toolchain/blocks.py b/conan/tools/cmake/toolchain/blocks.py
index 74bff2ef9..74a5a8967 100644
--- a/conan/tools/cmake/toolchain/blocks.py
+++ b/conan/tools/cmake/toolchain/blocks.py
@@ -10,7 +10,6 @@ from conan.tools.apple.apple import is_apple_os, to_apple_arch
 from conan.tools.build import build_jobs
 from conan.tools.build.cross_building import cross_building
 from conan.tools.cmake.toolchain import CONAN_TOOLCHAIN_FILENAME
-from conan.tools.cmake.utils import is_multi_configuration
 from conan.tools.intel import IntelCC
 from conan.tools.microsoft.visual import is_msvc, msvc_version_to_toolset_version
 from conans.errors import ConanException
@@ -93,7 +92,10 @@ class VSRuntimeBlock(Block):
             {% set genexpr.str = genexpr.str +
                                   '$<$<CONFIG:' + config + '>:' + value|string + '>' %}
         {% endfor %}
-        set(CMAKE_POLICY_DEFAULT_CMP0091 NEW)
+        cmake_policy(GET CMP0091 POLICY_CMP0091)
+        if(NOT "${POLICY_CMP0091}" STREQUAL NEW)
+            message(FATAL_ERROR "The CMake policy CMP0091 must be NEW, but is '${POLICY_CMP0091}'")
+        endif()
         set(CMAKE_MSVC_RUNTIME_LIBRARY "{{ genexpr.str }}")
         """)
 
@@ -689,37 +691,39 @@ class GenericSystemBlock(Block):
         settings = self._conanfile.settings
         compiler = settings.get_safe("compiler")
         compiler_base = settings.get_safe("compiler.base")
+        toolset = None
         if compiler == "Visual Studio":
-            subs_toolset = settings.get_safe("compiler.toolset")
-            if subs_toolset:
-                return subs_toolset
+            toolset = settings.get_safe("compiler.toolset")
         elif compiler == "intel" and compiler_base == "Visual Studio" and "Visual" in generator:
             # TODO: This intel toolset needs to be validated too
             compiler_version = settings.get_safe("compiler.version")
             if compiler_version:
                 compiler_version = compiler_version if "." in compiler_version else \
                     "%s.0" % compiler_version
-                return "Intel C++ Compiler " + compiler_version
+                toolset = "Intel C++ Compiler " + compiler_version
         elif compiler == "intel-cc":
             return IntelCC(self._conanfile).ms_toolset
         elif compiler == "msvc":
-            subs_toolset = settings.get_safe("compiler.toolset")
-            if subs_toolset:
-                return subs_toolset
-            compiler_version = str(settings.compiler.version)
-            compiler_update = str(settings.compiler.update)
-            if compiler_update != "None":  # It is full one(19.28), not generic 19.2X
-                # The equivalent of compiler 19.26 is toolset 14.26
-                return "version=14.{}{}".format(compiler_version[-1], compiler_update)
-            else:
-                return msvc_version_to_toolset_version(compiler_version)
+            toolset = settings.get_safe("compiler.toolset")
+            if toolset is None:
+                compiler_version = str(settings.compiler.version)
+                compiler_update = str(settings.compiler.update)
+                if compiler_update != "None":  # It is full one(19.28), not generic 19.2X
+                    # The equivalent of compiler 19.26 is toolset 14.26
+                    toolset = "version=14.{}{}".format(compiler_version[-1], compiler_update)
+                else:
+                    toolset = msvc_version_to_toolset_version(compiler_version)
         elif compiler == "clang":
             if generator and "Visual" in generator:
                 if "Visual Studio 16" in generator:
-                    return "ClangCL"
+                    toolset = "ClangCL"
                 else:
                     raise ConanException("CMakeToolchain compiler=clang only supported VS 16")
-        return None
+        toolset_arch = self._conanfile.conf.get("tools.cmake.cmaketoolchain:toolset_arch")
+        if toolset_arch is not None:
+            toolset_arch = "host={}".format(toolset_arch)
+            toolset = toolset_arch if toolset is None else "{},{}".format(toolset, toolset_arch)
+        return toolset
 
     def _get_generator_platform(self, generator):
         settings = self._conanfile.settings
diff --git a/conan/tools/env/environment.py b/conan/tools/env/environment.py
index fd57f3069..88c008e92 100644
--- a/conan/tools/env/environment.py
+++ b/conan/tools/env/environment.py
@@ -354,7 +354,7 @@ class EnvVars:
         deactivate_file = os.path.join(filepath, "deactivate_{}".format(filename))
         deactivate = textwrap.dedent("""\
            echo Capturing current environment in "{deactivate_file}"
-           echo echo Restoring environment >> "{deactivate_file}"
+           echo "echo Restoring environment" >> "{deactivate_file}"
            for v in {vars}
            do
                value=$(printenv $v)
diff --git a/conan/tools/gnu/autotools.py b/conan/tools/gnu/autotools.py
index af335a46b..dc93aca2e 100644
--- a/conan/tools/gnu/autotools.py
+++ b/conan/tools/gnu/autotools.py
@@ -6,6 +6,7 @@ from conans.client.subsystems import subsystem_path, deduce_subsystem
 from conans.client.build import join_arguments
 from conans.tools import args_to_string
 from conan.tools.files import chdir
+from conans.util.runners import check_output_runner
 
 
 class Autotools(object):
@@ -63,11 +64,41 @@ class Autotools(object):
         command = join_arguments([make_program, target, str_args, jobs])
         self._conanfile.run(command)
 
+    def _fix_osx_shared_install_name(self):
+
+        def _osx_collect_dylibs(lib_folder):
+            return [f for f in os.listdir(lib_folder) if f.endswith(".dylib")
+                    and not os.path.islink(os.path.join(lib_folder, f))]
+
+        def _fix_install_name(lib_name, lib_folder):
+            command = "install_name_tool -id @rpath/{} {}".format(lib_name, os.path.join(lib_folder,
+                                                                                         lib_name))
+            self._conanfile.run(command)
+
+        def _is_modified_install_name(lib_name, lib_folder):
+            """
+            Check that the user did not change the default install_name using the install_name
+            linker flag in that case we do not touch this field
+            """
+            command = "otool -D {}".format(os.path.join(lib_folder, lib_name))
+            out = check_output_runner(command).strip().split(":")[1]
+            return False if str(os.path.join(lib_folder, shared_lib)) in out else True
+
+        libdirs = getattr(self._conanfile.cpp.package, "libdirs")
+        for folder in libdirs:
+            full_folder = os.path.join(self._conanfile.package_folder, folder)
+            shared_libs = _osx_collect_dylibs(full_folder)
+            for shared_lib in shared_libs:
+                if not _is_modified_install_name(shared_lib, full_folder):
+                    _fix_install_name(shared_lib, full_folder)
+
     def install(self):
         # FIXME: we have to run configure twice because the local flow won't work otherwise
         #  because there's no package_folder until the package step
         self.configure()
         self.make(target="install")
+        if self._conanfile.settings.get_safe("os") == "Macos" and self._conanfile.options.get_safe("shared", False):
+            self._fix_osx_shared_install_name()
 
     def autoreconf(self, args=None):
         command = ["autoreconf"]
diff --git a/conan/tools/gnu/autotoolsdeps.py b/conan/tools/gnu/autotoolsdeps.py
index c42260fc4..dbc05de2e 100644
--- a/conan/tools/gnu/autotoolsdeps.py
+++ b/conan/tools/gnu/autotoolsdeps.py
@@ -8,19 +8,32 @@ class AutotoolsDeps:
     def __init__(self, conanfile):
         self._conanfile = conanfile
         self._environment = None
+        self._ordered_deps = []
         check_using_build_profile(self._conanfile)
 
+    @property
+    def ordered_deps(self):
+        if not self._ordered_deps:
+            deps = self._conanfile.dependencies.host.topological_sort
+            self._ordered_deps = [dep for dep in reversed(deps.values())]
+        return self._ordered_deps
+
     def _get_cpp_info(self):
         ret = NewCppInfo()
-
-        deps = self._conanfile.dependencies.host.topological_sort
-        for dep in reversed(deps.values()):
+        for dep in self.ordered_deps:
             dep_cppinfo = dep.cpp_info.aggregated_components()
             # In case we have components, aggregate them, we do not support isolated
             # "targets" with autotools
             ret.merge(dep_cppinfo)
         return ret
 
+    def _rpaths_flags(self):
+        flags = []
+        for dep in self.ordered_deps:
+            flags.extend(["-Wl,-rpath -Wl,{}".format(libdir) for libdir in dep.cpp_info.libdirs
+                          if dep.options.get_safe("shared", False)])
+        return flags
+
     @property
     def environment(self):
         # TODO: Seems we want to make this uniform, equal to other generators
@@ -39,6 +52,10 @@ class AutotoolsDeps:
             ldflags.extend(flags.framework_paths)
             ldflags.extend(flags.lib_paths)
 
+            ## set the rpath in Macos so that the library are found in the configure step
+            if self._conanfile.settings.get_safe("os") == "Macos":
+                ldflags.extend(self._rpaths_flags())
+
             # libs
             libs = flags.libs
             libs.extend(flags.system_libs)
diff --git a/conans/__init__.py b/conans/__init__.py
index 1ddb5e1ea..0aaa67ea0 100644
--- a/conans/__init__.py
+++ b/conans/__init__.py
@@ -20,4 +20,4 @@ OAUTH_TOKEN = "oauth_token"
 SERVER_CAPABILITIES = [COMPLEX_SEARCH_CAPABILITY, REVISIONS]  # Server is always with revisions
 DEFAULT_REVISION_V1 = "0"
 
-__version__ = '1.48.0-dev'
+__version__ = '1.49.0-dev'
diff --git a/conans/client/generators/markdown.py b/conans/client/generators/markdown.py
index da004c6e0..962976f2b 100644
--- a/conans/client/generators/markdown.py
+++ b/conans/client/generators/markdown.py
@@ -308,7 +308,6 @@ buildsystem_autotools_tpl = textwrap.dedent("""
     # set the environment variables for Autotools
     $ source conanautotoolstoolchain.sh
 
-    # You will have to set the PKG_CONFIG_PATH to where Conan created the {{ pkgconfig_variables.pkg_name }}.pc file
     $ export CPPFLAGS="$CPPFLAGS $(pkg-config --cflags {{ requirement.ref.name }})"
     $ export LIBS="$LIBS $(pkg-config --libs-only-l {{ requirement.ref.name }})"
     $ export LDFLAGS="$LDFLAGS $(pkg-config --libs-only-L --libs-only-other {{ requirement.ref.name }})"
diff --git a/conans/client/migrations_settings.py b/conans/client/migrations_settings.py
index b489458a5..e4d3b3911 100644
--- a/conans/client/migrations_settings.py
+++ b/conans/client/migrations_settings.py
@@ -3556,3 +3556,5 @@ cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20, 23, gnu23]
 """
 
 settings_1_48_0 = settings_1_47_0
+
+settings_1_49_0 = settings_1_48_0
diff --git a/conans/model/version.py b/conans/model/version.py
index 963702743..af6df5c77 100644
--- a/conans/model/version.py
+++ b/conans/model/version.py
@@ -9,7 +9,7 @@ class Version(str):
     version_pattern = re.compile('[.-]')
 
     def __new__(cls, content):
-        return str.__new__(cls, content.strip())
+        return str.__new__(cls, str(content).strip())
 
     @property
     def as_list(self):


Test patch:
diff --git a/conans/test/conftest.py b/conans/test/conftest.py
index 05b38f19d..6a1db19e7 100644
--- a/conans/test/conftest.py
+++ b/conans/test/conftest.py
@@ -72,6 +72,11 @@ tools_locations = {
             "path": {'Windows': 'C:/cmake/cmake-3.19.7-win64-x64/bin',
                      'Darwin': '/Users/jenkins/cmake/cmake-3.19.7/bin',
                      'Linux': '/usr/share/cmake-3.19.7/bin'}
+        },
+        "3.23": {
+            "path": {'Windows': 'C:/cmake/cmake-3.23.1-win64-x64/bin',
+                     'Darwin': '/Users/jenkins/cmake/cmake-3.23.1/bin',
+                     'Linux': '/usr/share/cmake-3.23.1/bin'}
         }
     },
     'ninja': {
diff --git a/conans/test/functional/layout/test_build_system_layout_helpers.py b/conans/test/functional/layout/test_build_system_layout_helpers.py
index 2454c3638..93e6b4859 100644
--- a/conans/test/functional/layout/test_build_system_layout_helpers.py
+++ b/conans/test/functional/layout/test_build_system_layout_helpers.py
@@ -168,7 +168,7 @@ def test_cmake_layout_external_sources():
 
     # Local flow
     client.run("install . foo/1.0 -s os=Linux")
-    assert os.path.exists(os.path.join(client.current_folder, "cmake-build-release", "conan", "generate.txt"))
+    assert os.path.exists(os.path.join(client.current_folder, "build", "generators", "generate.txt"))
     client.run("source .")
     assert os.path.exists(os.path.join(client.current_folder, "src", "source.txt"))
     client.run("build .")
diff --git a/conans/test/functional/layout/test_local_commands.py b/conans/test/functional/layout/test_local_commands.py
index cdab68714..bd036d617 100644
--- a/conans/test/functional/layout/test_local_commands.py
+++ b/conans/test/functional/layout/test_local_commands.py
@@ -372,8 +372,7 @@ def test_start_dir_failure():
     c = TestClient()
     c.save(pkg_cmake("dep", "0.1"))
     c.run("install .")
-    build = "build" if platform.system() == "Windows" else "cmake-build-release"
-    expected_path = os.path.join(c.current_folder, build, "conan", "conan_toolchain.cmake")
+    expected_path = os.path.join(c.current_folder, "build", "generators", "conan_toolchain.cmake")
     assert os.path.exists(expected_path)
     os.unlink(expected_path)
     with c.chdir("build"):
diff --git a/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps.py b/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps.py
index bcd5b7aed..e165bac75 100644
--- a/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps.py
+++ b/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps.py
@@ -375,6 +375,6 @@ def test_system_dep():
 
     client.run("install consumer")
     if platform.system() != "Windows":
-        data = os.path.join("consumer/cmake-build-release/conan/mylib-release-x86_64-data.cmake")
+        data = os.path.join("consumer/build/generators/mylib-release-x86_64-data.cmake")
         contents = client.load(data)
         assert 'set(ZLIB_FIND_MODE "")' in contents
diff --git a/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_aliases.py b/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_aliases.py
index a03947dae..a98179656 100644
--- a/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_aliases.py
+++ b/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_aliases.py
@@ -38,7 +38,8 @@ def test_global_alias():
     """)
 
     cmakelists = textwrap.dedent("""
-    cmake_minimum_required(VERSION 2.8)
+    cmake_minimum_required(VERSION 3.15)
+    project(test)
 
     find_package(hello REQUIRED)
     get_target_property(link_libraries hello INTERFACE_LINK_LIBRARIES)
@@ -71,7 +72,8 @@ def test_component_alias():
     """)
 
     cmakelists = textwrap.dedent("""
-    cmake_minimum_required(VERSION 2.8)
+    cmake_minimum_required(VERSION VERSION 3.15)
+    project(test)
 
     find_package(hello REQUIRED)
     get_target_property(link_libraries hola::adios INTERFACE_LINK_LIBRARIES)
@@ -104,7 +106,8 @@ def test_custom_name():
     """)
 
     cmakelists = textwrap.dedent("""
-    cmake_minimum_required(VERSION 2.8)
+    cmake_minimum_required(VERSION 3.15)
+    project(test)
 
     find_package(hello REQUIRED)
     get_target_property(link_libraries hello INTERFACE_LINK_LIBRARIES)
@@ -137,7 +140,9 @@ def test_collide_global_alias():
     """)
 
     cmakelists = textwrap.dedent("""
-    cmake_minimum_required(VERSION 2.8)
+    cmake_minimum_required(VERSION 3.15)
+    project(test)
+
     find_package(hello REQUIRED)
     """)
 
@@ -166,7 +171,8 @@ def test_collide_component_alias():
     """)
 
     cmakelists = textwrap.dedent("""
-    cmake_minimum_required(VERSION 2.8)
+    cmake_minimum_required(VERSION 3.15)
+    project(test)
 
     find_package(hello REQUIRED)
     """)
diff --git a/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_and_linker_flags.py b/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_and_linker_flags.py
index 9ddb81728..825a02082 100644
--- a/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_and_linker_flags.py
+++ b/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_and_linker_flags.py
@@ -51,7 +51,7 @@ def test_shared_link_flags():
     client.run("new hello/1.0 -m cmake_lib")
     client.save({"conanfile.py": conanfile})
     client.run("create .")
-    t = os.path.join("test_package", "cmake-build-release", "conan", "hello-release-x86_64-data.cmake")
+    t = os.path.join("test_package", "build", "generators", "hello-release-x86_64-data.cmake")
     target_data_cmake_content = client.load(t)
     assert 'set(hello_SHARED_LINK_FLAGS_RELEASE "-z now;-z relro")' in target_data_cmake_content
     assert 'set(hello_EXE_LINK_FLAGS_RELEASE "-z now;-z relro")' in target_data_cmake_content
diff --git a/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_components.py b/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_components.py
index b21168241..a6f56c3ac 100644
--- a/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_components.py
+++ b/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_components.py
@@ -192,8 +192,9 @@ def test_components_system_libs():
     """)
 
     cmakelists = textwrap.dedent("""
+        cmake_minimum_required(VERSION 3.15)
         project(consumer)
-        cmake_minimum_required(VERSION 3.1)
+
         find_package(requirement)
         get_target_property(tmp_libs requirement::component INTERFACE_LINK_LIBRARIES)
         get_target_property(tmp_options requirement::component INTERFACE_LINK_OPTIONS)
@@ -249,8 +250,8 @@ def test_components_exelinkflags():
     """)
 
     cmakelists = textwrap.dedent("""
+        cmake_minimum_required(VERSION 3.15)
         project(consumer)
-        cmake_minimum_required(VERSION 3.1)
         find_package(requirement)
         get_target_property(tmp_options requirement::component INTERFACE_LINK_OPTIONS)
         message("component options: ${tmp_options}")
@@ -303,8 +304,8 @@ def test_components_sharedlinkflags():
     """)
 
     cmakelists = textwrap.dedent("""
+        cmake_minimum_required(VERSION 3.15)
         project(consumer)
-        cmake_minimum_required(VERSION 3.1)
         find_package(requirement)
         get_target_property(tmp_options requirement::component INTERFACE_LINK_OPTIONS)
         message("component options: ${tmp_options}")
diff --git a/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_components_names.py b/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_components_names.py
index 33b89f8a5..6f71ded87 100644
--- a/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_components_names.py
+++ b/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_components_names.py
@@ -194,7 +194,7 @@ def create_chat(client, components, package_info, cmake_find, test_cmake_find):
     test_cmakelists = textwrap.dedent("""
         set(CMAKE_CXX_COMPILER_WORKS 1)
         set(CMAKE_CXX_ABI_COMPILED 1)
-        cmake_minimum_required(VERSION 3.0)
+        cmake_minimum_required(VERSION 3.15)
         project(PackageTest CXX)
 
         %s
@@ -586,10 +586,10 @@ class TestComponentsCMakeGenerators:
                     self.cpp_info.components["1"].libs = ["{name}"]
             """)
         basic_cmake = textwrap.dedent("""
+            cmake_minimum_required(VERSION 3.15)
             set(CMAKE_CXX_COMPILER_WORKS 1)
             set(CMAKE_CXX_ABI_COMPILED 1)
             project(middle CXX)
-            cmake_minimum_required(VERSION 3.1)
             add_library({name} {name}.cpp)
             """)
         client = TestClient()
@@ -599,10 +599,10 @@ class TestComponentsCMakeGenerators:
                          "src/CMakeLists.txt": basic_cmake.format(name=name)})
             client.run("create . {name}/1.0@".format(name=name))
         middle_cmakelists = textwrap.dedent("""
+            cmake_minimum_required(VERSION 3.15)
             set(CMAKE_CXX_COMPILER_WORKS 1)
             set(CMAKE_CXX_ABI_COMPILED 1)
             project(middle CXX)
-            cmake_minimum_required(VERSION 3.1)
 
             find_package(expected)
             find_package(variant)
@@ -665,10 +665,10 @@ class TestComponentsCMakeGenerators:
                     self.run(cmd, env="conanrun")
             """)
         cmakelists = textwrap.dedent("""
+            cmake_minimum_required(VERSION 3.15)
             set(CMAKE_CXX_COMPILER_WORKS 1)
             set(CMAKE_CXX_ABI_COMPILED 1)
             project(consumer CXX)
-            cmake_minimum_required(VERSION 3.1)
 
             find_package(middle)
 
diff --git a/conans/test/functional/toolchains/cmake/cmakedeps/test_link_order.py b/conans/test/functional/toolchains/cmake/cmakedeps/test_link_order.py
index c50e31b26..bbfb66c3b 100644
--- a/conans/test/functional/toolchains/cmake/cmakedeps/test_link_order.py
+++ b/conans/test/functional/toolchains/cmake/cmakedeps/test_link_order.py
@@ -285,7 +285,7 @@ def _create_find_package_project(client):
             CMakeToolchain
             """),
         'CMakeLists.txt': textwrap.dedent("""
-            cmake_minimum_required(VERSION 2.8.12)
+            cmake_minimum_required(VERSION 3.15)
             project(executable CXX)
 
             find_package(libD)
diff --git a/conans/test/functional/toolchains/cmake/test_cmake_toolchain.py b/conans/test/functional/toolchains/cmake/test_cmake_toolchain.py
index 769b49bf0..55664c9da 100644
--- a/conans/test/functional/toolchains/cmake/test_cmake_toolchain.py
+++ b/conans/test/functional/toolchains/cmake/test_cmake_toolchain.py
@@ -5,6 +5,8 @@ import textwrap
 import pytest
 
 from conan.tools.cmake.presets import load_cmake_presets
+from conan.tools.microsoft.visual import vcvars_command
+from conans.client.tools import replace_in_file
 from conans.model.ref import ConanFileReference
 from conans.test.assets.cmake import gen_cmakelists
 from conans.test.assets.genconanfile import GenConanfile
@@ -69,6 +71,49 @@ def test_cmake_toolchain_custom_toolchain():
     assert "binaryDir" not in presets["configurePresets"][0]
 
 
+@pytest.mark.skipif(platform.system() != "Darwin",
+                    reason="Single config test, Linux CI still without 3.23")
+@pytest.mark.tool_cmake(version="3.23")
+def test_cmake_user_presets_load():
+    """
+    Test if the CMakeUserPresets.cmake is generated and use CMake to use it to verify the right
+    syntax of generated CMakeUserPresets.cmake and CMakePresets.cmake
+    """
+    t = TestClient()
+    t.run("new mylib/1.0 --template cmake_lib")
+    t.run("create . -s:h build_type=Release")
+    t.run("create . -s:h build_type=Debug")
+
+    consumer = textwrap.dedent("""
+        from conan import ConanFile
+        from conan.tools.cmake import cmake_layout
+
+        class Consumer(ConanFile):
+
+            settings = "build_type", "os", "arch", "compiler"
+            requires = "mylib/1.0"
+            generators = "CMakeToolchain", "CMakeDeps"
+
+            def layout(self):
+                cmake_layout(self)
+
+    """)
+
+    cmakelist = textwrap.dedent("""
+        cmake_minimum_required(VERSION 3.1)
+        project(PackageTest CXX)
+        find_package(mylib REQUIRED CONFIG)
+        """)
+    t.save({"conanfile.py": consumer, "CMakeLists.txt": cmakelist}, clean_first=True)
+    t.run("install . -s:h build_type=Debug -g CMakeToolchain")
+    t.run("install . -s:h build_type=Release -g CMakeToolchain")
+    assert os.path.exists(os.path.join(t.current_folder, "CMakeUserPresets.json"))
+    t.run_command("cmake . --preset Release")
+    assert 'CMAKE_BUILD_TYPE="Release"' in t.out
+    t.run_command("cmake . --preset Debug")
+    assert 'CMAKE_BUILD_TYPE="Debug"' in t.out
+
+
 def test_cmake_toolchain_user_toolchain_from_dep():
     client = TestClient()
     conanfile = textwrap.dedent("""
@@ -182,10 +227,10 @@ def test_cmaketoolchain_no_warnings():
             requires = "dep/0.1"
         """)
     consumer = textwrap.dedent("""
+       cmake_minimum_required(VERSION 3.15)
        set(CMAKE_CXX_COMPILER_WORKS 1)
        set(CMAKE_CXX_ABI_COMPILED 1)
        project(MyHello CXX)
-       cmake_minimum_required(VERSION 3.15)
 
        find_package(dep CONFIG REQUIRED)
        """)
@@ -225,8 +270,7 @@ def test_install_output_directories():
     assert os.path.exists(os.path.join(p_folder, "mylibs"))
     assert not os.path.exists(os.path.join(p_folder, "lib"))
     b_folder = client.cache.package_layout(pref.ref).build(pref)
-    layout_folder = "cmake-build-release" if platform.system() != "Windows" else "build"
-    toolchain = client.load(os.path.join(b_folder, layout_folder, "conan", "conan_toolchain.cmake"))
+    toolchain = client.load(os.path.join(b_folder, "build", "generators", "conan_toolchain.cmake"))
     assert 'set(CMAKE_INSTALL_LIBDIR "mylibs")' in toolchain
 
 
@@ -436,3 +480,39 @@ class TestAutoLinkPragma:
                      "test_package/conanfile.py": self.test_cf})
 
         client.run("create .")
+
+
+@pytest.mark.skipif(platform.system() != "Windows", reason="Only for windows")
+def test_cmake_toolchain_runtime_types():
+    # everything works with the default cmake_minimum_required version 3.15 in the template
+    client = TestClient(path_with_spaces=False)
+    client.run("new hello/0.1 --template=cmake_lib")
+    client.run("install . -s compiler.runtime=MTd -s build_type=Debug")
+    client.run("build .")
+
+    vcvars = vcvars_command(version="15", architecture="x64")
+    lib = os.path.join(client.current_folder, "build", "Debug", "hello.lib")
+    dumpbind_cmd = '{} && dumpbin /directives "{}"'.format(vcvars, lib)
+    client.run_command(dumpbind_cmd)
+    assert "LIBCMTD" in client.out
+
+
+@pytest.mark.skipif(platform.system() != "Windows", reason="Only for windows")
+def test_cmake_toolchain_runtime_types_cmake_older_than_3_15():
+    client = TestClient(path_with_spaces=False)
+    # Setting an older cmake_minimum_required in the CMakeLists fails, will link
+    # against the default debug runtime (MDd->MSVCRTD), not against MTd->LIBCMTD
+    client.run("new hello/0.1 --template=cmake_lib")
+    replace_in_file(os.path.join(client.current_folder, "CMakeLists.txt"),
+                    'cmake_minimum_required(VERSION 3.15)',
+                    'cmake_minimum_required(VERSION 3.1)'
+                    , output=client.out)
+
+    client.run("install . -s compiler.runtime=MTd -s build_type=Debug")
+    client.run("build .")
+
+    vcvars = vcvars_command(version="15", architecture="x64")
+    lib = os.path.join(client.current_folder, "build", "Debug", "hello.lib")
+    dumpbind_cmd = '{} && dumpbin /directives "{}"'.format(vcvars, lib)
+    client.run_command(dumpbind_cmd)
+    assert "LIBCMTD" in client.out
diff --git a/conans/test/functional/toolchains/cmake/test_cmake_toolchain_xcode_flags.py b/conans/test/functional/toolchains/cmake/test_cmake_toolchain_xcode_flags.py
index 5f5fe146e..30b5622b2 100644
--- a/conans/test/functional/toolchains/cmake/test_cmake_toolchain_xcode_flags.py
+++ b/conans/test/functional/toolchains/cmake/test_cmake_toolchain_xcode_flags.py
@@ -38,7 +38,7 @@ def test_cmake_apple_bitcode_arc_and_visibility_flags_enabled(op_system, os_vers
     client.run("new hello/0.1 --template=cmake_lib")
     _add_message_status_flags(client)
     client.run("install . --profile:build=default --profile:host=host")
-    toolchain = client.load(os.path.join("cmake-build-release", "conan", "conan_toolchain.cmake"))
+    toolchain = client.load(os.path.join("build", "generators", "conan_toolchain.cmake"))
     # bitcode
     assert 'set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "YES")' in toolchain
     assert 'set(CMAKE_XCODE_ATTRIBUTE_BITCODE_GENERATION_MODE "bitcode")' in toolchain
@@ -121,7 +121,7 @@ def test_cmake_apple_bitcode_arc_and_visibility_flags_disabled(op_system, os_ver
     client.run("new hello/0.1 --template=cmake_lib")
     _add_message_status_flags(client)
     client.run("install . --profile:build=default --profile:host=host")
-    toolchain = client.load(os.path.join("cmake-build-release", "conan", "conan_toolchain.cmake"))
+    toolchain = client.load(os.path.join("build", "generators", "conan_toolchain.cmake"))
     # bitcode
     assert 'set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO")' in toolchain
     assert 'set(CMAKE_XCODE_ATTRIBUTE_BITCODE_GENERATION_MODE "bitcode")' not in toolchain
@@ -163,7 +163,7 @@ def test_cmake_apple_bitcode_arc_and_visibility_flags_are_none(op_system, os_ver
     client.run("new hello/0.1 --template=cmake_lib")
     _add_message_status_flags(client)
     client.run("install . --profile:build=default --profile:host=host")
-    toolchain = client.load(os.path.join("cmake-build-release", "conan", "conan_toolchain.cmake"))
+    toolchain = client.load(os.path.join("build", "generators", "conan_toolchain.cmake"))
     # bitcode
     assert 'set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO")' not in toolchain
     assert 'set(CMAKE_XCODE_ATTRIBUTE_BITCODE_GENERATION_MODE "bitcode")' not in toolchain
diff --git a/conans/test/functional/toolchains/cmake/test_cmaketoolchain_paths.py b/conans/test/functional/toolchains/cmake/test_cmaketoolchain_paths.py
index 4f43e9bb7..fb09c3c4b 100644
--- a/conans/test/functional/toolchains/cmake/test_cmaketoolchain_paths.py
+++ b/conans/test/functional/toolchains/cmake/test_cmaketoolchain_paths.py
@@ -168,8 +168,8 @@ def test_cmaketoolchain_path_find_package_real_config(settings, find_root_path_m
     client.run("create . hello/0.1@ -pr:b default {}".format(settings))
 
     consumer = textwrap.dedent("""
-        project(MyHello NONE)
         cmake_minimum_required(VERSION 3.15)
+        project(MyHello NONE)
 
         find_package(hello REQUIRED)
         """)
diff --git a/conans/test/functional/toolchains/gnu/test_v2_autotools_template.py b/conans/test/functional/toolchains/gnu/test_v2_autotools_template.py
index b7d46889b..32382f767 100644
--- a/conans/test/functional/toolchains/gnu/test_v2_autotools_template.py
+++ b/conans/test/functional/toolchains/gnu/test_v2_autotools_template.py
@@ -1,11 +1,13 @@
 import platform
 import re
 import os
+import shutil
+import textwrap
 
 import pytest
 
 from conans.model.ref import ConanFileReference, PackageReference
-from conans.test.utils.tools import TestClient
+from conans.test.utils.tools import TestClient, TestServer
 
 
 @pytest.mark.skipif(platform.system() not in ["Linux", "Darwin"], reason="Requires Autotools")
@@ -60,3 +62,103 @@ def test_autotools_exe_template():
     client.run("create . -s build_type=Debug")
     assert "greet/0.1: Hello World Debug!" in client.out
 
+
+@pytest.mark.skipif(platform.system() not in ["Darwin"], reason="Requires Autotools")
+@pytest.mark.tool_autotools()
+def test_autotools_relocatable_libs_darwin():
+    client = TestClient(path_with_spaces=False)
+    client.run("new hello/0.1 --template=autotools_lib")
+    client.run("create . -o hello:shared=True")
+    package_id = re.search(r"Package (\S+)", str(client.out)).group(1)
+    package_id = package_id.replace("'", "")
+    pref = PackageReference(ConanFileReference.loads("hello/0.1"), package_id)
+    package_folder = client.cache.package_layout(pref.ref).package(pref)
+    dylib = os.path.join(package_folder, "lib", "libhello.0.dylib")
+    if platform.system() == "Darwin":
+        client.run_command("otool -l {}".format(dylib))
+        assert "@rpath/libhello.0.dylib" in client.out
+        client.run_command("otool -l {}".format("test_package/build-release/main"))
+
+    # will work because rpath set
+    client.run_command("test_package/build-release/main")
+    assert "hello/0.1: Hello World Release!" in client.out
+
+    # move to another location so that the path set in the rpath does not exist
+    # then the execution should fail
+    shutil.move(os.path.join(package_folder, "lib"), os.path.join(client.current_folder, "tempfolder"))
+    # will fail because rpath does not exist
+    client.run_command("test_package/build-release/main", assert_error=True)
+    assert "Library not loaded: @rpath/libhello.0.dylib" in client.out
+
+    # Use DYLD_LIBRARY_PATH and should run
+    client.run_command("DYLD_LIBRARY_PATH={} test_package/build-release/main".format(os.path.join(client.current_folder, "tempfolder")))
+    assert "hello/0.1: Hello World Release!" in client.out
+
+
+@pytest.mark.skipif(platform.system() not in ["Darwin"], reason="Requires Autotools")
+@pytest.mark.tool_autotools()
+def test_autotools_relocatable_libs_darwin_downloaded():
+    server = TestServer([("*/*@*/*", "*")], [("*/*@*/*", "*")])
+    client = TestClient(servers={"default": server}, path_with_spaces=False)
+    client2 = TestClient(servers={"default": server}, path_with_spaces=False)
+    assert client2.cache_folder != client.cache_folder
+    client.run("new hello/0.1 --template=autotools_lib")
+    client.run("create . -o hello:shared=True -tf=None")
+    client.run("upload * --all -c")
+    client.run("remove * -f")
+
+    conanfile = textwrap.dedent("""
+        from conan import ConanFile
+        from conan.tools.gnu import Autotools
+        from conan.tools.layout import basic_layout
+
+        class GreetConan(ConanFile):
+            name = "greet"
+            version = "1.0"
+            settings = "os", "compiler", "build_type", "arch"
+            exports_sources = "configure.ac", "Makefile.am", "main.cpp"
+            generators = "AutotoolsDeps", "AutotoolsToolchain"
+
+            def requirements(self):
+                self.requires("hello/0.1")
+
+            def layout(self):
+                basic_layout(self)
+
+            def build(self):
+                autotools = Autotools(self)
+                autotools.autoreconf()
+                autotools.configure()
+                autotools.make()
+        """)
+
+    main = textwrap.dedent("""
+        #include "hello.h"
+        int main() { hello(); }
+        """)
+
+    makefileam = textwrap.dedent("""
+        bin_PROGRAMS = greet
+        greet_SOURCES = main.cpp
+        """)
+
+    configureac = textwrap.dedent("""
+        AC_INIT([greet], [1.0], [])
+        AM_INIT_AUTOMAKE([-Wall -Werror foreign])
+        AC_PROG_CXX
+        AM_PROG_AR
+        LT_INIT
+        AC_CONFIG_FILES([Makefile])
+        AC_OUTPUT
+        """)
+
+    client2.save({"conanfile.py": conanfile,
+                  "main.cpp": main,
+                  "makefile.am": makefileam,
+                  "configure.ac": configureac})
+
+    client2.run("install . -o hello:shared=True -r default")
+    client2.run("build .")
+    client2.run_command("build-release/greet")
+    assert "Hello World Release!" in client2.out
+
diff --git a/conans/test/functional/toolchains/microsoft/test_msbuildtoolchain.py b/conans/test/functional/toolchains/microsoft/test_msbuildtoolchain.py
index 32fc0799b..c60a56fba 100644
--- a/conans/test/functional/toolchains/microsoft/test_msbuildtoolchain.py
+++ b/conans/test/functional/toolchains/microsoft/test_msbuildtoolchain.py
@@ -1,4 +1,5 @@
 import platform
+import sys
 import textwrap
 import os
 
@@ -17,6 +18,7 @@ toolchain_props = """
 """
 
 
+@pytest.mark.skipif(sys.version_info.major == 2, reason="Meson not supported in Py2")
 @pytest.mark.skipif(platform.system() not in ["Windows"], reason="Requires Windows")
 def test_msbuildtoolchain_props_with_extra_flags():
     """
diff --git a/conans/test/integration/toolchains/cmake/test_cmaketoolchain.py b/conans/test/integration/toolchains/cmake/test_cmaketoolchain.py
index 023766363..41ea94724 100644
--- a/conans/test/integration/toolchains/cmake/test_cmaketoolchain.py
+++ b/conans/test/integration/toolchains/cmake/test_cmaketoolchain.py
@@ -353,7 +353,7 @@ def test_cmake_presets_binary_dir_available():
     else:
         build_dir = os.path.join(client.current_folder, "build")
 
-    presets = load_cmake_presets(os.path.join(build_dir, "conan"))
+    presets = load_cmake_presets(os.path.join(client.current_folder, "build", "generators"))
     assert presets["configurePresets"][0]["binaryDir"] == build_dir
 
 
@@ -401,6 +401,9 @@ def test_cmake_presets_multiconfig():
     assert presets["buildPresets"][2]["configuration"] == "RelWithDebInfo"
     assert presets["buildPresets"][3]["configuration"] == "MinSizeRel"
 
+    assert len(presets["configurePresets"]) == 1
+    assert presets["configurePresets"][0]["name"] == "default"
+
 
 def test_cmake_presets_singleconfig():
     client = TestClient()
@@ -420,8 +423,19 @@ def test_cmake_presets_singleconfig():
     assert len(presets["configurePresets"]) == 1
     assert presets["configurePresets"][0]["name"] == "Release"
 
-    # Still only one configurePreset, but named correctly
+    assert len(presets["buildPresets"]) == 1
+    assert presets["buildPresets"][0]["configurePreset"] == "Release"
+
+    # Now two configurePreset, but named correctly
     client.run("install mylib/1.0@ -g CMakeToolchain -s build_type=Debug --profile:h=profile")
     presets = json.loads(client.load("CMakePresets.json"))
-    assert len(presets["configurePresets"]) == 1
-    assert presets["configurePresets"][0]["name"] == "Debug"
+    assert len(presets["configurePresets"]) == 2
+    assert presets["configurePresets"][1]["name"] == "Debug"
+
+    assert len(presets["buildPresets"]) == 2
+    assert presets["buildPresets"][1]["configurePreset"] == "Debug"
+
+    # Repeat configuration, it shouldn't add a new one
+    client.run("install mylib/1.0@ -g CMakeToolchain -s build_type=Debug --profile:h=profile")
+    presets = json.loads(client.load("CMakePresets.json"))
+    assert len(presets["configurePresets"]) == 2
diff --git a/conans/test/integration/toolchains/microsoft/vcvars_test.py b/conans/test/integration/toolchains/microsoft/vcvars_test.py
index 8b9136a0c..27db87bbd 100644
--- a/conans/test/integration/toolchains/microsoft/vcvars_test.py
+++ b/conans/test/integration/toolchains/microsoft/vcvars_test.py
@@ -69,4 +69,25 @@ def test_vcvars_2015_error():
                '-s compiler.cppstd=14 -s compiler.runtime=static')
 
     vcvars = client.load("conanvcvars.bat")
+    assert 'vcvarsall.bat"  amd64' in vcvars
+    assert "-vcvars_ver" not in vcvars
+
+
+@pytest.mark.skipif(platform.system() != "Windows", reason="Requires Windows")
+def test_vcvars_platform_x86():
+    # https://github.com/conan-io/conan/issues/11144
+    client = TestClient(path_with_spaces=False)
+
+    conanfile = textwrap.dedent("""
+        from conans import ConanFile
+        class TestConan(ConanFile):
+            generators = "VCVars"
+            settings = "os", "compiler", "arch", "build_type"
+    """)
+    client.save({"conanfile.py": conanfile})
+    client.run('install . -s os=Windows -s compiler="msvc" -s compiler.version=190 '
+               '-s compiler.cppstd=14 -s compiler.runtime=static -s:b arch=x86')
+
+    vcvars = client.load("conanvcvars.bat")
+    assert 'vcvarsall.bat"  x86_amd64' in vcvars
     assert "-vcvars_ver" not in vcvars
diff --git a/conans/test/unittests/tools/cmake/test_cmaketoolchain.py b/conans/test/unittests/tools/cmake/test_cmaketoolchain.py
index 42a150dc3..123fb38b9 100644
--- a/conans/test/unittests/tools/cmake/test_cmaketoolchain.py
+++ b/conans/test/unittests/tools/cmake/test_cmaketoolchain.py
@@ -178,7 +178,16 @@ def conanfile_msvc():
 
 def test_toolset(conanfile_msvc):
     toolchain = CMakeToolchain(conanfile_msvc)
-    assert 'CMAKE_GENERATOR_TOOLSET "v143"' in toolchain.content
+    assert 'set(CMAKE_GENERATOR_TOOLSET "v143" CACHE STRING "" FORCE)' in toolchain.content
+    assert 'Visual Studio 17 2022' in toolchain.generator
+    assert 'CMAKE_CXX_STANDARD 20' in toolchain.content
+
+
+def test_toolset_x64(conanfile_msvc):
+    # https://github.com/conan-io/conan/issues/11144
+    conanfile_msvc.conf.define("tools.cmake.cmaketoolchain:toolset_arch", "x64")
+    toolchain = CMakeToolchain(conanfile_msvc)
+    assert 'set(CMAKE_GENERATOR_TOOLSET "v143,host=x64" CACHE STRING "" FORCE)' in toolchain.content
     assert 'Visual Studio 17 2022' in toolchain.generator
     assert 'CMAKE_CXX_STANDARD 20' in toolchain.content
 
diff --git a/conans/test/unittests/tools/scm/test_version.py b/conans/test/unittests/tools/scm/test_version.py
new file mode 100644
index 000000000..bdb83344a
--- /dev/null
+++ b/conans/test/unittests/tools/scm/test_version.py
@@ -0,0 +1,23 @@
+import textwrap
+
+from conans.test.utils.tools import TestClient
+
+
+def test_version():
+    c = TestClient()
+    conanfile = textwrap.dedent("""
+        from conan import ConanFile
+        from conan.tools.scm import Version
+
+        class Pkg(ConanFile):
+            name = "pkg"
+            version = "0.1"
+            settings = "compiler"
+            def configure(self):
+                v = Version(self.settings.compiler.version)
+                assert v > "10"
+        """)
+    c.save({"conanfile.py": conanfile})
+    settings = "-s compiler=gcc -s compiler.libcxx=libstdc++11"
+    c.run("create . {} -s compiler.version=11".format(settings))
+    c.run("create . {} -s compiler.version=9".format(settings), assert_error=True)