diff --git a/conan/tools/cmake/toolchain/blocks.py b/conan/tools/cmake/toolchain/blocks.py index 3ba82cbfb19..ec646709ac7 100644 --- a/conan/tools/cmake/toolchain/blocks.py +++ b/conan/tools/cmake/toolchain/blocks.py @@ -1030,11 +1030,11 @@ class ExtraVariablesBlock(Block): CMAKE_CACHE_TYPES = ["BOOL","FILEPATH", "PATH", "STRING", "INTERNAL"] def get_exact_type(self, key, value): - if type(value) == str: + if isinstance(value, str): return f"\"{value}\"" - elif type(value) == int or type(value) == float: + elif isinstance(value, (int, float)): return value - elif type(value) == dict: + elif isinstance(value, dict): var_value = self.get_exact_type(key, value.get("value")) is_cache = value.get("cache") if is_cache == True or str(is_cache).lower() == 'true': diff --git a/test/integration/toolchains/cmake/test_cmaketoolchain.py b/test/integration/toolchains/cmake/test_cmaketoolchain.py index ab668787faf..24c5c0da8d8 100644 --- a/test/integration/toolchains/cmake/test_cmaketoolchain.py +++ b/test/integration/toolchains/cmake/test_cmaketoolchain.py @@ -1585,12 +1585,12 @@ def test_toolchain_extra_variables(): tools.cmake.cmaketoolchain:extra_variables={'CMAKE_GENERATOR_INSTANCE': '${GENERATOR_INSTANCE}/buildTools/', 'FOO': '42' } """) - client = TestClient(path_with_spaces=False) + client = TestClient() client.save({"conanfile.txt": "[generators]\nCMakeToolchain", "windows": windows_profile}) # Test passing extra_variables from pro ile - client.run("install . --profile:build=windows --profile:host=windows") + client.run("install . --profile:host=windows") toolchain = client.load("conan_toolchain.cmake") assert 'set(CMAKE_GENERATOR_INSTANCE "${GENERATOR_INSTANCE}/buildTools/")' in toolchain assert 'set(FOO "42")' in toolchain