X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=Debian%2FDebhelper%2FBuildsystem%2Fcmake.pm;h=1d009b44989e6005a198d7c86ea8ebda7b469945;hb=4fed5fde645b9b69771f5b9111a1e50ae517b70a;hp=ee90c1f9122814761db5decd5e5383f5b82e11b5;hpb=a81dd8b003e5152bddeccc0c92f40c003890cbdc;p=debhelper.git diff --git a/Debian/Debhelper/Buildsystem/cmake.pm b/Debian/Debhelper/Buildsystem/cmake.pm index ee90c1f..1d009b4 100644 --- a/Debian/Debhelper/Buildsystem/cmake.pm +++ b/Debian/Debhelper/Buildsystem/cmake.pm @@ -7,6 +7,7 @@ package Debian::Debhelper::Buildsystem::cmake; use strict; +use Debian::Debhelper::Dh_Lib qw(compat); use base 'Debian::Debhelper::Buildsystem::makefile'; sub DESCRIPTION { @@ -17,12 +18,13 @@ sub check_auto_buildable { my $this=shift; my ($step)=@_; if (-e $this->get_sourcepath("CMakeLists.txt")) { - my $ret = $this->SUPER::check_auto_buildable(@_); + my $ret = ($step eq "configure" && 1) || + $this->SUPER::check_auto_buildable(@_); # Existence of CMakeCache.txt indicates cmake has already # been used by a prior build step, so should be used # instead of the parent makefile class. $ret++ if ($ret && -e $this->get_buildpath("CMakeCache.txt")); - return $ret > 0 ? $ret : 1; + return $ret; } return 0; } @@ -42,15 +44,33 @@ sub configure { push @flags, "-DCMAKE_INSTALL_PREFIX=/usr"; push @flags, "-DCMAKE_VERBOSE_MAKEFILE=ON"; + # CMake doesn't respect CPPFLAGS, see #653916. + if ($ENV{CPPFLAGS} && ! compat(8)) { + $ENV{CFLAGS} .= ' ' . $ENV{CPPFLAGS}; + $ENV{CXXFLAGS} .= ' ' . $ENV{CPPFLAGS}; + } + $this->mkdir_builddir(); - $this->doit_in_builddir("cmake", $this->get_source_rel2builddir(), @flags, @_); + eval { + $this->doit_in_builddir("cmake", $this->get_source_rel2builddir(), @flags, @_); + }; + if ($@) { + if (-e $this->get_buildpath("CMakeCache.txt")) { + $this->doit_in_builddir("tail -v -n +0 CMakeCache.txt"); + } + die $@; + } } sub test { my $this=shift; + # Unlike make, CTest does not have "unlimited parallel" setting (-j implies + # -j1). So in order to simulate unlimited parallel, allow to fork a huge + # number of threads instead. + my $parallel = ($this->get_parallel() > 0) ? $this->get_parallel() : 999; $ENV{CTEST_OUTPUT_ON_FAILURE} = 1; - return $this->test(@_); + return $this->SUPER::test(@_, "ARGS+=-j$parallel"); } 1