Skip to content

Commit 42681a7

Browse files
authored
Relative Root Preset Reference (#65)
1 parent ea12f32 commit 42681a7

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

cppython/project.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ def write_generator_presets(path: Path, generator_name: str, toolchain_path: Pat
161161

162162
def write_root_presets(self, path: Path):
163163
"""
164-
Read the top level json file and replace the include reference
164+
Read the top level json file and replace the include reference.
165+
Receives a relative path to the tool cmake json file
165166
"""
166167

167168
root_preset_path = self.configuration.root_path / "CMakePresets.json"
@@ -172,7 +173,7 @@ def write_root_presets(self, path: Path):
172173
if root_model.include is not None:
173174
for index, include_path in enumerate(root_model.include):
174175
if Path(include_path).name == "cppython.json":
175-
root_model.include[index] = path.as_posix()
176+
root_model.include[index] = "${sourceDir}/build" + path.as_posix()
176177

177178
# 'dict.update' wont apply to nested types, manual replacement
178179
root_preset["include"] = root_model.include
@@ -341,7 +342,7 @@ def install(self) -> None:
341342
raise exception
342343

343344
project_presets = self._builder.write_presets(preset_path, generator_output)
344-
self._builder.write_root_presets(project_presets)
345+
self._builder.write_root_presets(project_presets.relative_to(preset_path))
345346

346347
def update(self) -> None:
347348
"""
@@ -372,4 +373,4 @@ def update(self) -> None:
372373
raise exception
373374

374375
project_presets = self._builder.write_presets(preset_path, generator_output)
375-
self._builder.write_root_presets(project_presets)
376+
self._builder.write_root_presets(project_presets.relative_to(preset_path))

0 commit comments

Comments
 (0)