# Setup automatic generation of the changelog
MESSAGE(STATUS "CPack for Linux configuration..." )

SET( CPACK_SOURCE_PACKAGE_FILE_NAME "httraqt-${HTTRAQT_VERSION}" )
SET( CPACK_SOURCE_IGNORE_FILES
    "/\\\\.svn/"
    "/\\\\.kdev4/"
    "/\\\\.git/"
    "/pics/"
    "/build/"
    "~$"
    "\\\\.pcs$"
#     "TODO.txt"
#     "CMakeLists.txt.user"
#     "/doxygen/"
#     "${CMAKE_BINARY_DIR}"
)


# --- Package generation
SET( HTTRAQT_CPACK_BUILD_CONFIG "Release_and_Debug" )
SET( HTTRAQT_CPACK_PACKAGE_NAME ${CMAKE_PROJECT_NAME})
SET( HTTRAQT_CPACK_PACKAGE_VENDOR "KarboSoft" )
SET( HTTRAQT_CPACK_PACKAGE_INSTALL_DIRECTORY "HTTraQt ${HTTRAQT_VERSION}" )
SET( HTTRAQT_CPACK_PACKAGE_INSTALL_REGISTRY_KEY "HTTraQt ${HTTRAQT_VERSION}" )
SET( HTTRAQT_CPACK_PACKAGE_HOMEPAGE "http://httraqt.sourceforge.net/" )


# Setup global packaging parameters ...
SET( HTTRAQT_CPACK_INSTALL_CMAKE_PROJECTS "${CURRENT_BUILD_DIR};httraqt;ALL;/" )
# MESSAGE("HTTRAQT_BINARY_DIR ${CURRENT_BUILD_DIR}")
SET( HTTRAQT_CPACK_PACKAGE_DESCRIPTION "HTTraQt free GUI for httrack library." )
SET( HTTRAQT_CPACK_PACKAGE_FILE_NAME "httraqt-setup-${HTTRAQT_VERSION}" )
SET( HTTRAQT_CPACK_PACKAGE_VERSION "${HTTRAQT_VERSION}" )
SET( HTTRAQT_CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENCE" )
SET( HTTRAQT_CPACK_SOURCE_IGNORE_FILES "/CVS/;/.svn/;/.hg/" )
SET( HTTRAQT_CPACK_SOURCE_INSTALLED_DIRECTORIES "${PROJECT_SOURCE_DIR};/" )
SET( HTTRAQT_CPACK_SOURCE_PACKAGE_FILE_NAME "httraqt-source-${HTTRAQT_VERSION}" )

# SET( HTTRAQT_CPACK_PACKAGE_NAME ${CMAKE_PROJECT_NAME} )
SET( HTTRAQT_CPACK_PACKAGE_VERSION ${HTTRAQT_VERSION} )
SET( HTTRAQT_CPACK_PACKAGE_RELEASE 0 )
SET( HTTRAQT_CPACK_PACKAGE_MAINTAINER "Eduard Kalinowski <eduard_kalinowski@yahoo.de>" )
SET( HTTRAQT_CPACK_PACKAGE_MAINTAINER_NAME "Eduard Kalinowski" )
SET( HTTRAQT_CPACK_PACKAGE_MAINTAINER_EMAIL "eduard_kalinowski@yahoo.de" )
SET( HTTRAQT_CPACK_PACKAGE_DESCRIPTION "HTTraQt is the website copier for offline browsing" )
SET( HTTRAQT_CPACK_PACKAGE_DESCRIPTION_SUMMARY "HTTraQt network tool" )
# SET( PACKAGE_DEPENDS ${hugr_dependencies} )


# SET( HTTRAQT_CPACK_PACKAGE_DEPENDS "${HTTRAQT_CPACK_PACKAGE_SHLIBDEPS}" )

#SET( HTTRAQT_CPACK_PACKAGE_DEPENDS "libhttrack2, libqtcore4, libqtgui4, libc6, libstdc++6" )
SET( HTTRAQT_CPACK_PACKAGE_DEPENDS "libhttrack2, ${HTTRAQT_CPACK_PACKAGE_DEPENDS}" )
# SET( PACKAGE_DEPENDS "libc6 (>= 2.1.3), libhttrack (>= 3.42.1), libqtcore4 (>= 4:4.6.1), libqtgui4 (>= 4:4.5.3), libstdc++6 (>= 4.1.1)" )


SET( HTTRAQT_CPACK_PACKAGE_GROUP "Groupe" )
SET( HTTRAQT_CPACK_PACKAGE_LICENSE "GPL3" )

# ADD_CUSTOM_TARGET(changelog
# 	COMMAND ${GITCOMMAND} log > ${HTTRAQT_BINARY_DIR}/ChangeLog
# 	WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
# 	)

# Setup convenience targets for tagging and branching
# SET( HTTRAQT_VERSION_TAG "httraqt-${HTTRAQT_MAJOR_VERSION}.${HTTRAQT_MINOR_VERSION}.${HTTRAQT_RELEASE_VERSION}.${HTTRAQT_BUILD_VERSION}" )
# SET( HTTRAQT_VERSION_TAG "httraqt-${HTTRAQT_VERSION}" )
# ADD_CUSTOM_TARGET(tag-version
# 	COMMAND ${GITCOMMAND} tag ${HTTRAQT_VERSION_TAG}
# 	WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
# 	)

#SET( HTTRAQT_BRANCH_TAG "httraqt-release-${HTTRAQT_MAJOR_VERSION}.${HTTRAQT_MINOR_VERSION}" )
#ADD_CUSTOM_TARGET(tag-branch
#	COMMAND ${SVNCOMMAND} cp ${HTTRAQT_SVN_TRUNK}
#	${HTTRAQT_SVN_BRANCHES}/${HTTRAQT_BRANCH_TAG} -m "COMP: Branched HTTraQt Version ${HTTRAQT_MAJOR_VERSION}.${HTTRAQT_MINOR_VERSION}"
#	WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
#	)
# MESSAGE("CMAKE_CURRENT_SOURCE_DIR distr ${CMAKE_CURRENT_SOURCE_DIR} : ${PROJECT_SOURCE_DIR}")
# Get a SourceForge username so we can upload distributables to the FRS
IF(WIN32)
	SET( HTTRAQT_SOURCEFORGE_USERNAME "$ENV{USERNAME}" CACHE STRING "SourceForge user account name, for uploading distribution files." )
ELSE(WIN32)
	SET( HTTRAQT_SOURCEFORGE_USERNAME "$ENV{USER}" CACHE STRING "SourceForge user account name, for uploading distribution files." )
ENDIF(WIN32)
MARK_AS_ADVANCED(HTTRAQT_SOURCEFORGE_USERNAME)



# Setup some macros that can be used by the platform-specific distribution logic
MACRO(HTTRAQT_CHECK_INSTALLED_VERSION FOUND PACKAGE EXPECTED)
	IF(NOT ${FOUND} STREQUAL ${EXPECTED})
		MESSAGE(SEND_ERROR "Found ${PACKAGE} version ${FOUND} - for installation, version ${EXPECTED} is required." )
	ENDIF(NOT ${FOUND} STREQUAL ${EXPECTED})
ENDMACRO(HTTRAQT_CHECK_INSTALLED_VERSION)



# Generate source packages
# ADD_SUBDIRECTORY(source)
INCLUDE(CPack)

# Generate platform-specific binary packages
IF(APPLE)
	ADD_SUBDIRECTORY(osx)
ENDIF(APPLE)

IF(UNIX AND NOT APPLE)
	ADD_SUBDIRECTORY(posix)
ENDIF(UNIX AND NOT APPLE)

IF(WIN32)
	ADD_SUBDIRECTORY(win32)
ENDIF(WIN32)

