]> 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 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         "CMake (CMakeLists.txt)"
15 }
16
17 sub check_auto_buildable {
18         my $this=shift;
19         my ($action)=@_;
20         my $ret = -e "CMakeLists.txt";
21         $ret &&= $this->SUPER::check_auto_buildable(@_) if $action ne "configure";
22         return $ret;
23 }
24
25 sub new {
26         my $class=shift;
27         my $this=$class->SUPER::new(@_);
28         # Enforce outside-source tree builds.
29         $this->enforce_outside_source_building();
30         return $this;
31 }
32
33 sub configure {
34         my $this=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         $this->mkdir_builddir();
46         $this->doit_in_builddir("cmake", $this->get_rel2builddir_path(), @flags);
47 }
48
49 1;