]> git.donarmstrong.com Git - debhelper.git/blob - Debian/Debhelper/Buildsystem/cmake.pm
Update dh_auto documentation.
[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 =head1 NAME
10
11 B<cmake> - CMake (CMakeLists.txt)
12
13 =head1 SYNOPSIS
14
15 B<dh_auto_*> [B<--buildsystem>=I<cmake>] ...
16
17 =head1 DESCRIPTION
18
19 CMake is a family of tools designed to build, test and package software. CMake
20 generates F<Makefile>s and other temporary files in the build directory from
21 the directives present in the F<CMakeLists.txt> and a couple of other build
22 system source files. Then a standard set of make targets needs to be executed
23 in the build directory to complete source building process. CMake is available
24 in the cmake package that is essential throughout the whole build process.
25
26 =head1 DH_AUTO NOTES
27
28 Out of source tree building is done by default if this debhelper build system
29 is selected. This is due to the fact that there is no way to properly clean up
30 build directory from temporary files unless it is removed completely.
31 Therefore I<clean> step cannot be fully implemented if building is done in
32 source. However, the user may still enable in source building by explicitly
33 specifying a build directory path that is equal to the source directory path.
34
35 =head1 BUILD PROCESS
36
37 =cut
38
39 use strict;
40 use base 'Debian::Debhelper::Buildsystem::makefile';
41
42 sub DESCRIPTION {
43         "CMake (CMakeLists.txt)"
44 }
45
46 sub check_auto_buildable {
47         my $this=shift;
48         my ($step)=@_;
49         my $ret = -e $this->get_sourcepath("CMakeLists.txt");
50         $ret &&= $this->SUPER::check_auto_buildable(@_) if $step ne "configure";
51         return $ret;
52 }
53
54 sub new {
55         my $class=shift;
56         my $this=$class->SUPER::new(@_);
57         # Prefer out of source tree building.
58         $this->enforce_out_of_source_building(@_);
59         return $this;
60 }
61
62 =head2 Configure step
63
64 =over 4
65
66 =item I<Behaviour>
67
68 Execute C<cmake> in the build directory passing a path to the source directory
69 and defining the following flags:
70
71  -DCMAKE_INSTALL_PREFIX=/usr
72  -DCMAKE_SKIP_RPATH=ON
73  -DCMAKE_VERBOSE_MAKEFILE=ON
74
75 =item I<Auto-selection>
76
77 If F<CMakeLists.txt> file exists but neither F<configure>, F<Makefile.PL>,
78 F<setup.py> or F<Build.PL> exist in the source directory.
79
80 =back
81
82 =cut
83 sub configure {
84         my $this=shift;
85         my @flags;
86
87         # Standard set of cmake flags
88         push @flags, "-DCMAKE_INSTALL_PREFIX=/usr";
89         push @flags, "-DCMAKE_SKIP_RPATH=ON";
90         push @flags, "-DCMAKE_VERBOSE_MAKEFILE=ON";
91
92         $this->mkdir_builddir();
93         $this->doit_in_builddir("cmake", $this->get_source_rel2builddir(), @flags);
94 }
95
96 =head2 Build step
97
98 =over 4
99
100 =item I<Behaviour>
101
102 Execute C<make> in the build directory. See I<makefile> build system documentation
103 for more information.
104
105 =item I<Auto-selection>
106
107 It is normal for the I<makefile> build system to be auto-selected at this step.
108
109 =back
110
111 =head2 Test step
112
113 =over 4
114
115 =item I<Behaviour>
116
117 Execute C<make test> in the build directory. See I<makefile> build system
118 documentation for more information.
119
120 =item I<Auto-selection>
121
122 It is normal for the I<makefile> build system to be auto-selected at this step.
123
124 =back
125
126 =head2 Install step
127
128 =over 4
129
130 =item I<Behaviour>
131
132 Execute C<make install DESTDIR=$destdir> in the build directory with $destdir
133 set to the appropriate temporary installation directory. See I<makefile> build
134 system documentation for more information.
135
136 =item I<Auto-selection>
137
138 It is normal for the I<makefile> build system to be auto-selected at this step.
139
140 =back
141
142 =head2 Clean step
143
144 =over 4
145
146 =item I<Behaviour>
147
148 Remove the build directory if building out of source tree (complete clean up)
149 or execute C<make clean> if building in source (incomplete clean up). See
150 I<makefile> build system documentation for more information.
151
152 =item I<Auto-selection>
153
154 It is normal for the I<makefile> build system to be auto-selected at this step.
155
156 =back
157
158 =head1 SEE ALSO
159
160 L<dh_auto_makefile(7)>
161
162 L<dh_auto(7)>
163
164 =head1 AUTHORS
165
166  Modestas Vainius <modestas@vainius.eu>
167
168 =cut
169
170 1;