]> git.donarmstrong.com Git - debhelper.git/blob - Debian/Debhelper/Buildsystem/cmake.pm
Improve build system auto-selection process
[debhelper.git] / Debian / Debhelper / Buildsystem / cmake.pm
1 # A debhelper build system class for handling CMake based projects.
2 # It prefers out of source tree building.
3 #
4 # Copyright: © 2008-2009 Modestas Vainius
5 # License: GPL-2+
6
7 package Debian::Debhelper::Buildsystem::cmake;
8
9 use strict;
10 use base 'Debian::Debhelper::Buildsystem::makefile';
11
12 sub DESCRIPTION {
13         "CMake (CMakeLists.txt)"
14 }
15
16 sub check_auto_buildable {
17         my $this=shift;
18         my ($step)=@_;
19         if (-e $this->get_sourcepath("CMakeLists.txt")) {
20                 my $ret = $this->SUPER::check_auto_buildable(@_);
21                 $ret++ if ($ret && -e $this->get_buildpath("CMakeCache.txt"));
22                 return $ret > 0 ? $ret : 1;
23         }
24         return 0;
25 }
26
27 sub new {
28         my $class=shift;
29         my $this=$class->SUPER::new(@_);
30         $this->prefer_out_of_source_building(@_);
31         return $this;
32 }
33
34 sub configure {
35         my $this=shift;
36         my @flags;
37
38         # Standard set of cmake flags
39         push @flags, "-DCMAKE_INSTALL_PREFIX=/usr";
40         push @flags, "-DCMAKE_VERBOSE_MAKEFILE=ON";
41
42         $this->mkdir_builddir();
43         $this->doit_in_builddir("cmake", $this->get_source_rel2builddir(), @flags, @_);
44 }
45
46 sub test {
47         my $this=shift;
48
49         $ENV{CTEST_OUTPUT_ON_FAILURE} = 1;
50         return $this->test(@_);
51 }
52
53 1