set(EXPORT_NAME ${PROJECT_NAME})

INCLUDE(GNUInstallDirs)
INSTALL(
        TARGETS ${POSE_LIB_NAME}
        EXPORT ${EXPORT_NAME}
        ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
        PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

INSTALL(DIRECTORY include/hyperpose DESTINATION include)

INCLUDE(CPack)
# SET(CPACK_PACKAGE_DIRECTORY ${CMAKE_SOURCE_DIR}/release)
SET(CPACK_GENERATOR "TGZ")
SET(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})

INSTALL(EXPORT ${EXPORT_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${EXPORT_NAME})
include(CMakePackageConfigHelpers)
CONFIGURE_PACKAGE_CONFIG_FILE(
        ${CMAKE_SOURCE_DIR}/cmake/HyperPoseConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/HyperPoseConfig.cmake
        INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${EXPORT_NAME}
)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/HyperPoseConfig.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${EXPORT_NAME})
EXPORT(EXPORT ${EXPORT_NAME} FILE ${CMAKE_INSTALL_LIBDIR}/cmake/${EXPORT_NAME}.cmake)

MESSAGE(STATUS "Create target ${POSE_LIB_NAME} for export ${EXPORT_NAME}. Install INCLUDEDIR: ${CMAKE_INSTALL_INCLUDEDIR}. Install LIBDIR: ${CMAKE_INSTALL_LIBDIR}")