Skip to content

Conversation

@zezl7
Copy link

@zezl7 zezl7 commented Dec 4, 2025

Description

This PR enables the packaging and later installation of the CMake exercise with CPack.
To solely test the final version of the package, follow the instructions in the README.md.
To reproduce the entire workflow, follow the instructions in the Instructions section below.

Changes

Mandatory

  1. Modified the CMakeLists.txt to have an install target.
  2. Created cmake/CPackConfig.cmake and included it into the CMakeLists.txt.
  3. Further modified the cmake/CPackConfig.cmake to generate debian packages.
  4. Inspected the debian package using the linter.

Changes were done inside a Docker container.

Optional

  1. Fixed several linter errors and warnings. This is the initial and final output.
  • "extended-description-is-empty": set the CPACK_DEBIAN_PACKAGE_DESCRIPTION in the CPackConfig.cmake.
  • "no-phrase": set the CPACK_DEBIAN_PACKAGE_MAINTAINER in the CPackConfig.cmake.
  • "shared-library-lacks-version": added VERSION 0.1.0 and SOVERSION 1 to set_target_properties() in CMakeLists.txt.

Instructions

  1. Build a docker image
docker build -t sse-cpack-image .
  1. Create and run docker container in interactive mode and change into the desired directory
docker run --rm -it --mount type=bind,source="$(pwd)",target=/mnt/cpack-exercise sse-cpack-image
cd mnt/cpack-exercise
  1. Create the CPackConfig.cmake
mkdir cmake && cd cmake
vim CPackConfig.cmake
  1. After fully updating the CMakeLists.txt, build the code and create the package
mkdir build && cd build
cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release ..
make -j && make install
cpack -G "TGZ;DEB"
  1. Install the package, unpack it, and run the binary
apt install ./cpackexample_0.1.0_amd64.deb
dpkg-deb -R cpackexample_0.1.0_amd64.deb /mnt/cpack-exercise/build/cpackexample-debian
cd /cpackexample-debian/usr/bin && ./cpackexample
  1. Run the linter
lintian ./cpackexample_0.1.0_amd64.deb

Hints

  • GitLab username is @zlatanza.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant