]> git.donarmstrong.com Git - debhelper.git/blob - Debian/Debhelper/Buildsystem/cmake.pm
Merge branch 'master' into buildsystems
[debhelper.git] / Debian / Debhelper / Buildsystem / cmake.pm
1 # A buildsystem plugin for handling CMake based projects.
2 # It enforces 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         my $ret = -e $this->get_sourcepath("CMakeLists.txt");
20         $ret &&= $this->SUPER::check_auto_buildable(@_) if $step ne "configure";
21         return $ret;
22 }
23
24 sub new {
25         my $class=shift;
26         my $this=$class->SUPER::new(@_);
27         # Enforce out of source tree building.
28         $this->enforce_out_of_source_building();
29         return $this;
30 }
31
32 sub configure {
33         my $this=shift;
34         my @flags;
35
36         # Standard set of cmake flags
37         push @flags, "-DCMAKE_INSTALL_PREFIX=/usr";
38         push @flags, "-DCMAKE_C_FLAGS=$ENV{CFLAGS}" if (exists $ENV{CFLAGS});
39         push @flags, "-DCMAKE_CXX_FLAGS=$ENV{CXXFLAGS}" if (exists $ENV{CXXFLAGS});
40         push @flags, "-DCMAKE_LD_FLAGS=$ENV{LDFLAGS}" if (exists $ENV{LDFLAGS});
41         push @flags, "-DCMAKE_SKIP_RPATH=ON";
42         push @flags, "-DCMAKE_VERBOSE_MAKEFILE=ON";
43
44         $this->mkdir_builddir();
45         $this->doit_in_builddir("cmake", $this->get_source_rel2builddir(), @flags);
46 }
47
48 1;