diff options
author | Simon McVittie <smcv@debian.org> | 2023-08-06 14:02:57 +0100 |
---|---|---|
committer | Niels Thykier <niels@thykier.net> | 2023-08-09 09:48:58 +0000 |
commit | 7df8f2447afacad2f4dcd74ece0cbfe915df24c5 (patch) | |
tree | f2918c9ccc111ab204885ad67022bd1474ab8f82 | |
parent | b36a27e5a64f5a484e196c29473d33ba46c03ee9 (diff) |
cmake, meson: Set DEB_PYTHON_INSTALL_LAYOUT=deb if not already set
With recent versions of cmake, meson and python3, the default
installation layout discovered by cmake or meson is below /usr/local,
unless we explicitly override DEB_PYTHON_INSTALL_LAYOUT to tell Python
that we are building a distro package.
Closes: #1043136
Signed-off-by: Simon McVittie <smcv@debian.org>
-rw-r--r-- | lib/Debian/Debhelper/Buildsystem/cmake.pm | 12 | ||||
-rw-r--r-- | lib/Debian/Debhelper/Buildsystem/meson.pm | 18 |
2 files changed, 22 insertions, 8 deletions
diff --git a/lib/Debian/Debhelper/Buildsystem/cmake.pm b/lib/Debian/Debhelper/Buildsystem/cmake.pm index 2b793939..c64c418e 100644 --- a/lib/Debian/Debhelper/Buildsystem/cmake.pm +++ b/lib/Debian/Debhelper/Buildsystem/cmake.pm @@ -79,6 +79,12 @@ sub new { return $this; } +sub _get_cmake_env { + my $update_env = {}; + $update_env->{DEB_PYTHON_INSTALL_LAYOUT} = 'deb' unless $ENV{DEB_PYTHON_INSTALL_LAYOUT}; + return $update_env; +} + sub configure { my $this=shift; # Standard set of cmake flags @@ -141,7 +147,10 @@ sub configure { $this->mkdir_builddir(); eval { - $this->doit_in_builddir("cmake", @flags, @_, $this->get_source_rel2builddir()); + my %options = ( + update_env => _get_cmake_env(), + ); + $this->doit_in_builddir(\%options, "cmake", @flags, @_, $this->get_source_rel2builddir()); }; if (my $err = $@) { if (-e $this->get_buildpath("CMakeCache.txt")) { @@ -196,6 +205,7 @@ sub install { update_env => { 'LC_ALL' => 'C.UTF-8', 'DESTDIR' => $destdir, + %{ _get_cmake_env() }, } ); print_and_doit(\%options, 'cmake', '--install', $this->get_buildpath, @_); diff --git a/lib/Debian/Debhelper/Buildsystem/meson.pm b/lib/Debian/Debhelper/Buildsystem/meson.pm index 3cd447de..066216a7 100644 --- a/lib/Debian/Debhelper/Buildsystem/meson.pm +++ b/lib/Debian/Debhelper/Buildsystem/meson.pm @@ -48,6 +48,14 @@ sub new { return $this; } +sub _get_meson_env { + my $update_env = { + LC_ALL => 'C.UTF-8', + }; + $update_env->{DEB_PYTHON_INSTALL_LAYOUT} = 'deb' unless $ENV{DEB_PYTHON_INSTALL_LAYOUT}; + return $update_env; +} + sub configure { my $this=shift; @@ -92,7 +100,7 @@ sub configure { $this->mkdir_builddir(); eval { my %options = ( - update_env => { LC_ALL => 'C.UTF-8'}, + update_env => _get_meson_env(), ); $this->doit_in_builddir(\%options, "meson", "setup", $this->get_source_rel2builddir(), @opts, @_); }; @@ -115,9 +123,7 @@ sub test { # In compat 13 with meson+ninja, we prefer using "meson test" # over "ninja test" my %options = ( - update_env => { - 'LC_ALL' => 'C.UTF-8', - } + update_env => _get_meson_env(), ); if ($this->get_parallel() > 0) { $options{update_env}{MESON_TESTTHREADS} = $this->get_parallel(); @@ -144,9 +150,7 @@ sub install { # In compat 14 with meson+ninja, we prefer using "meson install" # over "ninja install" my %options = ( - update_env => { - 'LC_ALL' => 'C.UTF-8', - } + update_env => _get_meson_env(), ); $this->doit_in_builddir(\%options, 'meson', 'install', '--destdir', $destdir, @args); } |