@@ -19,14 +19,18 @@ def __init__(self) -> None:
1919
2020 @staticmethod
2121 def generate_cppython_preset (
22- cppython_preset_directory : Path , provider_preset_file : Path , provider_data : CMakeSyncData
22+ cppython_preset_directory : Path ,
23+ provider_preset_file : Path ,
24+ provider_data : CMakeSyncData ,
25+ project_root : Path ,
2326 ) -> CMakePresets :
2427 """Generates the cppython preset which inherits from the provider presets
2528
2629 Args:
2730 cppython_preset_directory: The tool directory
2831 provider_preset_file: Path to the provider's preset file
2932 provider_data: The provider's synchronization data
33+ project_root: The project root directory (where CMakeLists.txt is located)
3034
3135 Returns:
3236 A CMakePresets object
@@ -43,8 +47,7 @@ def generate_cppython_preset(
4347 )
4448
4549 if provider_data .toolchain_file :
46- # Make toolchain file path relative to the preset directory
47- relative_toolchain = provider_data .toolchain_file .relative_to (cppython_preset_directory , walk_up = True )
50+ relative_toolchain = provider_data .toolchain_file .relative_to (project_root , walk_up = True )
4851 default_configure .toolchainFile = relative_toolchain .as_posix ()
4952
5053 configure_presets .append (default_configure )
@@ -57,20 +60,24 @@ def generate_cppython_preset(
5760
5861 @staticmethod
5962 def write_cppython_preset (
60- cppython_preset_directory : Path , provider_preset_file : Path , provider_data : CMakeSyncData
63+ cppython_preset_directory : Path ,
64+ provider_preset_file : Path ,
65+ provider_data : CMakeSyncData ,
66+ project_root : Path ,
6167 ) -> Path :
6268 """Write the cppython presets which inherit from the provider presets
6369
6470 Args:
6571 cppython_preset_directory: The tool directory
6672 provider_preset_file: Path to the provider's preset file
6773 provider_data: The provider's synchronization data
74+ project_root: The project root directory (where CMakeLists.txt is located)
6875
6976 Returns:
7077 A file path to the written data
7178 """
7279 generated_preset = Builder .generate_cppython_preset (
73- cppython_preset_directory , provider_preset_file , provider_data
80+ cppython_preset_directory , provider_preset_file , provider_data , project_root
7481 )
7582 cppython_preset_file = cppython_preset_directory / 'cppython.json'
7683
0 commit comments