Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,25 @@ target_link_libraries(cpackexamplelib Boost::filesystem ${YAML_CPP_LIBRARIES})

DEAL_II_SETUP_TARGET("${PROJECT_NAME}")
DEAL_II_SETUP_TARGET(cpackexamplelib)

include(GNUInstallDirs)

install(TARGETS cpackexample
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

install(TARGETS cpackexamplelib
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})

install(FILES
fem/fem.hpp
filesystem/filesystem.hpp
flatset/flatset.hpp
yamlParser/yamlParser.hpp
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/cpackexamplelib)

# Include our packaging module
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(CPackConfig)


72 changes: 72 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,75 @@
# Packaging with CPack

Repository for the [CPack exercise](https://github.com/Simulation-Software-Engineering/Lecture-Material/blob/main/03_building_and_packaging/cpack_exercise.md). The code is a slightly modified version of the [code used in the CMake exercise](https://github.com/Simulation-Software-Engineering/cmake-exercise).

## How to Test the Code

0. **Clone the directory and go inside the root of the directory**
```bash
git clone https://github.com/jkhanGitHub/cpack-exercise-wt2526.git
cd cpack-exercise-wt2526
```

To test the changes made for the CPack exercise, follow these steps:

1. **Build the Docker Image:**
First, build the Docker image which provides the necessary build environment.
```bash
docker build -t cpack-exercise .
```

2. **Run the Docker Container:**
Run the Docker container, mounting the current directory to `/mnt/cpack-exercise`.
```bash
docker run --rm -it --mount type=bind,source="$(pwd)",target=/mnt/cpack-exercise cpack-exercise
```
inside the Docker container cd into `/mnt/cpack-exercise`.
```bash
cd /mnt/cpack-exercise
```

4. **Configure and Build the Project (Inside the Container):**
Once inside the container, configure CMake and build the project.
```bash
cmake -B build -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release
cmake --build build
```

5. **Install the Project (Inside the Container):**
Run the install target to place the executable, library, and headers in the designated installation directories.
```bash
cmake --install build
```
You can verify the installation by checking the `/usr/local/bin`, `/usr/local/lib`, and `/usr/local/include/cpackexamplelib` directories.

6. **Generate Packages (Inside the Container):**
Build the `package` target to generate both `.tar.gz` and Debian (`.deb`) packages.
```bash
cmake --build build --target package
```
The generated packages will be in the `build/` directory, e.g., `cpackexample-0.1.0-Linux.tar.gz` and `cpackexample_0.1.0_amd64.deb`.

7. **Install the Debian Package (Inside the Container):**
Install the generated Debian package using `apt`.
```bash
apt install ./build/cpackexample_0.1.0_amd64.deb
```

8. **Run the Installed Executable (Inside the Container):**
Verify that the executable is in the system's PATH and runs correctly.
```bash
which cpackexample
cpackexample yamlParser/config.yml
```
The output should show the program executing its various modules.

9. **Check the Debian Package with Lintian (Inside the Container):**
Inspect the generated Debian package for common errors and policy violations using `lintian`.
```bash
lintian build/cpackexample_0.1.0_amd64.deb
```
*Note: Several warnings and errors are expected from `lintian` as per the exercise instructions, and no fixes for these were implemented as they were optional tasks.*

## Optional Tasks

No optional tasks were completed as part of this exercise.
17 changes: 17 additions & 0 deletions cmake/CPackConfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
set(CPACK_PACKAGE_NAME "${PROJECT_NAME}")
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
set(CPACK_PACKAGE_VENDOR "Gemini")
set(CPACK_PACKAGE_CONTACT "gemini@google.com")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A CPack exercise to demonstrate packaging a C++ application.")
set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/Simulation-Software-Engineering/cpack-exercise-wt2526")

set(CPACK_GENERATOR "TGZ;DEB")

# Debian packaging section
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS YES)

# strip really all Debug symbols
set(CPACK_STRIP_FILES TRUE)

include(CPack)