set(CPACK_PACKAGE_VENDOR "TSG")
set(CPACK_PACKAGE_VERSION_MAJOR "${VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${VERSION_PATCH}.${DESCRIBE}")
set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})

# RPM Build
set(CPACK_GENERATOR "RPM")
set(CPACK_RPM_AUTO_GENERATED_FILE_NAME ON)
set(CPACK_RPM_FILE_NAME "RPM-DEFAULT")
set(CPACK_RPM_PACKAGE_AUTOREQPROV "no")
set(CPACK_RPM_PACKAGE_RELEASE_DIST on)
set(CPACK_RPM_DEBUGINFO_PACKAGE on)
set(CPACK_RPM_COMPONENT_INSTALL ON)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
    set(CPACK_RPM_PROGRAM_PACKAGE_NAME "stellar-debug")
    set(CPACK_RPM_LIBRARIES_PACKAGE_NAME "stellar-devel-debug")
else()
    set(CPACK_RPM_PROGRAM_PACKAGE_NAME "stellar")
    set(CPACK_RPM_LIBRARIES_PACKAGE_NAME "stellar-devel")
endif()

set(CPACK_COMPONENT_PROGRAM_REQUIRED TRUE)
set(CPACK_RPM_PROGRAM_PACKAGE_CONFLICTS ${CPACK_RPM_PROGRAM_PACKAGE_NAME})

set(CPACK_COMPONENT_LIBRARIES_REQUIRED TRUE)
set(CPACK_RPM_LIBRARIES_PACKAGE_CONFLICTS ${CPACK_RPM_LIBRARIES_PACKAGE_NAME})

set(CPACK_COMPONENTS_ALL LIBRARIES PROGRAM)

# setup %config(noreplace)
set(CPACK_RPM_USER_FILELIST "%config(noreplace) ${CMAKE_INSTALL_PREFIX}/conf/stellar.toml")
set(CPACK_RPM_USER_FILELIST "%config(noreplace) ${CMAKE_INSTALL_PREFIX}/conf/log.toml")

include(CPack)