X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=Debian%2FDebhelper%2FBuildsystem%2Fcmake.pm;h=f318b44b827e7609dc116fbb1f98131a74af449e;hb=e7f5f747e04176bda1d0e353eee3e0b5445b70f8;hp=5662874089c2c51944839be361503a24b886a694;hpb=fdf8b4a8b4b4f50c39b6e4266773539bc13d6e56;p=debhelper.git diff --git a/Debian/Debhelper/Buildsystem/cmake.pm b/Debian/Debhelper/Buildsystem/cmake.pm index 5662874..f318b44 100644 --- a/Debian/Debhelper/Buildsystem/cmake.pm +++ b/Debian/Debhelper/Buildsystem/cmake.pm @@ -16,16 +16,22 @@ sub DESCRIPTION { sub check_auto_buildable { my $this=shift; my ($step)=@_; - my $ret = -e $this->get_sourcepath("CMakeLists.txt"); - $ret &&= $this->SUPER::check_auto_buildable(@_) if $step ne "configure"; - return $ret; + if (-e $this->get_sourcepath("CMakeLists.txt")) { + 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; + } + return 0; } sub new { my $class=shift; my $this=$class->SUPER::new(@_); - # Prefer out of source tree building. - $this->enforce_out_of_source_building(@_); + $this->prefer_out_of_source_building(@_); return $this; } @@ -35,11 +41,35 @@ sub configure { # Standard set of cmake flags push @flags, "-DCMAKE_INSTALL_PREFIX=/usr"; - push @flags, "-DCMAKE_SKIP_RPATH=ON"; 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->SUPER::test(@_, "ARGS+=-j$parallel"); } -1; +1