diff --git a/pycheribuild/projects/cmake.py b/pycheribuild/projects/cmake.py index 279a1ef9d..02a66bcf5 100644 --- a/pycheribuild/projects/cmake.py +++ b/pycheribuild/projects/cmake.py @@ -61,6 +61,7 @@ class BuildCMake(AutotoolsProject): repository = GitRepository("https://github.com/Kitware/CMake", # a lot faster than "https://cmake.org/cmake.git" # track the stable release branch default_branch="release") + default_architecture = CompilationTargets.NATIVE native_install_dir = DefaultInstallDir.BOOTSTRAP_TOOLS make_kind = MakeCommandKind.Ninja add_host_target_build_config_options = False diff --git a/pycheribuild/projects/repository.py b/pycheribuild/projects/repository.py index 0c6d48ab0..49910a8c7 100644 --- a/pycheribuild/projects/repository.py +++ b/pycheribuild/projects/repository.py @@ -127,11 +127,15 @@ def update(self, current_project: "Project", *, src_dir: Path, **kwargs): class ReuseOtherProjectDefaultTargetRepository(ReuseOtherProjectRepository): def __init__(self, source_project: "type[Project]", *, subdirectory=".", do_update=False): + xtarget = source_project.default_architecture + if xtarget is None and len(source_project.supported_architectures) == 1: + xtarget = source_project.supported_architectures[0] + assert xtarget is not None super().__init__( source_project, subdirectory=subdirectory, do_update=do_update, - repo_for_target=source_project.supported_architectures[0], + repo_for_target=xtarget, ) diff --git a/tests/test_argument_parsing.py b/tests/test_argument_parsing.py index 6732b684b..bf6110966 100644 --- a/tests/test_argument_parsing.py +++ b/tests/test_argument_parsing.py @@ -1157,8 +1157,8 @@ def test_source_dir_option_when_reusing_git_repo(): ) assert str(_get_target_instance("llvm-native", config).source_dir) == "/custom/llvm/dir3" assert str(_get_target_instance("compiler-rt-native", config).source_dir) == "/custom/compiler-rt/dir3" - # compiler-rt-riscv64 uses the default path, since we only changed llvm-native and compiler-rt-native: - assert str(_get_target_instance("compiler-rt-riscv64", config).source_dir) == "/foo/llvm-project/compiler-rt" + # compiler-rt-riscv64 uses the default path (llvm-native source), since we only changed compiler-rt-native: + assert str(_get_target_instance("compiler-rt-riscv64", config).source_dir) == "/custom/llvm/dir3/compiler-rt" # Check that cheribsd-mfs-root-kernel reused the cheribsd source dir assert str(_get_target_instance("cheribsd-mfs-root-kernel-riscv64-purecap", config).source_dir) == "/foo/cheribsd"