cmake_minimum_required(VERSION 2.8.3)
project(hip_doc)

find_program(DOXYGEN_EXE doxygen)
if(DOXYGEN_EXE)
    add_custom_target(build_doxygen ALL
                  COMMAND HIP_PATH=@hip_SOURCE_DIR@ doxygen @hip_SOURCE_DIR@/docs/doxygen-input/doxy.cfg)
    install(DIRECTORY RuntimeAPI/html DESTINATION docs/docs/RuntimeAPI)
endif()

#find_program(GRIP_EXE grip)
#if(GRIP_EXE)
#    add_custom_target(convert_md_to_html ALL
#                  COMMAND @hip_SOURCE_DIR@/packaging/convert_md_to_html.sh @hip_SOURCE_DIR@ ${PROJECT_BINARY_DIR}/md2html)
#    install(DIRECTORY md2html/ DESTINATION docs)
#endif()

#############################
# Packaging steps
#############################
set(CPACK_SET_DESTDIR TRUE)
set(CPACK_INSTALL_PREFIX @CPACK_INSTALL_PREFIX@ )
set(CPACK_PACKAGE_NAME "hip-doc")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "HIP: Heterogenous-computing Interface for Portability [DOCUMENTATION]")
set(CPACK_PACKAGE_VENDOR "Advanced Micro Devices, Inc.")
set(CPACK_PACKAGE_CONTACT "Maneesh Gupta <maneesh.gupta@amd.com>")
set(CPACK_PACKAGE_VERSION @HIP_VERSION_MAJOR@.@HIP_VERSION_MINOR@.@HIP_VERSION_PATCH@)
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_FILE_NAME ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH})
set(CPACK_GENERATOR "TGZ;DEB;RPM")
set(CPACK_BINARY_DEB "ON")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "hip-base (= ${CPACK_PACKAGE_VERSION})")
set(CPACK_DEBIAN_PACKAGE_PROVIDES "hip_doc")
set(CPACK_DEBIAN_PACKAGE_REPLACES "hip_doc")
set(CPACK_DEBIAN_PACKAGE_CONFLICTS "hip_doc")
set(CPACK_BINARY_RPM "ON")
set(CPACK_RPM_PACKAGE_ARCHITECTURE "${CMAKE_SYSTEM_PROCESSOR}")
set(CPACK_RPM_PACKAGE_AUTOREQPROV " no")
string(REPLACE "-" "_" HIP_BASE_VERSION ${CPACK_PACKAGE_VERSION})
set(CPACK_RPM_PACKAGE_REQUIRES "hip-base = ${HIP_BASE_VERSION}")
set(CPACK_RPM_PACKAGE_OBSOLETES "hip_doc")
set(CPACK_RPM_PACKAGE_CONFLICTS "hip_doc")
set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/opt")
set(CPACK_SOURCE_GENERATOR "TGZ")
include(CPack)
