Sample Header Ad - 728x90

Packaging CMake components for Debian

1 vote
2 answers
2481 views
I have a single upstream source package using cmake and I'd like to package it as two binary debian packages.
$ tree proj
proj/
├── app1.c
├── app2.c
└── CMakeLists.txt
Upstream's CMakeLists.txt was already written with this in mind. They use the COMPONENTS argument of [install](https://cmake.org/cmake/help/v3.7/command/install.html)
$ cat proj/CMakeLists.txt
include(GnuInstallDirs)

add_executable(app1 app1.c)
install(
  TARGETS app1 
  RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
  COMPONENT app1)

add_executable(app2 app2.c)
install(
  TARGETS app2
  RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
  COMPONENT app2)
To compile/install locally, it's pretty easy:
$ mkdir build && cd build
$ cmake ../proj -DCMAKE_INSTALL_PREFIX=/usr/local  # Configure
$ cmake --build .                                  # Build
$ cmake -DCOMPONENT=app1 -P cmake_install.cmake    # Install app1 component
$ cmake -DCOMPONENT=app2 -P cmake_install.cmake    # Install app2 component
But how would you build a debian/rules file for this?
Asked by Stewart (15631 rep)
May 20, 2019, 03:05 PM
Last activity: Dec 30, 2024, 10:01 AM