[Reproducible-commits] [debhelper] 05/05: Add cross-compile support to the cmake build system
Mattia Rizzolo
mattia at mapreri.org
Wed Aug 12 17:47:03 UTC 2015
This is an automated email from the git hooks/post-receive script.
mapreri-guest pushed a commit to branch master
in repository debhelper.
commit 23a66fd8787fad005446c25e02a4ed66134b446c
Author: Helmut Grohne <helmut at subdivi.de>
Date: Wed Aug 12 17:15:09 2015 +0200
Add cross-compile support to the cmake build system
[nthykier: Minor style changes/refactoring]
Signed-off-by: Niels Thykier <niels at thykier.net>
---
Debian/Debhelper/Buildsystem/cmake.pm | 28 +++++++++++++++++++++++++++-
debian/changelog | 3 +++
2 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/Debian/Debhelper/Buildsystem/cmake.pm b/Debian/Debhelper/Buildsystem/cmake.pm
index 9646d4b..f778c6d 100644
--- a/Debian/Debhelper/Buildsystem/cmake.pm
+++ b/Debian/Debhelper/Buildsystem/cmake.pm
@@ -8,9 +8,15 @@ package Debian::Debhelper::Buildsystem::cmake;
use strict;
use warnings;
-use Debian::Debhelper::Dh_Lib qw(compat);
+use Debian::Debhelper::Dh_Lib qw(compat dpkg_architecture_value error is_cross_compiling);
use parent qw(Debian::Debhelper::Buildsystem::makefile);
+my %DEB_HOST2CMAKE_SYSTEM = (
+ 'linux' => 'Linux',
+ 'kfreebsd' => 'FreeBSD',
+ 'hurd' => 'GNU',
+);
+
sub DESCRIPTION {
"CMake (CMakeLists.txt)"
}
@@ -46,6 +52,26 @@ sub configure {
push @flags, "-DCMAKE_VERBOSE_MAKEFILE=ON";
push @flags, "-DCMAKE_BUILD_TYPE=None";
+ if (is_cross_compiling()) {
+ my $deb_host = dpkg_architecture_value("DEB_HOST_ARCH_OS");
+ if (my $cmake_system = $DEB_HOST2CMAKE_SYSTEM{$deb_host}) {
+ push(@flags, "-DCMAKE_SYSTEM_NAME=${cmake_system}");
+ } else {
+ error("Cannot cross-compile - CMAKE_SYSTEM_NAME not known for ${deb_host}");
+ }
+ push @flags, "-DCMAKE_SYSTEM_PROCESSOR=" . dpkg_architecture_value("DEB_HOST_GNU_CPU");
+ if ($ENV{CC}) {
+ push @flags, "-DCMAKE_C_COMPILER=" . $ENV{CC};
+ } else {
+ push @flags, "-DCMAKE_C_COMPILER=" . dpkg_architecture_value("DEB_HOST_GNU_TYPE") . "-cc";
+ }
+ if ($ENV{CXX}) {
+ push @flags, "-DCMAKE_CXX_COMPILER=" . $ENV{CXX};
+ } else {
+ push @flags, "-DCMAKE_CXX_COMPILER=" . dpkg_architecture_value("DEB_HOST_GNU_TYPE") . "-c++";
+ }
+ }
+
# CMake doesn't respect CPPFLAGS, see #653916.
if ($ENV{CPPFLAGS} && ! compat(8)) {
$ENV{CFLAGS} .= ' ' . $ENV{CPPFLAGS};
diff --git a/debian/changelog b/debian/changelog
index 2cfd1a1..e4d0e5c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,9 @@ debhelper (9.20150811+unreleased) UNRELEASED; urgency=medium
* dh/dh_auto_*: Apply patch from "Dhole" to define
SOURCE_DATE_EPOCH. (Closes: #791823)
+ * cmake.pm: Add better cross-compile support for cmake.
+ Heavily based on a patch from Helmut Grohne.
+ (Closes: #794396)
-- Niels Thykier <niels at thykier.net> Wed, 12 Aug 2015 10:46:59 +0200
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/debhelper.git
More information about the Reproducible-commits
mailing list