diff --git a/CMakeLists.txt b/CMakeLists.txt index 94d6c2c..3083dc4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,10 +13,33 @@ find_package(Boost 1.83 COMPONENTS filesystem REQUIRED) find_package(yaml-cpp 0.6 REQUIRED) add_library(cpackexamplelib filesystem/filesystem.cpp fem/fem.cpp flatset/flatset.cpp yamlParser/yamlParser.cpp) + +set_target_properties(cpackexamplelib PROPERTIES VERSION 0.1.0 SOVERSION 1 PUBLIC_HEADER "filesystem/filesystem.hpp;fem/fem.hpp;flatset/flatset.hpp;yamlParser/yamlParser.hpp") + +target_include_directories(cpackexamplelib + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + PUBLIC + $ + $ +) + add_executable("${PROJECT_NAME}" main.cpp) target_link_libraries("${PROJECT_NAME}" cpackexamplelib) target_link_libraries(cpackexamplelib Boost::filesystem ${YAML_CPP_LIBRARIES}) +include(GNUInstallDirs) +install(TARGETS cpackexample cpackexamplelib + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/cpackexamplelib + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/cpackexamplelib + ) + +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +include(CPackConfig) + DEAL_II_SETUP_TARGET("${PROJECT_NAME}") DEAL_II_SETUP_TARGET(cpackexamplelib) diff --git a/README.md b/README.md index 8e950e4..26e58b3 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,25 @@ # 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). + +## Building the package + +```bash +mkdir build && cd build +cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release .. +make -j && make install +cpack -G "TGZ;DEB" +``` + +## Installing the package + +```bash +apt install ./cpackexample_0.1.0_amd64.deb +``` + +## Unpacking the package and running the binary + +```bash +dpkg-deb -R cpackexample_0.1.0_amd64.deb /cpackexample-debian +cd /cpackexample-debian/usr/bin && ./cpackexample +``` diff --git a/cmake/CPackConfig.cmake b/cmake/CPackConfig.cmake new file mode 100644 index 0000000..ab4177f --- /dev/null +++ b/cmake/CPackConfig.cmake @@ -0,0 +1,17 @@ +set(CPACK_PACKAGE_NAME ${PROJECT_NAME}) + +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "This file configures the cpack packaging process." + CACHE STRING "Extended summary.") + +set(CPACK_PACKAGE_VENDOR "Zara Zlatanova") +set(CPACK_PACKAGE_CONTACT "zara.zlatanova@protonmail.com") +set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Zara Zlatanova <${CPACK_PACKAGE_CONTACT}>") +set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/zezl7/cpack-exercise-wt2526") +set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT) +set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS YES) +set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS YES) +set(CPACK_STRIP_FILES TRUE) + +set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "Once unpacked, the binary cpackexample prints the SSE course work.") + +include(CPack) diff --git a/lintian_final_output.sh b/lintian_final_output.sh new file mode 100644 index 0000000..f1bf8d3 --- /dev/null +++ b/lintian_final_output.sh @@ -0,0 +1,10 @@ +$ lintian ./cpackexample_0.1.0_amd64.deb +running with root privileges is not recommended! +E: cpackexample: lacks-ldconfig-trigger usr/lib/libcpackexamplelib.so.0.1.0 +E: cpackexample: no-changelog usr/share/doc/cpackexample/changelog.gz (native package) +E: cpackexample: no-copyright-file +W: cpackexample: link-to-shared-library-in-wrong-package usr/lib/libcpackexamplelib.so.0.1.0 [usr/lib/libcpackexamplelib.so] +W: cpackexample: maintscript-calls-ldconfig [postinst] +W: cpackexample: maintscript-calls-ldconfig [postrm] +W: cpackexample: no-manual-page [usr/bin/cpackexample] +W: cpackexample: package-name-doesnt-match-sonames libcpackexamplelib1 diff --git a/lintian_initial_output.sh b/lintian_initial_output.sh new file mode 100644 index 0000000..a78bc6e --- /dev/null +++ b/lintian_initial_output.sh @@ -0,0 +1,12 @@ +$ lintian ./cpackexample_0.1.0_amd64.deb +running with root privileges is not recommended! +E: cpackexample: extended-description-is-empty +E: cpackexample: lacks-ldconfig-trigger usr/lib/libcpackexamplelib.so +E: cpackexample: no-changelog usr/share/doc/cpackexample/changelog.gz (native package) +E: cpackexample: no-copyright-file +E: cpackexample: no-phrase Maintainer zara.zlatanova@protonmail.com +W: cpackexample: no-manual-page [usr/bin/cpackexample] +W: cpackexample: package-name-doesnt-match-sonames libcpackexamplelib +W: cpackexample: shared-library-lacks-version usr/lib/libcpackexamplelib.so libcpackexamplelib.so +W: cpackexample: undeclared-elf-prerequisites (libboost_filesystem.so.1.83.0 libc.so.6 libdeal.ii.so.9.5.1 libgcc_s.so.1 libm.so.6 libmpi.so.40 libmpi_cxx.so.40 libstdc++.so.6 libtbb.so.12 libyaml-cpp.so.0.6) [usr/lib/libcpackexamplelib.so] +W: cpackexample: undeclared-elf-prerequisites (libc.so.6 libcpackexamplelib.so libdeal.ii.so.9.5.1 libgcc_s.so.1 libmpi.so.40 libmpi_cxx.so.40 libstdc++.so.6 libtbb.so.12) [usr/bin/cpackexample] \ No newline at end of file