set(CPACK_PACKAGE_VENDOR "Jacek Swierk")
set(CPACK_PACKAGE_CONTACT "Jacek Swierk <jacek.swierk@gmail.com>")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A helpful debugging macro")
set(CPACK_PROJECT_URL "https://github.com/gessen/jdbg")
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
set(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/README.md")

set(CPACK_GENERATOR TXZ)
set(CPACK_PACKAGE_RELOCATABLE ON)

set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
set(CPACK_DEBIAN_PACKAGE_NAME "lib${PROJECT_NAME}-dev")
set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")

set(CPACK_RPM_PACKAGE_AUTOPROV ON)
set(CPACK_RPM_PACKAGE_NAME "${PROJECT_NAME}-devel")
set(CPACK_RPM_PACKAGE_LICENSE "MIT")
set(CPACK_RPM_FILE_NAME "RPM-DEFAULT")

set(ignored_files)
set(gitignore "${PROJECT_SOURCE_DIR}/.gitignore")
if(EXISTS "${gitignore}")
  file(STRINGS "${gitignore}" content)
  foreach(line ${content})
    if(line MATCHES "^#")
      continue()
    endif()
    string(REPLACE "." "[.]" line "${line}")
    string(REPLACE "*" ".*" line "${line}")
    list(APPEND ignored_files "${line}")
  endforeach()
endif()
list(APPEND ignored_files "/.git.*")

set(CPACK_SOURCE_GENERATOR TXZ)
set(CPACK_SOURCE_IGNORE_FILES ${ignored_files})
set(CPACK_SOURCE_PACKAGE_FILE_NAME ${PROJECT_NAME}-${PROJECT_VERSION})

include(CPack)
