Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/fix toolchain path slash #11652

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion conan/tools/cmake/toolchain/toolchain.py
Expand Up @@ -176,7 +176,8 @@ def generate(self):
# Generators like Ninja or NMake requires an active vcvars
elif self.generator is not None and "Visual" not in self.generator:
VCVars(self._conanfile).generate()
toolchain = os.path.join(self._conanfile.generators_folder, toolchain_file or self.filename)
toolchain = os.path.abspath(os.path.join(self._conanfile.generators_folder,
toolchain_file or self.filename))
cache_variables = {}
for name, value in self.cache_variables.items():
if isinstance(value, bool):
Expand Down
25 changes: 25 additions & 0 deletions conans/test/integration/toolchains/cmake/test_cmaketoolchain.py
Expand Up @@ -490,3 +490,28 @@ def configure(self):
""")
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")


@pytest.mark.skipif(platform.system() != "Windows", reason="Only Windows")
def test_presets_paths_correct():
client = TestClient()
conanfile = textwrap.dedent("""
from conan import ConanFile
from conan.tools.cmake import cmake_layout

class Conan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeToolchain"

def layout(self):
cmake_layout(self)
""")
client.save({"conanfile.py": conanfile})
client.run("install . ")
contents = json.loads(client.load("build/generators/CMakePresets.json"))
toolchain_file = contents["configurePresets"][0]["toolchainFile"]
assert "/" not in toolchain_file

binary_dir = contents["configurePresets"][0]["binaryDir"]
assert "/" not in binary_dir