Repository: conan-io/conan
Pull request #11826 (2022-08-10 07:55:43)

[MSBuildDeps] Bad XML format
Changelog: Bugfix: Added `+` symbol to be replaced by `_` in XML element names.
Docs: omit
Closes: https://github.com/conan-io/conan/issues/11822



Patch:
diff --git a/conan/tools/cmake/toolchain/blocks.py b/conan/tools/cmake/toolchain/blocks.py
index 5db4af04e..9d698dd50 100644
--- a/conan/tools/cmake/toolchain/blocks.py
+++ b/conan/tools/cmake/toolchain/blocks.py
@@ -313,7 +313,7 @@ class AndroidSystemBlock(Block):
         android_ndk_path = android_ndk_path.replace("\\", "/")
 
         ctxt_toolchain = {
-            'android_platform': self._conanfile.settings.os.api_level,
+            'android_platform': 'android-' + str(self._conanfile.settings.os.api_level),
             'android_abi': android_abi,
             'android_stl': libcxx_str,
             'android_ndk_path': android_ndk_path,
diff --git a/conan/tools/meson/helpers.py b/conan/tools/meson/helpers.py
index 28cb09822..f3da633ee 100644
--- a/conan/tools/meson/helpers.py
+++ b/conan/tools/meson/helpers.py
@@ -58,7 +58,7 @@ _cppstd_map = {
     '11': "c++11", 'gnu11': "gnu++11",
     '14': "c++14", 'gnu14': "gnu++14",
     '17': "c++17", 'gnu17': "gnu++17",
-    '20': "c++1z", 'gnu20': "gnu++1z"
+    '20': "c++20", 'gnu20': "gnu++20"
 }
 
 
diff --git a/conan/tools/microsoft/msbuilddeps.py b/conan/tools/microsoft/msbuilddeps.py
index 8b1165823..009395802 100644
--- a/conan/tools/microsoft/msbuilddeps.py
+++ b/conan/tools/microsoft/msbuilddeps.py
@@ -1,16 +1,17 @@
 import fnmatch
 import os
+import re
 import textwrap
 from xml.dom import minidom
 
 from jinja2 import Template
 
 from conan.tools._check_build_profile import check_using_build_profile
-from conans.client.graph.graph import CONTEXT_BUILD
 from conans.errors import ConanException
 from conans.util.files import load, save
 
 VALID_LIB_EXTENSIONS = (".so", ".lib", ".a", ".dylib", ".bc")
+EXCLUDED_SYMBOLS_PATTERN = re.compile(r"[\.+\-]")
 
 
 class MSBuildDeps(object):
@@ -126,10 +127,13 @@ class MSBuildDeps(object):
     @staticmethod
     def _dep_name(dep, build):
         dep_name = dep.ref.name
-        dep_name = dep_name.replace(".", "_")
         if build:  # dep.context == CONTEXT_BUILD:
             dep_name += "_build"
-        return dep_name
+        return MSBuildDeps._get_valid_xml_format(dep_name)
+
+    @staticmethod
+    def _get_valid_xml_format(name):
+        return EXCLUDED_SYMBOLS_PATTERN.sub("_", name)
 
     def _vars_props_file(self, dep, name, cpp_info, deps, build):
         """
@@ -224,7 +228,6 @@ class MSBuildDeps(object):
             </Project>
             """)
             content_multi = Template(content_multi).render({"name": dep_name})
-
         # parse the multi_file and add new import statement if needed
         dom = minidom.parseString(content_multi)
         import_vars = dom.getElementsByTagName('ImportGroup')[0]
@@ -283,7 +286,7 @@ class MSBuildDeps(object):
             for comp_name, comp_info in dep.cpp_info.components.items():
                 if comp_name is None:
                     continue
-                full_comp_name = "{}_{}".format(dep_name, comp_name)
+                full_comp_name = "{}_{}".format(dep_name, self._get_valid_xml_format(comp_name))
                 vars_filename = "conan_%s_vars%s.props" % (full_comp_name, conf_name)
                 activate_filename = "conan_%s%s.props" % (full_comp_name, conf_name)
                 comp_filename = "conan_%s.props" % full_comp_name
diff --git a/conan/tools/scm/__init__.py b/conan/tools/scm/__init__.py
index 9d4097bc7..59846cc18 100644
--- a/conan/tools/scm/__init__.py
+++ b/conan/tools/scm/__init__.py
@@ -1,2 +1,200 @@
 from conan.tools.scm.git import Git
-from conans.model.version import Version
+# develop2 uncomment the next line
+# from conans.model.version import Version
+
+
+# ######## DEVELOP2: Delete all the contents from here, this is copy-paste from the Version model
+# ######## at conans.model.version (for an easier migration)
+from functools import total_ordering
+from conans.errors import ConanException
+
+
+@total_ordering
+class _VersionItem:
+    """ a single "digit" in a version, like X.Y.Z all X and Y and Z are VersionItems
+    They can be int or strings
+    """
+    def __init__(self, item):
+        try:
+            self._v = int(item)
+        except ValueError:
+            self._v = item
+
+    @property
+    def value(self):
+        return self._v
+
+    def __str__(self):
+        return str(self._v)
+
+    def __add__(self, other):
+        # necessary for the "bump()" functionality. Other aritmetic operations are missing
+        return self._v + other
+
+    def __eq__(self, other):
+        if not isinstance(other, _VersionItem):
+            other = _VersionItem(other)
+        return self._v == other._v
+
+    def __hash__(self):
+        return hash(self._v)
+
+    def __lt__(self, other):
+        """
+        @type other: _VersionItem
+        """
+        if not isinstance(other, _VersionItem):
+            other = _VersionItem(other)
+        try:
+            return self._v < other._v
+        except TypeError:
+            return str(self._v) < str(other._v)
+
+
+@total_ordering
+class Version:
+    """
+    This is NOT an implementation of semver, as users may use any pattern in their versions.
+    It is just a helper to parse "." or "-" and compare taking into account integers when possible
+    """
+    def __init__(self, value):
+        value = str(value)
+        self._value = value
+
+        items = value.rsplit("+", 1)  # split for build
+        if len(items) == 2:
+            value, build = items
+            self._build = Version(build)  # This is a nested version by itself
+        else:
+            value = items[0]
+            self._build = None
+
+        items = value.rsplit("-", 1)  # split for pre-release
+        if len(items) == 2:
+            value, pre = items
+            self._pre = Version(pre)  # This is a nested version by itself
+        else:
+            value = items[0]
+            self._pre = None
+        items = value.split(".")
+        items = [_VersionItem(item) for item in items]
+        self._items = tuple(items)
+        while items and items[-1].value == 0:
+            del items[-1]
+        self._nonzero_items = tuple(items)
+
+    def bump(self, index):
+        """
+           Increments by 1 the version field at the specified index, setting to 0 the fields
+            on the right.
+           2.5 => bump(1) => 2.6
+           1.5.7 => bump(0) => 2.0.0
+        """
+        # this method is used to compute version ranges from tilde ~1.2 and caret ^1.2.1 ranges
+        # TODO: at this moment it only works for digits, cannot increment pre-release or builds
+        # better not make it public yet, keep it internal
+        items = list(self._items[:index])
+        try:
+            items.append(self._items[index]+1)
+        except TypeError:
+            raise ConanException(f"Cannot bump '{self._value} version index {index}, not an int")
+        items.extend([0] * (len(items) - index - 1))
+        v = ".".join(str(i) for i in items)
+        # prerelease and build are dropped while bumping digits
+        result = Version(v)
+        return result
+
+    def upper_bound(self, index):
+        items = list(self._items[:index])
+        try:
+            items.append(self._items[index] + 1)
+        except TypeError:
+            raise ConanException(f"Cannot bump '{self._value} version index {index}, not an int")
+        items.extend([0] * (len(items) - index - 1))
+        v = ".".join(str(i) for i in items)
+        v += "-"  # Exclude prereleases
+        result = Version(v)
+        return result
+
+    @property
+    def pre(self):
+        return self._pre
+
+    @property
+    def build(self):
+        return self._build
+
+    @property
+    def main(self):
+        return self._items
+
+    @property
+    def major(self):
+        try:
+            return self.main[0]
+        except IndexError:
+            return None
+
+    @property
+    def minor(self):
+        try:
+            return self.main[1]
+        except IndexError:
+            return None
+
+    @property
+    def patch(self):
+        try:
+            return self.main[2]
+        except IndexError:
+            return None
+
+    @property
+    def micro(self):
+        try:
+            return self.main[3]
+        except IndexError:
+            return None
+
+    def __str__(self):
+        return self._value
+
+    def __repr__(self):
+        return self._value
+
+    def __eq__(self, other):
+        if other is None:
+            return False
+        if isinstance(other, str):
+            other = Version(other)
+
+        return (self._nonzero_items, self._pre, self._build) ==\
+               (other._nonzero_items, other._pre, other._build)
+
+    def __hash__(self):
+        return hash((self._nonzero_items, self._pre, self._build))
+
+    def __lt__(self, other):
+        if other is None:
+            return False
+        if not isinstance(other, Version):
+            other = Version(other)
+
+        if self._pre:
+            if other._pre:  # both are pre-releases
+                return (self._nonzero_items, self._pre, self._build) < \
+                       (other._nonzero_items, other._pre, other._build)
+            else:  # Left hand is pre-release, right side is regular
+                if self._nonzero_items == other._nonzero_items:  # Problem only happens if both equal
+                    return True
+                else:
+                    return self._nonzero_items < other._nonzero_items
+        else:
+            if other._pre:  # Left hand is regular, right side is pre-release
+                if self._nonzero_items == other._nonzero_items:  # Problem only happens if both equal
+                    return False
+                else:
+                    return self._nonzero_items < other._nonzero_items
+            else:  # None of them is pre-release
+                return (self._nonzero_items, self._build) < (other._nonzero_items, other._build)
+
diff --git a/conans/assets/templates/new_v2_cmake.py b/conans/assets/templates/new_v2_cmake.py
index 891d1634c..9380e33a3 100644
--- a/conans/assets/templates/new_v2_cmake.py
+++ b/conans/assets/templates/new_v2_cmake.py
@@ -131,6 +131,10 @@ void {name}(){{
     std::cout << "  {name}/{version}: _M_IX86 defined\n";
     #endif
 
+    #ifdef _M_ARM64
+    std::cout << "  {name}/{version}: _M_ARM64 defined\n";
+    #endif
+
     #if __i386__
     std::cout << "  {name}/{version}: __i386__ defined\n";
     #endif
@@ -139,6 +143,10 @@ void {name}(){{
     std::cout << "  {name}/{version}: __x86_64__ defined\n";
     #endif
 
+    #if __aarch64__
+    std::cout << "  {name}/{version}: __aarch64__ defined\n";
+    #endif
+
     // Libstdc++
     #if defined _GLIBCXX_USE_CXX11_ABI
     std::cout << "  {name}/{version}: _GLIBCXX_USE_CXX11_ABI "<< _GLIBCXX_USE_CXX11_ABI << "\n";
diff --git a/conans/assets/templates/new_v2_msbuild.py b/conans/assets/templates/new_v2_msbuild.py
index da4329e98..e7f2cc6ee 100644
--- a/conans/assets/templates/new_v2_msbuild.py
+++ b/conans/assets/templates/new_v2_msbuild.py
@@ -311,6 +311,10 @@ void {{name}}(){
     std::cout << "  {{name}}/{{version}}: _M_IX86 defined\n";
     #endif
 
+    #ifdef _M_ARM64
+    std::cout << "  {{name}}/{{version}}: _M_ARM64 defined\n";
+    #endif
+
     #if __i386__
     std::cout << "  {{name}}/{{version}}: __i386__ defined\n";
     #endif
@@ -319,6 +323,10 @@ void {{name}}(){
     std::cout << "  {{name}}/{{version}}: __x86_64__ defined\n";
     #endif
 
+    #if __aarch64__
+    std::cout << "  {{name}}/{{version}}: __aarch64__ defined\n";
+    #endif
+
     // Libstdc++
     #if defined _GLIBCXX_USE_CXX11_ABI
     std::cout << "  {{name}}/{{version}}: _GLIBCXX_USE_CXX11_ABI "<< _GLIBCXX_USE_CXX11_ABI << "\n";
diff --git a/conans/client/conf/__init__.py b/conans/client/conf/__init__.py
index 4e1212307..25768c904 100644
--- a/conans/client/conf/__init__.py
+++ b/conans/client/conf/__init__.py
@@ -118,7 +118,7 @@ _t_default_settings_yml = Template(textwrap.dedent("""
         clang:
             version: ["3.3", "3.4", "3.5", "3.6", "3.7", "3.8", "3.9", "4.0",
                       "5.0", "6.0", "7.0", "7.1",
-                      "8", "9", "10", "11", "12", "13", "14", "15"]
+                      "8", "9", "10", "11", "12", "13", "14", "15", "16"]
             libcxx: [None, libstdc++, libstdc++11, libc++, c++_shared, c++_static]
             cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20, 23, gnu23]
             runtime: [None, MD, MT, MTd, MDd, static, dynamic]
diff --git a/conans/client/migrations_settings.py b/conans/client/migrations_settings.py
index 3ade307f4..910710eaa 100644
--- a/conans/client/migrations_settings.py
+++ b/conans/client/migrations_settings.py
@@ -3714,8 +3714,161 @@ cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20, 23, gnu23]
 
 settings_1_50_0 = settings_1_49_0
 settings_1_50_1 = settings_1_50_0
+settings_1_50_2 = settings_1_50_1
 
-settings_1_51_0 = settings_1_50_1
+settings_1_51_0 = settings_1_50_2
 settings_1_51_1 = settings_1_51_0
+settings_1_51_2 = settings_1_51_1
 
-settings_1_52_0 = settings_1_51_1
+settings_1_52_0 = """
+# Only for cross building, 'os_build/arch_build' is the system that runs Conan
+os_build: [Windows, WindowsStore, Linux, Macos, FreeBSD, SunOS, AIX, VxWorks]
+arch_build: [x86, x86_64, ppc32be, ppc32, ppc64le, ppc64, armv5el, armv5hf, armv6, armv7, armv7hf, armv7s, armv7k, armv8, armv8_32, armv8.3, sparc, sparcv9, mips, mips64, avr, s390, s390x, sh4le, e2k-v2, e2k-v3, e2k-v4, e2k-v5, e2k-v6, e2k-v7]
+
+# Only for building cross compilation tools, 'os_target/arch_target' is the system for
+# which the tools generate code
+os_target: [Windows, Linux, Macos, Android, iOS, watchOS, tvOS, FreeBSD, SunOS, AIX, Arduino, Neutrino]
+arch_target: [x86, x86_64, ppc32be, ppc32, ppc64le, ppc64, armv5el, armv5hf, armv6, armv7, armv7hf, armv7s, armv7k, armv8, armv8_32, armv8.3, sparc, sparcv9, mips, mips64, avr, s390, s390x, asm.js, wasm, sh4le, e2k-v2, e2k-v3, e2k-v4, e2k-v5, e2k-v6, e2k-v7, xtensalx6, xtensalx106, xtensalx7]
+
+# Rest of the settings are "host" settings:
+# - For native building/cross building: Where the library/program will run.
+# - For building cross compilation tools: Where the cross compiler will run.
+os:
+    Windows:
+        subsystem: [None, cygwin, msys, msys2, wsl]
+    WindowsStore:
+        version: ["8.1", "10.0"]
+    WindowsCE:
+        platform: ANY
+        version: ["5.0", "6.0", "7.0", "8.0"]
+    Linux:
+    iOS:
+        version: &ios_version
+                 ["7.0", "7.1", "8.0", "8.1", "8.2", "8.3", "9.0", "9.1", "9.2", "9.3", "10.0", "10.1", "10.2", "10.3",
+                  "11.0", "11.1", "11.2", "11.3", "11.4", "12.0", "12.1", "12.2", "12.3", "12.4",
+                  "13.0", "13.1", "13.2", "13.3", "13.4", "13.5", "13.6", "13.7",
+                  "14.0", "14.1", "14.2", "14.3", "14.4", "14.5", "14.6", "14.7", "14.8",
+                  "15.0", "15.1", "15.2", "15.3", "15.4"]
+        sdk: [None, "iphoneos", "iphonesimulator"]
+        sdk_version: [None, "11.3", "11.4", "12.0", "12.1", "12.2", "12.4",
+                      "13.0", "13.1", "13.2", "13.4", "13.5", "13.6", "13.7",
+                      "14.0", "14.1", "14.2", "14.3", "14.4", "14.5", "15.0", "15.2", "15.4"]
+    watchOS:
+        version: ["4.0", "4.1", "4.2", "4.3", "5.0", "5.1", "5.2", "5.3", "6.0", "6.1", "6.2",
+                  "7.0", "7.1", "7.2", "7.3", "7.4", "7.5", "7.6", "8.0", "8.1", "8.3", "8.4", "8.5"]
+        sdk: [None, "watchos", "watchsimulator"]
+        sdk_version: [None, "4.3", "5.0", "5.1", "5.2", "5.3", "6.0", "6.1", "6.2",
+                      "7.0", "7.1", "7.2", "7.4", "8.0", "8.0.1", "8.3", "8.5"]
+    tvOS:
+        version: ["11.0", "11.1", "11.2", "11.3", "11.4", "12.0", "12.1", "12.2", "12.3", "12.4",
+                  "13.0", "13.2", "13.3", "13.4", "14.0", "14.2", "14.3", "14.4", "14.5", "14.6", "14.7",
+                  "15.0", "15.1", "15.2", "15.3", "15.4"]
+        sdk: [None, "appletvos", "appletvsimulator"]
+        sdk_version: [None, "11.3", "11.4", "12.0", "12.1", "12.2", "12.4",
+                      "13.0", "13.1", "13.2", "13.4", "14.0", "14.2", "14.3", "14.5", "15.0", "15.2", "15.4"]
+    Macos:
+        version: [None, "10.6", "10.7", "10.8", "10.9", "10.10", "10.11", "10.12", "10.13", "10.14", "10.15", "11.0", "12.0", "13.0"]
+        sdk: [None, "macosx"]
+        sdk_version: [None, "10.13", "10.14", "10.15", "11.0", "11.1", "11.3", "12.0", "12.1", "12.3"]
+        subsystem:
+            None:
+            catalyst:
+                ios_version: *ios_version
+    Android:
+        api_level: ANY
+    FreeBSD:
+    SunOS:
+    AIX:
+    Arduino:
+        board: ANY
+    Emscripten:
+    Neutrino:
+        version: ["6.4", "6.5", "6.6", "7.0", "7.1"]
+    baremetal:
+    VxWorks:
+        version: ["7"]
+arch: [x86, x86_64, ppc32be, ppc32, ppc64le, ppc64, armv4, armv4i, armv5el, armv5hf, armv6, armv7, armv7hf, armv7s, armv7k, armv8, armv8_32, armv8.3, sparc, sparcv9, mips, mips64, avr, s390, s390x, asm.js, wasm, sh4le, e2k-v2, e2k-v3, e2k-v4, e2k-v5, e2k-v6, e2k-v7, xtensalx6, xtensalx106, xtensalx7]
+compiler:
+    sun-cc:
+        version: ["5.10", "5.11", "5.12", "5.13", "5.14", "5.15"]
+        threads: [None, posix]
+        libcxx: [libCstd, libstdcxx, libstlport, libstdc++]
+    gcc: &gcc
+        version: ["4.1", "4.4", "4.5", "4.6", "4.7", "4.8", "4.9",
+                  "5", "5.1", "5.2", "5.3", "5.4", "5.5",
+                  "6", "6.1", "6.2", "6.3", "6.4", "6.5",
+                  "7", "7.1", "7.2", "7.3", "7.4", "7.5",
+                  "8", "8.1", "8.2", "8.3", "8.4",
+                  "9", "9.1", "9.2", "9.3", "9.4",
+                  "10", "10.1", "10.2", "10.3",
+                  "11", "11.1", "11.2",
+                  "12"]
+        libcxx: [libstdc++, libstdc++11]
+        threads: [None, posix, win32]  # Windows MinGW
+        exception: [None, dwarf2, sjlj, seh]  # Windows MinGW
+        cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20, 23, gnu23]
+    Visual Studio: &visual_studio
+        runtime: [MD, MT, MTd, MDd]
+        version: ["8", "9", "10", "11", "12", "14", "15", "16", "17"]
+        toolset: [None, v90, v100, v110, v110_xp, v120, v120_xp,
+                  v140, v140_xp, v140_clang_c2, LLVM-vs2012, LLVM-vs2012_xp,
+                  LLVM-vs2013, LLVM-vs2013_xp, LLVM-vs2014, LLVM-vs2014_xp,
+                  LLVM-vs2017, LLVM-vs2017_xp, v141, v141_xp, v141_clang_c2, v142,
+                  llvm, ClangCL, v143]
+        cppstd: [None, 14, 17, 20, 23]
+    msvc:
+        version: [170, 180, 190, 191, 192, 193]
+        update: [None, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+        runtime: [static, dynamic]
+        runtime_type: [Debug, Release]
+        cppstd: [98, 14, 17, 20, 23]
+        toolset: [None, v110_xp, v120_xp, v140_xp, v141_xp]
+    clang:
+        version: ["3.3", "3.4", "3.5", "3.6", "3.7", "3.8", "3.9", "4.0",
+                  "5.0", "6.0", "7.0", "7.1",
+                  "8", "9", "10", "11", "12", "13", "14", "15", "16"]
+        libcxx: [None, libstdc++, libstdc++11, libc++, c++_shared, c++_static]
+        cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20, 23, gnu23]
+        runtime: [None, MD, MT, MTd, MDd, static, dynamic]
+        runtime_type: [None, Debug, Release]
+    apple-clang: &apple_clang
+        version: ["5.0", "5.1", "6.0", "6.1", "7.0", "7.3", "8.0", "8.1", "9.0", "9.1", "10.0", "11.0", "12.0", "13", "13.0", "13.1"]
+        libcxx: [libstdc++, libc++]
+        cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20]
+    intel:
+        version: ["11", "12", "13", "14", "15", "16", "17", "18", "19", "19.1"]
+        update: [None, ANY]
+        base:
+            gcc:
+                <<: *gcc
+                threads: [None]
+                exception: [None]
+            Visual Studio:
+                <<: *visual_studio
+            apple-clang:
+                <<: *apple_clang
+    intel-cc:
+        version: ["2021.1", "2021.2", "2021.3"]
+        update: [None, ANY]
+        mode: ["icx", "classic", "dpcpp"]
+        libcxx: [None, libstdc++, libstdc++11, libc++]
+        cppstd: [None, 98, gnu98, 03, gnu03, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20, 23, gnu23]
+        runtime: [None, static, dynamic]
+        runtime_type: [None, Debug, Release]
+    qcc:
+        version: ["4.4", "5.4", "8.3"]
+        libcxx: [cxx, gpp, cpp, cpp-ne, accp, acpp-ne, ecpp, ecpp-ne]
+        cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17]
+    mcst-lcc:
+        version: ["1.19", "1.20", "1.21", "1.22", "1.23", "1.24", "1.25"]
+        base:
+            gcc:
+                <<: *gcc
+                threads: [None]
+                exceptions: [None]
+
+build_type: [None, Debug, Release, RelWithDebInfo, MinSizeRel]
+
+
+cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20, 23, gnu23]  # Deprecated, use compiler.cppstd
+"""


Test patch:
diff --git a/conans/test/assets/sources.py b/conans/test/assets/sources.py
index 052e96b90..91e386870 100644
--- a/conans/test/assets/sources.py
+++ b/conans/test/assets/sources.py
@@ -27,6 +27,10 @@ int {{name}}(){
     std::cout << "  {{ msg or name }} _M_IX86 defined\n";
     #endif
 
+    #ifdef _M_ARM64
+    std::cout << "   {{ msg or name }} _M_ARM64 defined\n";
+    #endif
+
     #if __i386__
     std::cout << "  {{ msg or name }} __i386__ defined\n";
     #endif
@@ -34,6 +38,10 @@ int {{name}}(){
     #if __x86_64__
     std::cout << "  {{ msg or name }} __x86_64__ defined\n";
     #endif
+  
+    #if __aarch64__
+    std::cout << "  {{ msg or name }} __aarch64__ defined\n";
+    #endif
 
     // Libstdc++
     #if defined _GLIBCXX_USE_CXX11_ABI
diff --git a/conans/test/conftest.py b/conans/test/conftest.py
index 5a8716836..be571fd11 100644
--- a/conans/test/conftest.py
+++ b/conans/test/conftest.py
@@ -174,12 +174,16 @@ try:
 except ImportError as e:
     user_tool_locations = None
 
+if platform.machine() == "arm64":
+    android_ndk_path = "/opt/homebrew/share/android-ndk"
+else:
+    android_ndk_path = "/usr/local/share/android-ndk"
 tools_environments = {
     'mingw32': {'Windows': {'MSYSTEM': 'MINGW32'}},
     'mingw64': {'Windows': {'MSYSTEM': 'MINGW64'}},
     'ucrt64': {'Windows': {'MSYSTEM': 'UCRT64'}},
     'msys2_clang64': {"Windows": {"MSYSTEM": "CLANG64"}},
-    'android_ndk': {'Darwin': {'TEST_CONAN_ANDROID_NDK': '/usr/local/share/android-ndk'}}
+    'android_ndk': {'Darwin': {'TEST_CONAN_ANDROID_NDK': android_ndk_path}}
 }
 
 
diff --git a/conans/test/functional/layout/test_editable_cmake.py b/conans/test/functional/layout/test_editable_cmake.py
index a7e01b4e1..a6ccef494 100644
--- a/conans/test/functional/layout/test_editable_cmake.py
+++ b/conans/test/functional/layout/test_editable_cmake.py
@@ -110,12 +110,13 @@ def editable_cmake_exe(generator):
         build_dep()
 
     def run_pkg(msg):
+        host_arch = c.get_default_host_profile().settings['arch']
         # FIXME: This only works with ``--install-folder``, layout() will break this
-        cmd_release = environment_wrap_command("conanrunenv-release-x86_64", c.current_folder,
+        cmd_release = environment_wrap_command(f"conanrunenv-release-{host_arch}", c.current_folder,
                                                "dep_app",)
         c.run_command(cmd_release)
         assert "{}: Release!".format(msg) in c.out
-        cmd_release = environment_wrap_command("conanrunenv-debug-x86_64", c.current_folder,
+        cmd_release = environment_wrap_command(f"conanrunenv-debug-{host_arch}", c.current_folder,
                                                "dep_app", )
         c.run_command(cmd_release)
         assert "{}: Debug!".format(msg) in c.out
diff --git a/conans/test/functional/layout/test_in_cache.py b/conans/test/functional/layout/test_in_cache.py
index d53d8a6dc..13c386808 100644
--- a/conans/test/functional/layout/test_in_cache.py
+++ b/conans/test/functional/layout/test_in_cache.py
@@ -268,7 +268,8 @@ def test_cpp_package():
     assert "**includedirs:['foo/include']**" in out
     assert "**libdirs:['foo/libs']**" in out
     assert "**libs:['foo']**" in out
-    cmake = client.load("hello-release-x86_64-data.cmake")
+    arch = client.get_default_host_profile().settings['arch']
+    cmake = client.load(f"hello-release-{arch}-data.cmake")
 
     assert 'set(hello_INCLUDE_DIRS_RELEASE "${hello_PACKAGE_FOLDER_RELEASE}/foo/include")' in cmake
     assert 'set(hello_LIB_DIRS_RELEASE "${hello_PACKAGE_FOLDER_RELEASE}/foo/libs")' in cmake
diff --git a/conans/test/functional/toolchains/apple/test_xcodedeps_components.py b/conans/test/functional/toolchains/apple/test_xcodedeps_components.py
index d4898bff1..2a50ab1e0 100644
--- a/conans/test/functional/toolchains/apple/test_xcodedeps_components.py
+++ b/conans/test/functional/toolchains/apple/test_xcodedeps_components.py
@@ -187,9 +187,11 @@ def test_xcodedeps_components():
     assert '#include "conan_network_client.xcconfig"' in chat_xcconfig
     assert '#include "conan_network_server.xcconfig"' not in chat_xcconfig
     assert '#include "conan_network_network.xcconfig"' not in chat_xcconfig
+    host_arch = client.get_default_host_profile().settings['arch']
+    arch = "arm64" if host_arch == "armv8" else host_arch
     client.run_command("xcodegen generate")
-    client.run_command("xcodebuild -project ChatApp.xcodeproj -configuration Release -arch x86_64")
-    client.run_command("xcodebuild -project ChatApp.xcodeproj -configuration Debug -arch x86_64")
+    client.run_command(f"xcodebuild -project ChatApp.xcodeproj -configuration Release -arch {arch}")
+    client.run_command(f"xcodebuild -project ChatApp.xcodeproj -configuration Debug -arch {arch}")
     client.run_command("build/Debug/chat")
     assert "core/1.0: Hello World Debug!" in client.out
     assert "tcp/1.0: Hello World Debug!" in client.out
@@ -220,7 +222,10 @@ def test_xcodedeps_test_require():
         ''')
     client.save({"conanfile.py": conanfile}, clean_first=True)
     client.run("install . -g XcodeDeps")
+    host_arch = client.get_default_host_profile().settings['arch']
+    arch = "arm64" if host_arch == "armv8" else host_arch
     assert os.path.isfile(os.path.join(client.current_folder, "conan_gtest.xcconfig"))
     assert os.path.isfile(os.path.join(client.current_folder, "conan_gtest_gtest.xcconfig"))
-    assert os.path.isfile(os.path.join(client.current_folder, "conan_gtest_gtest_release_x86_64.xcconfig"))
+    assert os.path.isfile(os.path.join(client.current_folder,
+                                       f"conan_gtest_gtest_release_{arch}.xcconfig"))
     assert '#include "conan_gtest.xcconfig"' in client.load("conandeps.xcconfig")
diff --git a/conans/test/functional/toolchains/apple/test_xcodetoolchain.py b/conans/test/functional/toolchains/apple/test_xcodetoolchain.py
index 7590f5adc..6737ff8ea 100644
--- a/conans/test/functional/toolchains/apple/test_xcodetoolchain.py
+++ b/conans/test/functional/toolchains/apple/test_xcodetoolchain.py
@@ -6,15 +6,17 @@ import pytest
 from conans.test.assets.sources import gen_function_cpp
 from conans.test.utils.tools import TestClient
 
-
 test = textwrap.dedent("""
     import os
-    from conans import ConanFile, tools
+    from conan import ConanFile, tools
+    from conan.tools.build import can_run
     class TestApp(ConanFile):
         settings = "os", "compiler", "build_type", "arch"
         generators = "VirtualRunEnv"
+        def requirements(self):
+            self.requires(self.tested_reference_str)
         def test(self):
-            if not tools.cross_building(self):
+            if can_run(self):
                 self.run("app", env="conanrun")
     """)
 
@@ -35,8 +37,8 @@ def test_project_xcodetoolchain(cppstd, cppstd_output, min_version):
     conanfile = textwrap.dedent("""
         import os
         from conan import ConanFile
-        from conan.tools.files import copy
         from conan.tools.apple import XcodeBuild
+        from conan.tools.files import copy
         class MyApplicationConan(ConanFile):
             name = "myapplication"
             version = "1.0"
@@ -44,6 +46,7 @@ def test_project_xcodetoolchain(cppstd, cppstd_output, min_version):
             settings = "os", "compiler", "build_type", "arch"
             generators = "XcodeDeps", "XcodeToolchain"
             exports_sources = "app.xcodeproj/*", "app/*"
+            package_type = "application"
             def build(self):
                 xcode = XcodeBuild(self)
                 xcode.build("app.xcodeproj")
diff --git a/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps.py b/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps.py
index 7e6d86dd4..cd5c87ad5 100644
--- a/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps.py
+++ b/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps.py
@@ -64,7 +64,8 @@ def test_transitive_multi(client):
         # to skip finding first possible FindBye somewhere
         assert "find_dependency(${_DEPENDENCY} REQUIRED ${${_DEPENDENCY}_FIND_MODE})" \
                in client.load("libb-config.cmake")
-        assert 'set(liba_FIND_MODE "NO_MODULE")' in client.load("libb-release-x86_64-data.cmake")
+        arch = client.get_default_host_profile().settings['arch']
+        assert 'set(liba_FIND_MODE "NO_MODULE")' in client.load(f"libb-release-{arch}-data.cmake")
 
         if platform.system() == "Windows":
             client.run_command('cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake')
@@ -357,13 +358,13 @@ def test_custom_configuration(client):
                cmake.build_context_suffix["liba"] = "_build"
                cmake.generate()
        """)
-
+    host_arch = client.get_default_host_profile().settings['arch']
     client.save({"conanfile.py": conanfile})
     client.run("install . -pr:h default -s:b build_type=RelWithDebInfo"
                " -pr:b default -s:b arch=x86 --build missing")
     curdir = client.current_folder
     data_name_context_build = "liba_build-relwithdebinfo-x86-data.cmake"
-    data_name_context_host = "liba-debug-x86_64-data.cmake"
+    data_name_context_host = f"liba-debug-{host_arch}-data.cmake"
     assert os.path.exists(os.path.join(curdir, data_name_context_build))
     assert os.path.exists(os.path.join(curdir, data_name_context_host))
 
@@ -506,7 +507,8 @@ def test_system_dep():
 
     client.run("install consumer")
     if platform.system() != "Windows":
-        data = os.path.join("consumer/build/generators/mylib-release-x86_64-data.cmake")
+        host_arch = client.get_default_host_profile().settings['arch']
+        data = os.path.join(f"consumer/build/generators/mylib-release-{host_arch}-data.cmake")
         contents = client.load(data)
         assert 'set(ZLIB_FIND_MODE "")' in contents
 
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 da0f0d015..a6f7aaf93 100644
--- a/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_components.py
+++ b/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_components.py
@@ -67,8 +67,8 @@ class PropagateSpecificComponents(unittest.TestCase):
     def test_cmakedeps_multi(self):
         t = TestClient(cache_folder=self.cache_folder)
         t.run('install middle/version@ -g CMakeDeps')
-
-        content = t.load('middle-release-x86_64-data.cmake')
+        arch = t.get_default_host_profile().settings['arch']
+        content = t.load(f'middle-release-{arch}-data.cmake')
         self.assertIn("list(APPEND middle_FIND_DEPENDENCY_NAMES top)", content)
 
         content = t.load('middle-Target-release.cmake')
diff --git a/conans/test/functional/toolchains/cmake/test_cmake.py b/conans/test/functional/toolchains/cmake/test_cmake.py
index e84fc0981..7b5fde432 100644
--- a/conans/test/functional/toolchains/cmake/test_cmake.py
+++ b/conans/test/functional/toolchains/cmake/test_cmake.py
@@ -436,17 +436,27 @@ class AppleTest(Base):
         vals = {"CMAKE_CXX_STANDARD": cppstd,
                 "CMAKE_CXX_EXTENSIONS": extensions_str,
                 "CMAKE_BUILD_TYPE": build_type,
-                "CMAKE_CXX_FLAGS": "-m64 -stdlib=libc++",
                 "CMAKE_CXX_FLAGS_DEBUG": "-g",
                 "CMAKE_CXX_FLAGS_RELEASE": "-O3 -DNDEBUG",
-                "CMAKE_C_FLAGS": "-m64",
                 "CMAKE_C_FLAGS_DEBUG": "-g",
                 "CMAKE_C_FLAGS_RELEASE": "-O3 -DNDEBUG",
-                "CMAKE_SHARED_LINKER_FLAGS": "-m64",
-                "CMAKE_EXE_LINKER_FLAGS": "-m64",
                 "CMAKE_INSTALL_NAME_DIR": ""
                 }
 
+        host_arch = self.client.get_default_host_profile().settings['arch']
+
+        if host_arch == "x86_64":
+            vals.update({
+                "CMAKE_C_FLAGS": "-m64",
+                "CMAKE_CXX_FLAGS": "-m64 -stdlib=libc++",
+                "CMAKE_SHARED_LINKER_FLAGS": "-m64",
+                "CMAKE_EXE_LINKER_FLAGS": "-m64",
+            })
+        else:
+            vals.update({
+                "CMAKE_CXX_FLAGS": "-stdlib=libc++",
+            })
+
         def _verify_out(marker=">>"):
             if shared:
                 self.assertIn("libapp_lib.dylib", self.client.out)
diff --git a/conans/test/functional/toolchains/cmake/test_cmake_toolchain_m1.py b/conans/test/functional/toolchains/cmake/test_cmake_toolchain_m1.py
index 615bd76de..f81d04228 100644
--- a/conans/test/functional/toolchains/cmake/test_cmake_toolchain_m1.py
+++ b/conans/test/functional/toolchains/cmake/test_cmake_toolchain_m1.py
@@ -64,8 +64,13 @@ def test_m1(op_system):
     assert "CMAKE_SYSTEM_PROCESSOR: arm64" in client.out
     main_path = "./build/Release/main.app/main" if op_system == "iOS" \
         else "./build/Release/main"
-    client.run_command(main_path, assert_error=True)
-    assert "Bad CPU type in executable" in client.out
     client.run_command("lipo -info {}".format(main_path))
     assert "Non-fat file" in client.out
     assert "is architecture: arm64" in client.out
+    client.run_command(f"vtool -show-build {main_path}")
+
+    if op_system == "Macos":
+        assert "platform MACOS"
+    elif op_system == "iOS":
+        assert "platform IOS"
+        assert "minos 12.0"
\ No newline at end of file
diff --git a/conans/test/functional/toolchains/gnu/autotools/test_basic.py b/conans/test/functional/toolchains/gnu/autotools/test_basic.py
index b7c507c21..51b397fd6 100644
--- a/conans/test/functional/toolchains/gnu/autotools/test_basic.py
+++ b/conans/test/functional/toolchains/gnu/autotools/test_basic.py
@@ -53,8 +53,9 @@ def test_autotools():
     client.run("build .")
     client.run_command("./main")
     cxx11_abi = 0 if platform.system() == "Linux" else None
-    compiler = "gcc" if platform.system() == "Linux" else "clang"
-    check_exe_run(client.out, "main", compiler, None, "Release", "x86_64", None, cxx11_abi=cxx11_abi)
+    compiler = "gcc" if platform.system() == "Linux" else "apple-clang"
+    host_arch = client.get_default_host_profile().settings['arch']
+    check_exe_run(client.out, "main", compiler, None, "Release", host_arch, None, cxx11_abi=cxx11_abi)
     assert "hello/0.1: Hello World Release!" in client.out
 
 
diff --git a/conans/test/functional/toolchains/gnu/autotools/test_ios.py b/conans/test/functional/toolchains/gnu/autotools/test_ios.py
index 51f17f3c0..565e67da0 100644
--- a/conans/test/functional/toolchains/gnu/autotools/test_ios.py
+++ b/conans/test/functional/toolchains/gnu/autotools/test_ios.py
@@ -70,18 +70,21 @@ def test_ios():
                  "m1": profile}, clean_first=True)
     client.run("install . --profile:build=default --profile:host=m1")
     client.run("build .")
-    client.run_command("./main", assert_error=True)
-    assert "Bad CPU type in executable" in client.out
     client.run_command("lipo -info main")
     assert "Non-fat file: main is architecture: arm64" in client.out
+    client.run_command("vtool -show-build main")
+    assert "platform IOS" in client.out
+    assert "minos 12.0" in client.out
 
     conanbuild = load_toolchain_args(client.current_folder)
     configure_args = conanbuild["configure_args"]
     make_args = conanbuild["make_args"]
     autoreconf_args = conanbuild["autoreconf_args"]
+    build_arch = client.get_default_build_profile().settings['arch']
+    build_arch = "aarch64" if build_arch == "armv8" else build_arch
     assert configure_args == "'--prefix=/' '--bindir=${prefix}/bin' '--sbindir=${prefix}/bin' " \
                              "'--libdir=${prefix}/lib' '--includedir=${prefix}/include' " \
                              "'--oldincludedir=${prefix}/include' '--datarootdir=${prefix}/res' " \
-                             "'--host=aarch64-apple-ios' '--build=x86_64-apple-darwin'"
+                             f"'--host=aarch64-apple-ios' '--build={build_arch}-apple-darwin'"
     assert make_args == ""
     assert autoreconf_args == "'--force' '--install'"
diff --git a/conans/test/functional/toolchains/meson/_base.py b/conans/test/functional/toolchains/meson/_base.py
index 3200a6aaf..41c2d6858 100644
--- a/conans/test/functional/toolchains/meson/_base.py
+++ b/conans/test/functional/toolchains/meson/_base.py
@@ -17,22 +17,29 @@ class TestMesonBase(unittest.TestCase):
 
     @property
     def _settings(self):
+        interpreter_arch = platform.machine()
+        if interpreter_arch in ["x86_64", "AMD64"]:
+            host_arch = "x86_64"
+        elif interpreter_arch in ["arm64", "aarch64", "ARM64"]:
+            host_arch = "armv8"
+        else:
+            host_ach = interpreter_arch
         settings_macosx = {"compiler": "apple-clang",
                            "compiler.libcxx": "libc++",
-                           "compiler.version": "13.0",
-                           "arch": "x86_64",
+                           "compiler.version": "13",
+                           "arch": host_arch,
                            "build_type": "Release"}
 
         settings_windows = {"compiler": "Visual Studio",
                             "compiler.version": "15",
                             "compiler.runtime": "MD",
-                            "arch": "x86_64",
+                            "arch": host_arch,
                             "build_type": "Release"}
 
         settings_linux = {"compiler": "gcc",
                           "compiler.version": "5",
                           "compiler.libcxx": "libstdc++",
-                          "arch": "x86_64",
+                          "arch": host_arch,
                           "build_type": "Release"}
 
         return {"Darwin": settings_macosx,
@@ -44,17 +51,23 @@ class TestMesonBase(unittest.TestCase):
         return " ".join('-s %s="%s"' % (k, v) for k, v in self._settings.items() if v)
 
     def _check_binary(self):
+        # FIXME: Some values are hardcoded to match the CI setup
+        host_arch =  self.t.get_default_host_profile().settings['arch']
+        arch_macro = {
+            "gcc": {"armv8": "__aarch64__", "x86_64": "__x86_64__"},
+            "msvc": {"armv8": "_M_ARM64", "x86_64": "_M_X64"}
+        }
         if platform.system() == "Darwin":
-            self.assertIn("main __x86_64__ defined", self.t.out)
+            self.assertIn(f"main {arch_macro['gcc'][host_arch]} defined", self.t.out)
             self.assertIn("main __apple_build_version__", self.t.out)
             self.assertIn("main __clang_major__13", self.t.out)
             # TODO: check why __clang_minor__ seems to be not defined in XCode 12
             # commented while migrating to XCode12 CI
             # self.assertIn("main __clang_minor__0", self.t.out)
         elif platform.system() == "Windows":
-            self.assertIn("main _M_X64 defined", self.t.out)
+            self.assertIn(f"main {arch_macro['msvc'][host_arch]} defined", self.t.out)
             self.assertIn("main _MSC_VER19", self.t.out)
             self.assertIn("main _MSVC_LANG2014", self.t.out)
         elif platform.system() == "Linux":
-            self.assertIn("main __x86_64__ defined", self.t.out)
+            self.assertIn(f"main {arch_macro['gcc'][host_arch]} defined", self.t.out)
             self.assertIn("main __GNUC__5", self.t.out)
diff --git a/conans/test/functional/toolchains/microsoft/test_msbuilddeps.py b/conans/test/functional/toolchains/microsoft/test_msbuilddeps.py
index e950df38e..9c6a9120b 100644
--- a/conans/test/functional/toolchains/microsoft/test_msbuilddeps.py
+++ b/conans/test/functional/toolchains/microsoft/test_msbuilddeps.py
@@ -672,6 +672,7 @@ def test_exclude_code_analysis(pattern, exclude_a, exclude_b):
         """)
     profile = textwrap.dedent("""
         include(default)
+        [settings]
         build_type=Release
         arch=x86_64
         [conf]
diff --git a/conans/test/functional/tools/old/vcvars/vcvars_test.py b/conans/test/functional/tools/old/vcvars/vcvars_test.py
index a99fbff8b..90871d2d4 100644
--- a/conans/test/functional/tools/old/vcvars/vcvars_test.py
+++ b/conans/test/functional/tools/old/vcvars/vcvars_test.py
@@ -127,6 +127,8 @@ class VCVarsTest(unittest.TestCase):
     def test_vcvars_raises_when_not_found(self):
         text = """
 os: [Windows]
+arch: [x86_64]
+arch_build: [x86_64]
 compiler:
     Visual Studio:
         version: ["5"]
@@ -135,6 +137,8 @@ compiler:
         settings.os = "Windows"
         settings.compiler = "Visual Studio"
         settings.compiler.version = "5"
+        settings.arch = "x86_64"
+        settings.arch_build = "x86_64"
         with six.assertRaisesRegex(self, ConanException,
                                    "VS non-existing installation: Visual Studio 5"):
             output = ConanOutput(StringIO())
diff --git a/conans/test/functional/utils.py b/conans/test/functional/utils.py
index b4d121735..ddcda2346 100644
--- a/conans/test/functional/utils.py
+++ b/conans/test/functional/utils.py
@@ -86,6 +86,8 @@ def check_exe_run(output, names, compiler, version, build_type, arch, cppstd, de
                 assert "{} _M_IX86 defined".format(name) in output
             elif arch == "x86_64":
                 assert "{} _M_X64 defined".format(name) in output
+            elif arch == "armv8":
+                assert "{} _M_ARM64 defined".format(name) in output
             else:
                 assert arch is None, "checked don't know how to validate this architecture"
 
diff --git a/conans/test/integration/command/install/test_install_transitive.py b/conans/test/integration/command/install/test_install_transitive.py
index 86e3c3179..442a58a5c 100644
--- a/conans/test/integration/command/install/test_install_transitive.py
+++ b/conans/test/integration/command/install/test_install_transitive.py
@@ -15,7 +15,7 @@ from conans.util.files import save
 @pytest.fixture()
 def client():
     c = TestClient()
-    save(c.cache.settings_path, "os: [Windows, Macos, Linux, FreeBSD]\nos_build: [Windows, Macos]")
+    save(c.cache.settings_path, "os: [Windows, Macos, Linux, FreeBSD]\nos_build: [Windows, Macos]\narch_build: [x86_64]")
     save(c.cache.default_profile_path, "[settings]\nos=Windows")
 
     def base_conanfile(name):
@@ -205,12 +205,12 @@ def test_change_option_txt(client):
 
 def test_cross_platform_msg(client):
     # Explicit with os_build and os_arch settings
-    client.run("install Hello0/0.1@lasote/stable -s os_build=Macos -s os=Windows", assert_error=True)
+    client.run("install Hello0/0.1@lasote/stable -s os_build=Macos -s arch_build=x86_64 -s os=Windows", assert_error=True)
     assert "Cross-build from 'Macos:x86_64' to 'Windows:None'" in client.out
     assert "ERROR: Missing binary: Hello0" in client.out
 
     bad_os = "Windows" if platform.system() != "Windows" else "Macos"
-    client.run("install Hello0/0.1@lasote/stable -s os={}".format(bad_os), assert_error=True)
+    client.run("install Hello0/0.1@lasote/stable -s os={} -s arch_build=x86_64".format(bad_os), assert_error=True)
     # Implicit detection when not available (retrocompatibility)
     message = "Cross-build from '{}:x86_64' to '{}:None'".format(detected_os(), bad_os)
     assert message in client.out
diff --git a/conans/test/integration/environment/test_env.py b/conans/test/integration/environment/test_env.py
index aad9b27bd..f60c0c4db 100644
--- a/conans/test/integration/environment/test_env.py
+++ b/conans/test/integration/environment/test_env.py
@@ -676,10 +676,8 @@ def test_files_always_created():
     c.run("install consumer -g VirtualBuildEnv -g VirtualRunEnv")
     ext = "bat" if platform.system() == "Windows" else "sh"
 
-    assert os.path.isfile(os.path.join(c.current_folder, "conanbuild.{}".format(ext)))
-    assert os.path.isfile(os.path.join(c.current_folder, "conanrun.{}".format(ext)))
-    assert os.path.isfile(os.path.join(c.current_folder,
-                                       "conanbuildenv-release-x86_64.{}".format(ext)))
-    assert os.path.isfile(os.path.join(c.current_folder,
-                                       "conanbuildenv-release-x86_64.{}".format(ext)))
-
+    arch = c.get_default_host_profile().settings['arch']
+    assert os.path.isfile(os.path.join(c.current_folder, f"conanbuild.{ext}"))
+    assert os.path.isfile(os.path.join(c.current_folder, f"conanrun.{ext}"))
+    assert os.path.isfile(os.path.join(c.current_folder, f"conanbuildenv-release-{arch}.{ext}"))
+    assert os.path.isfile(os.path.join(c.current_folder, f"conanbuildenv-release-{arch}.{ext}"))
diff --git a/conans/test/integration/package_id/package_id_test.py b/conans/test/integration/package_id/package_id_test.py
index 568a6325e..cb8a51028 100644
--- a/conans/test/integration/package_id/package_id_test.py
+++ b/conans/test/integration/package_id/package_id_test.py
@@ -129,8 +129,8 @@ def test_build_type_remove_windows():
         """)
     client.save({"conanfile.py": conanfile})
     client.run('create . pkg/0.1@ -s os=Windows -s compiler="Visual Studio" '
-               '-s compiler.version=14 -s build_type=Release')
+               '-s compiler.version=14 -s build_type=Release -s arch=x86_64')
     assert "pkg/0.1:e1f7c8ffe5f9342d04ab704810faf93060ae3d70 - Build" in client.out
     client.run('install pkg/0.1@ -s os=Windows -s compiler="Visual Studio" '
-               '-s compiler.version=14 -s build_type=Debug')
+               '-s compiler.version=14 -s build_type=Debug -s arch=x86_64')
     assert "pkg/0.1:e1f7c8ffe5f9342d04ab704810faf93060ae3d70 - Cache" in client.out
diff --git a/conans/test/integration/toolchains/apple/test_xcodedeps.py b/conans/test/integration/toolchains/apple/test_xcodedeps.py
index 3467b7da2..fdc555a0c 100644
--- a/conans/test/integration/toolchains/apple/test_xcodedeps.py
+++ b/conans/test/integration/toolchains/apple/test_xcodedeps.py
@@ -155,7 +155,10 @@ def test_xcodedeps_aggregate_components():
     component7_entry = client.load("conan_libb_libb_comp7.xcconfig")
     assert '#include "conan_liba_liba.xcconfig"' in component7_entry
 
-    component7_vars = client.load("conan_libb_libb_comp7_release_x86_64.xcconfig")
+    arch_setting = client.get_default_host_profile().settings['arch']
+    arch = "arm64" if arch_setting == "armv8" else arch_setting
+
+    component7_vars = client.load(f"conan_libb_libb_comp7_release_{arch}.xcconfig")
 
     # all of the transitive required components and the component itself are added
     for index in range(1, 8):
@@ -163,7 +166,7 @@ def test_xcodedeps_aggregate_components():
 
     assert "mylibdir" in component7_vars
 
-    component4_vars = client.load("conan_libb_libb_comp4_release_x86_64.xcconfig")
+    component4_vars = client.load(f"conan_libb_libb_comp4_release_{arch}.xcconfig")
 
     # all of the transitive required components and the component itself are added
     for index in range(1, 5):
@@ -193,7 +196,10 @@ def test_xcodedeps_frameworkdirs():
 
     client.run("install lib_a/1.0@ -g XcodeDeps")
 
-    lib_a_xcconfig = client.load("conan_lib_a_lib_a_release_x86_64.xcconfig")
+    arch_setting = client.get_default_host_profile().settings['arch']
+    arch = "arm64" if arch_setting == "armv8" else arch_setting
+
+    lib_a_xcconfig = client.load(f"conan_lib_a_lib_a_release_{arch}.xcconfig")
 
     assert "lib_a_frameworkdir" in lib_a_xcconfig
 
diff --git a/conans/test/integration/toolchains/apple/test_xcodetoolchain.py b/conans/test/integration/toolchains/apple/test_xcodetoolchain.py
index 4aef8e16d..457c15a17 100644
--- a/conans/test/integration/toolchains/apple/test_xcodetoolchain.py
+++ b/conans/test/integration/toolchains/apple/test_xcodetoolchain.py
@@ -36,6 +36,7 @@ def test_toolchain_files(configuration, os_version, cppstd, libcxx, arch, sdk_na
     cmd = cmd + " -s compiler.cppstd={}".format(cppstd) if cppstd else cmd
     cmd = cmd + " -s os.sdk={}".format(sdk_name) if sdk_name else cmd
     cmd = cmd + " -s os.sdk_version={}".format(sdk_version) if sdk_version else cmd
+    cmd = cmd + " -s arch={}".format(arch) if arch else cmd
     client.run(cmd)
     filename = _get_filename(configuration, arch, sdk_name, sdk_version)
     condition = _condition(configuration, arch, sdk_name, sdk_version)
diff --git a/conans/test/integration/toolchains/cmake/cmakedeps/test_cmakedeps.py b/conans/test/integration/toolchains/cmake/cmakedeps/test_cmakedeps.py
index 5b7ee09fe..0cf208de5 100644
--- a/conans/test/integration/toolchains/cmake/cmakedeps/test_cmakedeps.py
+++ b/conans/test/integration/toolchains/cmake/cmakedeps/test_cmakedeps.py
@@ -37,7 +37,8 @@ def test_package_from_system():
     assert os.path.exists(os.path.join(client.current_folder, "dep1-config.cmake"))
     assert not os.path.exists(os.path.join(client.current_folder, "dep2-config.cmake"))
     assert not os.path.exists(os.path.join(client.current_folder, "custom_dep2-config.cmake"))
-    dep1_contents = client.load("dep1-release-x86_64-data.cmake")
+    host_arch = client.get_default_host_profile().settings['arch']
+    dep1_contents = client.load(f"dep1-release-{host_arch}-data.cmake")
     assert 'list(APPEND dep1_FIND_DEPENDENCY_NAMES custom_dep2)' in dep1_contents
     assert 'set(custom_dep2_FIND_MODE "")' in dep1_contents
 
@@ -61,7 +62,7 @@ def test_test_package():
             requires = "pkg/1.0"
         """)
     client.save({"conanfile.py": consumer})
-    client.run("install . -s:b os=Windows -s:h os=Linux --build=missing")
+    client.run("install . -s:b os=Windows -s:h os=Linux -s:h arch=x86_64 --build=missing")
     cmake_data = client.load("pkg-release-x86_64-data.cmake")
     assert "gtest" not in cmake_data
 
@@ -179,7 +180,8 @@ def test_cmakedeps_cppinfo_complex_strings():
     client.run("export . hello/1.0@")
     client.save({"conanfile.txt": "[requires]\nhello/1.0\n"}, clean_first=True)
     client.run("install . --build=missing -g CMakeDeps")
-    deps = client.load("hello-release-x86_64-data.cmake")
+    arch = client.get_default_host_profile().settings['arch']
+    deps = client.load(f"hello-release-{arch}-data.cmake")
     assert r"escape=partially \"escaped\"" in deps
     assert r"spaces=me you" in deps
     assert r"foobar=bazbuz" in deps
diff --git a/conans/test/integration/toolchains/cmake/test_cmaketoolchain.py b/conans/test/integration/toolchains/cmake/test_cmaketoolchain.py
index 08262873f..d22ee397a 100644
--- a/conans/test/integration/toolchains/cmake/test_cmaketoolchain.py
+++ b/conans/test/integration/toolchains/cmake/test_cmaketoolchain.py
@@ -491,7 +491,16 @@ def test_android_c_library():
 
         """)
     client.save({"conanfile.py": conanfile})
-    client.run("create . foo/1.0@ -s os=Android -s os.api_level=23 -c tools.android:ndk_path=/foo")
+    # Settings
+    settings = "-s arch=x86_64 -s os=Android -s os.api_level=23 -c tools.android:ndk_path=/foo"
+    # Checking the Android variables created
+    # Issue: https://github.com/conan-io/conan/issues/11798
+    client.run("install . " + settings)
+    conan_toolchain = client.load(os.path.join(client.current_folder, "conan_toolchain.cmake"))
+    assert "set(ANDROID_PLATFORM android-23)" in conan_toolchain
+    assert "set(ANDROID_ABI x86_64)" in conan_toolchain
+    assert "include(/foo/build/cmake/android.toolchain.cmake)" in conan_toolchain
+    client.run("create . foo/1.0@ " + settings)
 
 
 def test_user_presets_version2():
diff --git a/conans/test/integration/toolchains/microsoft/test_msbuilddeps.py b/conans/test/integration/toolchains/microsoft/test_msbuilddeps.py
index 94cea9522..0076538a0 100644
--- a/conans/test/integration/toolchains/microsoft/test_msbuilddeps.py
+++ b/conans/test/integration/toolchains/microsoft/test_msbuilddeps.py
@@ -1,4 +1,5 @@
 import os
+import textwrap
 
 import pytest
 
@@ -21,3 +22,28 @@ def test_msbuilddeps_maps_architecture_to_platform(arch, exp_platform):
     toolchain = client.load(os.path.join("conan", "conantoolchain.props"))
     expected_import = f"""<Import Condition="'$(Configuration)' == 'Release' And '$(Platform)' == '{exp_platform}'" Project="conantoolchain_release_{exp_platform.lower()}.props"/>"""
     assert expected_import in toolchain
+
+
+def test_msbuilddeps_format_names():
+    c = TestClient()
+    conanfile = textwrap.dedent("""
+        from conan import ConanFile
+        class Pkg(ConanFile):
+            settings = "os", "compiler", "build_type", "arch"
+            name = "pkg"
+            version = "1.0"
+
+            def package_info(self):
+                self.cpp_info.components["libmpdecimal++"].libs = ["libmp++"]
+        """)
+    c.save({"conanfile.py": conanfile})
+    c.run("create .")
+    # Issue: https://github.com/conan-io/conan/issues/11822
+    c.run("install pkg/1.0@ -g MSBuildDeps -s build_type=Release -s arch=x86_64")
+    # Checking that MSBuildDeps builds correctly the XML file
+    props = c.load("conan_pkg_libmpdecimal__.props")
+    assert "<conan_pkg_libmpdecimal___props_imported>" in props
+    props = c.load("conan_pkg_libmpdecimal___release_x64.props")
+    assert "Conanpkg_libmpdecimal__IncludeDirectories" in props
+    props = c.load("conan_pkg_libmpdecimal___vars_release_x64.props")
+    assert "<Conanpkg_libmpdecimal__RootFolder>" in props
diff --git a/conans/test/integration/toolchains/microsoft/test_msbuildtoolchain.py b/conans/test/integration/toolchains/microsoft/test_msbuildtoolchain.py
index c7f8fe903..9432f4b51 100644
--- a/conans/test/integration/toolchains/microsoft/test_msbuildtoolchain.py
+++ b/conans/test/integration/toolchains/microsoft/test_msbuildtoolchain.py
@@ -11,6 +11,8 @@ def test_msbuildtoolchain_props_with_extra_flags():
     """
     profile = textwrap.dedent("""\
     include(default)
+    [settings]
+    arch=x86_64
     [conf]
     tools.build:cxxflags=["--flag1", "--flag2"]
     tools.build:cflags+=["--flag3", "--flag4"]
diff --git a/conans/test/unittests/client/build/autotools_environment_test.py b/conans/test/unittests/client/build/autotools_environment_test.py
index 36c09d1e5..666fff793 100644
--- a/conans/test/unittests/client/build/autotools_environment_test.py
+++ b/conans/test/unittests/client/build/autotools_environment_test.py
@@ -495,9 +495,10 @@ class AutoToolsConfigureTest(unittest.TestCase):
             self.assertIn("./configure  --build=x86_64-linux-gnu --host=x86_64-w64-mingw32",
                           runner.command_called)
         else:
+            build_arch = "aarch64" if platform.machine() == "arm64" else platform.machine()
             self.assertIn("x86_64-w64-mingw32", ab.host)
-            self.assertIn("x86_64-apple-darwin", ab.build)
-            self.assertIn("./configure  --build=x86_64-apple-darwin --host=x86_64-w64-mingw32",
+            self.assertIn(f"{build_arch}-apple-darwin", ab.build)
+            self.assertIn(f"./configure  --build={build_arch}-apple-darwin --host=x86_64-w64-mingw32",
                           runner.command_called)
 
         ab.configure(build="fake_build_triplet", host="fake_host_triplet")
diff --git a/conans/test/unittests/client/tools/oss/cross_building_test.py b/conans/test/unittests/client/tools/oss/cross_building_test.py
index 7374c9778..3eb27b7cd 100644
--- a/conans/test/unittests/client/tools/oss/cross_building_test.py
+++ b/conans/test/unittests/client/tools/oss/cross_building_test.py
@@ -16,6 +16,7 @@ class CrossBuildingTest(unittest.TestCase):
         settings = Settings.loads(get_default_settings_yml())
         settings.os = "FreeBSD"
         settings.arch = "x86_64"
+        settings.arch_build = "x86_64"
         self.assertFalse(cross_building(settings, self_os="FreeBSD", self_arch="x86_64"))
 
         with mock.patch("platform.system", mock.MagicMock(return_value='FreeBSD')),\
diff --git a/conans/test/unittests/model/other_settings_test.py b/conans/test/unittests/model/other_settings_test.py
index 4933a9105..51d68f36e 100644
--- a/conans/test/unittests/model/other_settings_test.py
+++ b/conans/test/unittests/model/other_settings_test.py
@@ -242,7 +242,7 @@ class SayConan(ConanFile):
 """
         client = TestClient()
         client.save({CONANFILE: content})
-        client.run("install . -s os=Windows --build missing")
+        client.run("install . -s os=Windows -s arch=x86_64 --build missing")
         conan_info = ConanInfo.loads(client.load(CONANINFO))
         self.assertEqual(conan_info.settings.os,  "Windows")
         self.assertEqual(conan_info.settings.fields, ["arch", "os"])
diff --git a/conans/test/unittests/tools/scm/test_version.py b/conans/test/unittests/tools/scm/test_version.py
index bdb83344a..7c52bb49e 100644
--- a/conans/test/unittests/tools/scm/test_version.py
+++ b/conans/test/unittests/tools/scm/test_version.py
@@ -16,8 +16,17 @@ def test_version():
             def configure(self):
                 v = Version(self.settings.compiler.version)
                 assert v > "10"
+
+                v = Version("1.2.3")
+                self.output.warning(f"The major of 1.2.3 is {v.major}")
+                self.output.warning(f"The minor of 1.2.3 is {v.minor}")
+                self.output.warning(f"The patch of 1.2.3 is {v.patch}")
         """)
     c.save({"conanfile.py": conanfile})
     settings = "-s compiler=gcc -s compiler.libcxx=libstdc++11"
     c.run("create . {} -s compiler.version=11".format(settings))
+    assert "The major of 1.2.3 is 1" in c.out
+    assert "The minor of 1.2.3 is 2" in c.out
+    assert "The patch of 1.2.3 is 3" in c.out
+
     c.run("create . {} -s compiler.version=9".format(settings), assert_error=True)
diff --git a/conans/test/utils/tools.py b/conans/test/utils/tools.py
index f46111f92..b9553bf24 100644
--- a/conans/test/utils/tools.py
+++ b/conans/test/utils/tools.py
@@ -532,6 +532,12 @@ class TestClient(object):
         else:
             return self.get_conan_api_v1()
 
+    def get_default_host_profile(self):
+        return self.cache.default_profile
+
+    def get_default_build_profile(self):
+        return self.cache.default_profile
+
     def run_cli(self, command_line, assert_error=False):
         conan = self.get_conan_api()
         self.api = conan