// vim:set filetype=asciidoc:
[[cmake-single]]
=== CMake (single-binary package)

Here is an example of creating a simple Debian package from a simple C source program using CMake (*CMakeLists.txt* and some files such as *config.h.in*) as its build system.

The *cmake* command generates the *Makefile* file based on the *CMakeLists.txt* file and its *-D* option.  It also configures the file as specified in its *configure_file(...)* by replacing strings with *@...@* and changing the *#cmakedefine ...* line.

Let's assume this upstream tarball to be *debhello-1.7.tar.gz*.

This type of source is meant to be installed as a non-system file, for example, as:

----
 $ tar -xzmf debhello-1.7.tar.gz
 $ cd debhello-1.7
 $ mkdir obj-x86_64-linux-gnu # for out-of-tree build
 $ cd obj-x86_64-linux-gnu
 $ cmake ..
 $ make
 $ make install
----

Let's get the source and make the Debian package.

.Download *debhello-1.7.tar.gz*
----
include::../examples/debhello-1.7_build-1/step000.slog[]
----

Here, the contents of this source are as follows.

.*src/hello.c* (v=1.7):
----
include::../examples/debhello-1.7_build-1/step101.slog[]
----

.*src/config.h.in* (v=1.7):
----
include::../examples/debhello-1.7_build-1/step102.slog[]
----

.*CMakeLists.txt* (v=1.7):
----
include::../examples/debhello-1.7_build-1/step103.slog[]
----

Let's package this with the *debmake* command.

----
include::../examples/debhello-1.7_build-1/step200.slog[lines=1..3]
 ...
include::../examples/debhello-1.7_build-1/step200.slog-sanity[]
 ...
----

The result is similar to "`<<configure-single>>`" but not exactly the same.

Let's inspect the notable template files generated.

// .The source tree after the basic *debmake* execution. (v=1.7)
// ----
// include::../examples/debhello-1.7_build-1/step201.slog[]
// ----

.*debian/rules* (template file, v=1.7):
----
include::../examples/debhello-1.7_build-1/step202.slog[]
----

.*debian/control* (template file, v=1.7):
----
include::../examples/debhello-1.7_build-1/step203.slog[]
----

Let's make this Debian package better as the maintainer.

.*debian/rules* (maintainer version, v=1.7):
----
include::../examples/debhello-1.7_build-1/step301.slog[]
----

.*debian/control* (maintainer version, v=1.7):
----
include::../examples/debhello-1.7_build-1/step302.slog[]
----

There are several other template files under the *debian/* directory.  These also need to be updated.

The rest of the packaging activities are practically the same as the one in "`<<configure-single>>`".
