Repository: conan-io/conan

Issue:
[Fix] Remove "namespace" argument from CMakeToolchain
Since 1.47, generating the CMakePresets.json file, it is not used anymore.
Also from the CMake() build helper


Discussion:

Resolving patch:
diff --git a/conan/tools/cmake/cmake.py b/conan/tools/cmake/cmake.py
--- a/conan/tools/cmake/cmake.py
+++ b/conan/tools/cmake/cmake.py
@@ -48,12 +48,11 @@ class CMake(object):
     are passed to the command line, plus the ``--config Release`` for builds in multi-config
     """
 
-    def __init__(self, conanfile, namespace=None):
+    def __init__(self, conanfile):
         _validate_recipe(conanfile)
 
         # Store a reference to useful data
         self._conanfile = conanfile
-        self._namespace = namespace
 
         cmake_presets = load_cmake_presets(conanfile.generators_folder)
         self._generator = cmake_presets["configurePresets"][0]["generator"]
diff --git a/conan/tools/cmake/toolchain/toolchain.py b/conan/tools/cmake/toolchain/toolchain.py
--- a/conan/tools/cmake/toolchain/toolchain.py
+++ b/conan/tools/cmake/toolchain/toolchain.py
@@ -109,10 +109,9 @@ class CMakeToolchain(object):
         {{ iterate_configs(preprocessor_definitions_config, action='add_definitions') }}
         """)
 
-    def __init__(self, conanfile, generator=None, namespace=None):
+    def __init__(self, conanfile, generator=None):
         self._conanfile = conanfile
         self.generator = self._get_generator(generator)
-        self._namespace = namespace
         self.variables = Variables()
         self.preprocessor_definitions = Variables()
 


Test patch:
diff --git a/conans/test/integration/toolchains/test_toolchain_namespaces.py b/conans/test/integration/toolchains/test_toolchain_namespaces.py
--- a/conans/test/integration/toolchains/test_toolchain_namespaces.py
+++ b/conans/test/integration/toolchains/test_toolchain_namespaces.py
@@ -2,39 +2,10 @@
 import textwrap
 
 from conan.tools import CONAN_TOOLCHAIN_ARGS_FILE
-from conan.tools.cmake.presets import load_cmake_presets
 from conan.tools.files.files import load_toolchain_args
 from conans.test.utils.tools import TestClient
 
 
-def test_cmake_namespace():
-    client = TestClient()
-    namespace = "somename"
-    conanfile = textwrap.dedent("""
-            from conans import ConanFile
-            from conan.tools.cmake import CMakeToolchain, CMake
-
-            class Conan(ConanFile):
-                settings = "os", "arch", "compiler", "build_type"
-                def generate(self):
-                    cmake = CMakeToolchain(self, namespace='{0}')
-                    cmake.generate()
-                def build(self):
-                    cmake = CMake(self, namespace='{0}')
-                    self.output.info(cmake._generator)
-                    self.output.info(cmake._toolchain_file)
-            """.format(namespace))
-
-    client.save({"conanfile.py": conanfile})
-    client.run("install . ")
-    presets = load_cmake_presets(client.current_folder)
-    toolchain_file = presets["configurePresets"][0]["toolchainFile"]
-    generator = presets["configurePresets"][0]["generator"]
-    client.run("build . ")
-    assert generator in client.out
-    assert toolchain_file in client.out
-
-
 def test_bazel_namespace():
     client = TestClient()
     namespace = "somename"