1 # A debhelper build system class for handling CMake based projects.
2 # It prefers out of source tree building.
4 # Copyright: © 2008-2009 Modestas Vainius
7 package Debian::Debhelper::Buildsystem::cmake;
11 B<cmake> - CMake (CMakeLists.txt)
15 B<dh_auto_*> [B<--buildsystem>=I<cmake>] ...
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.
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.
40 use base 'Debian::Debhelper::Buildsystem::makefile';
43 "CMake (CMakeLists.txt)"
46 sub check_auto_buildable {
49 my $ret = -e $this->get_sourcepath("CMakeLists.txt");
50 $ret &&= $this->SUPER::check_auto_buildable(@_) if $step ne "configure";
56 my $this=$class->SUPER::new(@_);
57 # Prefer out of source tree building.
58 $this->enforce_out_of_source_building(@_);
68 Execute C<cmake> in the build directory passing a path to the source directory
69 and defining the following flags:
71 -DCMAKE_INSTALL_PREFIX=/usr
73 -DCMAKE_VERBOSE_MAKEFILE=ON
75 =item I<Auto-selection>
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.
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";
92 $this->mkdir_builddir();
93 $this->doit_in_builddir("cmake", $this->get_source_rel2builddir(), @flags);
102 Execute C<make> in the build directory. See I<makefile> build system documentation
103 for more information.
105 =item I<Auto-selection>
107 It is normal for the I<makefile> build system to be auto-selected at this step.
117 Execute C<make test> in the build directory. See I<makefile> build system
118 documentation for more information.
120 =item I<Auto-selection>
122 It is normal for the I<makefile> build system to be auto-selected at this step.
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.
136 =item I<Auto-selection>
138 It is normal for the I<makefile> build system to be auto-selected at this step.
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.
152 =item I<Auto-selection>
154 It is normal for the I<makefile> build system to be auto-selected at this step.
160 L<dh_auto_makefile(7)>
166 Modestas Vainius <modestas@vainius.eu>