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

This example demonstrates creating a set of Debian binary packages including the executable package, the shared library package, the development file package, and the debug symbol package from a simple C source program using CMake (*CMakeLists.txt* and files such as *config.h.in*) as its build system.

Let's assume this upstream tarball to be *debhello-2.1.tar.xz*.

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

----
[base_dir] $ tar --xz -xmf debhello-2.1.tar.xz
[base_dir] $ cd debhello-2.1
[debhello-2.1] $ mkdir obj-x86_64-linux-gnu
[debhello-2.1] $ cd obj-x86_64-linux-gnu
[debhello-2.1] $ cmake ..
[debhello-2.1] $ make
[debhello-2.1] $ make install
----

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

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

Here, the contents of this source are as follows.

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

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

.*lib/sharedlib.c* and *lib/sharedlib.h* (v=2.1):
----
include::../examples/debhello-2.1_build-1/step104.slog[]
----

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

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

----
include::../examples/debhello-2.1_build-1/step200.slog[lines=1..23]
 ...
----

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

Let's inspect the notable template files generated.

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

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

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

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

.**debian/*.install** (maintainer version, v=2.1):
----
include::../examples/debhello-2.1_build-1/step303.slog[]
----

The upstream CMakeLists.txt file needs to be patched to handle the multiarch path correctly.

.*debian/patches/** (maintainer version, v=2.1):
----
include::../examples/debhello-2.1_build-1/step304.slog[]
----

Since this upstream source creates the proper auto-generated *Makefile*, there is no need to create *debian/install* and *debian/manpages* files.

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

.Template files under *debian/*. (v=2.1):
----
include::../examples/debhello-2.1_build-1/step400.slog[]
----

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

Here are the generated dependency list of all binary packages.

.The generated dependency list of all binary packages (v=2.1):
----
include::../examples/debhello-2.1_build-1/step702.slog[]
----
