]> git.donarmstrong.com Git - debhelper.git/blob - Debian/Debhelper/Buildsystem/cmake.pm
debhelper modular buildsystems (try 3).
[debhelper.git] / Debian / Debhelper / Buildsystem / cmake.pm
1 # A buildsystem plugin for handling CMake based projects.
2 # It enforces outside-source 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 Debian::Debhelper::Dh_Lib;
11 use base 'Debian::Debhelper::Buildsystem::makefile';
12
13 sub DESCRIPTION {
14         "support for building CMake based packages (outside-source tree only)"
15 }
16
17 sub check_auto_buildable {
18         my $self=shift;
19         my ($action)=@_;
20         my $ret = -e "CMakeLists.txt";
21         $ret &&= $self->SUPER::check_auto_buildable(@_) if $action ne "configure";
22         return $ret;
23 }
24
25 sub new {
26         my $cls=shift;
27         my $self=$cls->SUPER::new(@_);
28         # Enforce outside-source tree builds.
29         $self->enforce_outside_source_building();
30         return $self;
31 }
32
33 sub configure {
34         my $self=shift;
35         my @flags;
36
37         # Standard set of cmake flags
38         push @flags, "-DCMAKE_INSTALL_PREFIX=/usr";
39         push @flags, "-DCMAKE_C_FLAGS=$ENV{CFLAGS}" if (exists $ENV{CFLAGS});
40         push @flags, "-DCMAKE_CXX_FLAGS=$ENV{CXXFLAGS}" if (exists $ENV{CXXFLAGS});
41         push @flags, "-DCMAKE_LD_FLAGS=$ENV{LDFLAGS}" if (exists $ENV{LDFLAGS});
42         push @flags, "-DCMAKE_SKIP_RPATH=ON";
43         push @flags, "-DCMAKE_VERBOSE_MAKEFILE=ON";
44
45         $self->mkdir_builddir();
46         $self->doit_in_builddir("cmake", $self->get_rel2builddir_path(), @flags);
47 }
48
49 1;