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
29 changes: 29 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION "3.28")

project("cpackexample" VERSION 0.1.0)

# --- Find Dependencies ---
FIND_PACKAGE(deal.II 9.5 REQUIRED
HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}
)
Expand All @@ -12,11 +13,39 @@ find_package(Boost 1.83 COMPONENTS filesystem REQUIRED)

find_package(yaml-cpp 0.6 REQUIRED)

# --- Define Targets ---
add_library(cpackexamplelib filesystem/filesystem.cpp fem/fem.cpp flatset/flatset.cpp yamlParser/yamlParser.cpp)
add_executable("${PROJECT_NAME}" main.cpp)

# --- Link Libraries ---
target_link_libraries("${PROJECT_NAME}" cpackexamplelib)
target_link_libraries(cpackexamplelib Boost::filesystem ${YAML_CPP_LIBRARIES})

# --- Configure Deal.II ---
DEAL_II_SETUP_TARGET("${PROJECT_NAME}")
DEAL_II_SETUP_TARGET(cpackexamplelib)

# --- 1. Add Install Target to CMake Configuration ---

# Install the executable to <prefix>/bin
install(TARGETS "${PROJECT_NAME}" RUNTIME DESTINATION bin)

# Install the library to <prefix>/lib
# We specify both ARCHIVE (static libs) and LIBRARY (shared libs) to be safe
install(TARGETS cpackexamplelib
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)

# Install header files to <prefix>/include/cpackexamplelib
install(FILES
fem/fem.hpp
filesystem/filesystem.hpp
flatset/flatset.hpp
yamlParser/yamlParser.hpp
DESTINATION include/cpackexamplelib
)

# --- 2. Add CPack Configuration ---
include(cmake/CPackConfig.cmake)
include(CPack)
22 changes: 22 additions & 0 deletions cmake/CPackConfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Basic Package Info
set(CPACK_PACKAGE_NAME "cpack-exercise")
set(CPACK_PACKAGE_VENDOR "Simulation Software Engineering")
set(CPACK_PACKAGE_CONTACT "RickySandi <rickysandis@gmail.com>")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A sample project for learning CPack")
set(CPACK_PACKAGE_VERSION_MAJOR ${cpackexample_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${cpackexample_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${cpackexample_VERSION_PATCH})

set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")

# --- Generators ---
set(CPACK_GENERATOR "TGZ;DEB")

# --- Debian Specific Settings ---
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Ricky") # Required by Debian
set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") # Use standard naming (name_version_arch.deb)

set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)

# --- Lintian / Optimization ---
set(CPACK_STRIP_FILES ON)