diff --git a/conan/tools/cmake/cmake.py b/conan/tools/cmake/cmake.py index d30e4274f0b..716e6afd1d7 100644 --- a/conan/tools/cmake/cmake.py +++ b/conan/tools/cmake/cmake.py @@ -56,7 +56,7 @@ def __init__(self, conanfile): configure_preset = get_configure_preset(cmake_presets, conanfile) self._generator = configure_preset["generator"] - self._toolchain_file = configure_preset["toolchainFile"] + self._toolchain_file = configure_preset.get("toolchainFile") self._cache_variables = configure_preset["cacheVariables"] self._cmake_program = "cmake" # Path to CMake should be handled by environment diff --git a/conans/test/functional/toolchains/cmake/test_cmake_toolchain.py b/conans/test/functional/toolchains/cmake/test_cmake_toolchain.py index c4b25b27266..01453c25b9c 100644 --- a/conans/test/functional/toolchains/cmake/test_cmake_toolchain.py +++ b/conans/test/functional/toolchains/cmake/test_cmake_toolchain.py @@ -814,6 +814,15 @@ def test_cmake_presets_multiple_settings_multi_config(): assert "MSVC_LANG2017" in client.out +@pytest.mark.tool_cmake(version="3.23") +def test_max_schema_version2_build(): + client = TestClient(path_with_spaces=False) + client.run("new hello/0.1 --template=cmake_exe") + configs = ["-c tools.cmake.cmaketoolchain.presets:max_schema_version=2"] + client.run("install . {} -s compiler.cppstd=14".format(" ".join(configs))) + client.run("build .") + + @pytest.mark.tool_cmake(version="3.23") def test_user_presets_version2(): client = TestClient(path_with_spaces=False)