cmake_minimum_required(VERSION 2.8.3)
project(hip_hcc)

install(FILES @PROJECT_BINARY_DIR@/libhip_hcc.so DESTINATION lib)
install(FILES @PROJECT_BINARY_DIR@/libhip_hcc.so.@HIP_LIB_VERSION_MAJOR@ DESTINATION lib)
install(FILES @PROJECT_BINARY_DIR@/libhip_hcc.so.@HIP_LIB_VERSION_STRING@ DESTINATION lib)
install(FILES @PROJECT_BINARY_DIR@/libhip_hcc_static.a DESTINATION lib)
if(NOT @HIP_COMPILER@ STREQUAL "clang")
    install(FILES @PROJECT_BINARY_DIR@/libhiprtc.so DESTINATION lib)
    install(FILES @PROJECT_BINARY_DIR@/libhiprtc.so.@HIP_LIB_VERSION_MAJOR@ DESTINATION lib)
    install(FILES @PROJECT_BINARY_DIR@/libhiprtc.so.@HIP_LIB_VERSION_STRING@ DESTINATION lib)
endif()
install(FILES @PROJECT_BINARY_DIR@/.hipInfo DESTINATION lib)
install(FILES @PROJECT_BINARY_DIR@/hip-config.cmake @PROJECT_BINARY_DIR@/hip-config-version.cmake DESTINATION lib/cmake/hip)
install(FILES @CONFIG_PACKAGE_INSTALL_DIR@/hip-targets.cmake @CONFIG_PACKAGE_INSTALL_DIR@/hip-targets-release.cmake DESTINATION lib/cmake/hip)

#############################
# Packaging steps
#############################
set(CPACK_SET_DESTDIR TRUE)
set(CPACK_INSTALL_PREFIX @CPACK_INSTALL_PREFIX@ )
set(CPACK_PACKAGE_NAME "hip-hcc")
if(@HCC_VERSION_MAJOR@ EQUAL 0)
    set(HCC_PACKAGE_NAME "hcc_lc")
else()
    set(HCC_PACKAGE_NAME "hcc")
endif()
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "HIP: Heterogenous-computing Interface for Portability [HCC]")
set(CPACK_PACKAGE_VENDOR "Advanced Micro Devices, Inc.")
set(CPACK_PACKAGE_CONTACT "HIP Support <hip.support@amd.com>")
set(CPACK_PACKAGE_VERSION_MAJOR @HIP_VERSION_MAJOR@)
set(CPACK_PACKAGE_VERSION_MINOR @HIP_VERSION_MINOR@)
set(CPACK_PACKAGE_VERSION_PATCH @HIP_VERSION_PATCH@)
set(CPACK_PACKAGE_VERSION @HIP_VERSION_MAJOR@.@HIP_VERSION_MINOR@.@HIP_PACKAGING_VERSION_PATCH@)
set(CPACK_GENERATOR "TGZ;DEB;RPM")

set(CPACK_BINARY_DEB "ON")
set(CPACK_DEBIAN_PACKAGE_RELEASE @CPACK_DEBIAN_PACKAGE_RELEASE@)
set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${PROJECT_BINARY_DIR}/postinst;${PROJECT_BINARY_DIR}/prerm")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "hip-base (= ${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE}), ${HCC_PACKAGE_NAME} (= @HCC_PACKAGE_VERSION@), comgr (>= 1.1)")
set(CPACK_DEBIAN_PACKAGE_PROVIDES "hip-hcc")
set(CPACK_DEBIAN_PACKAGE_REPLACES "hip_hcc")

set(CPACK_BINARY_RPM "ON")
set(CPACK_RPM_PACKAGE_RELEASE @CPACK_RPM_PACKAGE_RELEASE@)
set(CPACK_RPM_FILE_NAME "RPM-DEFAULT")
set(CPACK_RPM_PACKAGE_ARCHITECTURE "${CMAKE_SYSTEM_PROCESSOR}")
set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${PROJECT_BINARY_DIR}/postinst")
set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${PROJECT_BINARY_DIR}/prerm")
set(CPACK_RPM_PACKAGE_AUTOREQPROV " no")
string(REPLACE "-" "_" HIP_BASE_VERSION ${CPACK_PACKAGE_VERSION})
set(CPACK_RPM_PACKAGE_REQUIRES "hip-base = ${HIP_BASE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}, ${HCC_PACKAGE_NAME} = @HCC_PACKAGE_VERSION@, comgr >= 1.1")
set(CPACK_RPM_PACKAGE_OBSOLETES "hip_hcc")
set(CPACK_RPM_PACKAGE_CONFLICTS "hip_hcc")
set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/opt")
set(CPACK_SOURCE_GENERATOR "TGZ")
include(CPack)
