Commit 37d7e250 authored by Kyle Edwards's avatar Kyle Edwards

Add CPack example

parent 8026e856
cmake_minimum_required(VERSION 3.5)
project(libcpackexample C)
include(GNUInstallDirs)
include(CPackComponent)
add_library(cpackexample SHARED example.c)
set_target_properties(cpackexample PROPERTIES
PUBLIC_HEADER "example.h"
VERSION 1.0
SOVERSION 1
)
install(TARGETS cpackexample
LIBRARY
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
COMPONENT Libraries
NAMELINK_SKIP
PUBLIC_HEADER
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
COMPONENT Headers
)
install(TARGETS cpackexample
LIBRARY
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
COMPONENT Namelinks
NAMELINK_ONLY
)
cpack_add_component(Libraries)
cpack_add_component(Namelinks GROUP Development DEPENDS Libraries)
cpack_add_component(Headers GROUP Development DEPENDS Libraries)
cpack_add_component_group(Development)
include(CPack)
CMake Example
=============
This example project demonstrates how to use dh-cmake's CPack functionality. It
can be built out of the box with dpkg-buildpackage.
Please note that this project depends on features that are currently only in
the CMake master branch. They will be available in CMake 3.13. If you want to
test this example, you will need to build CMake from source.
Look in the `debian/rules` file. Notice the `--with cpack` parameter. This
enables the `cpack` Debhelper sequence, which runs the `dh_cpack_generate`,
`dh_cpack_substvars`, and `dh_cpack_install` commands. The generate step
generates a .json file containing the CPack metadata, the substvars step puts
this metadata into the packages' substvars, and the install step installs the
CPack components and component groups in the respective packages.
The install step is very similar to `dh_cmake_install`, but it also supports
entire CPack groups. Look at `debian/libcpackexample.cpack-components` and
`debian/libcpackexample-dev.cpack-component-groups`, and compare these with the
`CMakeLists.txt` file.
Now look at `debian/control`. Notice the use of `${cpack:Depends}` in the
`libcpackexample-dev` package. This variable makes use of CPack's own internal
dependency graph. Because the `Headers` and `Namelink` components depend on the
`Libraries` component, `libcpackexample-dev` will depend on `libcpackexample`.
libcpackexample (1.0) unstable; urgency=medium
* Initial release.
-- Kyle Edwards <kyle.edwards@kitware.com> Thu, 05 Jul 2018 10:21:06 -0400
Source: libcpackexample
Maintainer: Example <example@example.com>
Build-Depends: cmake, dh-cmake, debhelper (>= 11)
Standards-Version: 4.1.5
Section: misc
Priority: extra
Package: libcpackexample
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: dh-cmake example - libraries
This package contains the shared libraries for the dh-cmake example project.
Package: libcpackexample-dev
Architecture: any
Depends: ${cpack:Depends}, ${misc:Depends}
Description: dh-cmake example - development
This package contains the development files for the dh-cmake example project.
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: libexample
Files: *
Copyright: 2018 Kitware, Inc.
License: BSD-3-clause
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
.
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#!/usr/bin/make -f
%:
dh $@ --buildsystem=cmake --with cpack
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment