From 6bf55bfad313b21cde82d39124f8a7e11cc6a047 Mon Sep 17 00:00:00 2001 From: Daniele Nicolodi Date: Sun, 19 Oct 2025 15:44:04 +0200 Subject: [PATCH 1/2] cmake: Do not pass install prefix explicitly to the CMake interpreter There is no point in doing so as it can be readily obtained from the environment. This in preparation of extracting more installation location from the environment. --- mesonbuild/cmake/interpreter.py | 4 ++-- mesonbuild/interpreter/interpreter.py | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/mesonbuild/cmake/interpreter.py b/mesonbuild/cmake/interpreter.py index 54c9ae696916..17c076e69bb5 100644 --- a/mesonbuild/cmake/interpreter.py +++ b/mesonbuild/cmake/interpreter.py @@ -786,12 +786,12 @@ def log(self) -> None: mlog.log(' -- depends: ', mlog.bold(str(self.depends))) class CMakeInterpreter: - def __init__(self, subdir: Path, install_prefix: Path, env: 'Environment', backend: 'Backend'): + def __init__(self, subdir: Path, env: 'Environment', backend: 'Backend'): self.subdir = subdir self.src_dir = Path(env.get_source_dir(), subdir) self.build_dir_rel = subdir / '__CMake_build' self.build_dir = Path(env.get_build_dir()) / self.build_dir_rel - self.install_prefix = install_prefix + self.install_prefix = Path(T.cast('str', env.coredata.optstore.get_value_for(OptionKey('prefix')))) self.env = env self.for_machine = MachineChoice.HOST # TODO make parameter self.backend_name = backend.name diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py index 9bfc9be23831..688fd2dba2a1 100644 --- a/mesonbuild/interpreter/interpreter.py +++ b/mesonbuild/interpreter/interpreter.py @@ -1049,12 +1049,10 @@ def _do_subproject_cmake(self, subp_name: str, subdir: str, kwargs: kwtypes.DoSubproject) -> SubprojectHolder: from ..cmake import CMakeInterpreter with mlog.nested(subp_name): - prefix = self.coredata.optstore.get_value_for('prefix') - from ..modules.cmake import CMakeSubprojectOptions kw_opts = kwargs.get('options') or CMakeSubprojectOptions() cmake_options = kwargs.get('cmake_options', []) + kw_opts.cmake_options - cm_int = CMakeInterpreter(Path(subdir), Path(prefix), self.build.environment, self.backend) + cm_int = CMakeInterpreter(Path(subdir), self.build.environment, self.backend) cm_int.initialise(cmake_options) cm_int.analyse() From 8aecc0ca890dd65344264e9459e8a0e8ff3671b1 Mon Sep 17 00:00:00 2001 From: Daniele Nicolodi Date: Sun, 19 Oct 2025 15:45:45 +0200 Subject: [PATCH 2/2] cmake: Set CMAKE_INSTALL_LIBDIR explicitly CMake and Meson may disagree on the default value of the libdir installation path. This results in shared libraries installed in the default location not assigned to the {libdir_shared} install location by the Meson CMake interpreter. This results in wrong install plan metadata and in those libraries being installed in the wrong location. Fixes #12960. --- mesonbuild/cmake/interpreter.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mesonbuild/cmake/interpreter.py b/mesonbuild/cmake/interpreter.py index 17c076e69bb5..bdaa6d54c2f3 100644 --- a/mesonbuild/cmake/interpreter.py +++ b/mesonbuild/cmake/interpreter.py @@ -842,6 +842,8 @@ def configure(self, extra_cmake_options: T.List[str]) -> CMakeExecutor: cmake_args = [] cmake_args += cmake_get_generator_args(self.env) cmake_args += [f'-DCMAKE_INSTALL_PREFIX={self.install_prefix}'] + libdir = self.env.coredata.optstore.get_value_for(OptionKey('libdir')) + cmake_args += [f'-DCMAKE_INSTALL_LIBDIR={libdir}'] cmake_args += extra_cmake_options if not any(arg.startswith('-DCMAKE_BUILD_TYPE=') for arg in cmake_args): # Our build type is favored over any CMAKE_BUILD_TYPE environment variable