Skip to content

Commit

Permalink
Hotfix/cmaketoolchain fulldeploy (#16434)
Browse files Browse the repository at this point in the history
fix for CMakeToolchain escape errors with --deployer=full_deploy
  • Loading branch information
memsharded authored Jun 10, 2024
1 parent 8e20909 commit 84f2387
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion conan/tools/cmake/toolchain/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,8 +564,8 @@ def _get_host_runtime_dirs(self, host_req):
return host_runtime_dirs

def _join_paths(self, paths):
paths = [relativize_path(p, self._conanfile, "${CMAKE_CURRENT_LIST_DIR}") for p in paths]
paths = [p.replace('\\', '/').replace('$', '\\$').replace('"', '\\"') for p in paths]
paths = [relativize_path(p, self._conanfile, "${CMAKE_CURRENT_LIST_DIR}") for p in paths]
return " ".join([f'"{p}"' for p in paths])

def context(self):
Expand Down
16 changes: 16 additions & 0 deletions test/integration/toolchains/cmake/test_cmaketoolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -1501,6 +1501,7 @@ def layout(self):
presets = json.loads(c.load(user_presets["include"][0]))
assert os.path.isabs(presets["configurePresets"][0]["toolchainFile"])


def test_output_dirs_gnudirs_local_default():
# https://github.com/conan-io/conan/issues/14733
c = TestClient()
Expand Down Expand Up @@ -1630,3 +1631,18 @@ def test_toolchain_extra_variables():
toolchain = client.load("conan_toolchain.cmake")
assert 'set(CACHE_VAR_DEFAULT_DOC "hello world" CACHE PATH "CACHE_VAR_DEFAULT_DOC")' in toolchain


def test_variables_wrong_scaping():
# https://github.com/conan-io/conan/issues/16432
c = TestClient()
c.save({"tool/conanfile.py": GenConanfile("tool", "0.1"),
"pkg/conanfile.txt": "[tool_requires]\ntool/0.1\n[generators]\nCMakeToolchain"})
c.run("create tool")
c.run("install pkg")
toolchain = c.load("pkg/conan_toolchain.cmake")
cache_folder = c.cache_folder.replace("\\", "/")
assert f'list(PREPEND CMAKE_PROGRAM_PATH "{cache_folder}' in toolchain

c.run("install pkg --deployer=full_deploy")
toolchain = c.load("pkg/conan_toolchain.cmake")
assert 'list(PREPEND CMAKE_PROGRAM_PATH "${CMAKE_CURRENT_LIST_DIR}/full_deploy' in toolchain

0 comments on commit 84f2387

Please sign in to comment.