#
# Synergy+ CPack config
#
# List of CPack variables:
# http://www.vtk.org/Wiki/CMake:CPackConfiguration
#

# CPack files common to all platforms.
SET(cpack_targets synergys synergyc)

IF(WIN32)
	# Windows has an extra GUI and DLL.
	LIST(APPEND cpack_targets launcher synrgyhk)
ENDIF(WIN32)

INSTALL(
	TARGETS ${cpack_targets}
	RUNTIME DESTINATION bin)

# The default CPack behaviour is not to append the system processor
# type, which is undesirable in our case, since we want to support 
# both 32-bit and 64-bit processors.
SET(CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR})

# Hack: When running CMake on 64-bit Windows 7, the value of 
# CMAKE_SYSTEM_PROCESSOR always seems to be x86, regardless of if the
# CMake build is 32-bit or 64-bit. As a work around, we will prefix either
# x86 or x64 (in the same style as Microsoft do with their installers).
# However, some confusion may be caused when the user sees that Synergy+
# is installed in the x86 Program Files directory (even though it's a 
# 64-bit build). This is caused by NSIS only supporting the 32-bit 
# installs structure (also uses 32-bit registry key locations).
IF(WIN32)
	IF(CMAKE_CL_64)
		SET(CPACK_SYSTEM_NAME Windows-x64)
	ELSE(CMAKE_CL_64)
		SET(CPACK_SYSTEM_NAME Windows-x86)
	ENDIF(CMAKE_CL_64)
ENDIF(WIN32)

# For source code, use .tar.gz on Unix, and .zip on Windows
IF(UNIX)
	SET(CPACK_SOURCE_GENERATOR TGZ)
ELSE(UNIX)
	SET(CPACK_SOURCE_GENERATOR ZIP)
ENDIF(UNIX)

SET(CPACK_PACKAGE_NAME "synergy-plus")
SET(CPACK_PACKAGE_VENDOR "The Synergy+ Project")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Installs Synergy+ server and client")
SET(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
SET(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
SET(CPACK_PACKAGE_VERSION_PATCH ${VERSION_REV})
SET(CPACK_PACKAGE_VERSION ${VERSION})
SET(CPACK_PACKAGE_CONTACT http://code.google.com/p/synergy-plus/)
SET(CPACK_RESOURCE_FILE_LICENSE "${cmake_dir}/License.rtf")
SET(CPACK_RESOURCE_FILE_README "${cmake_dir}/Readme.txt")

IF(WIN32)
	SET(WIN32_ICON "${root_dir}/cmd/launcher/synergy.ico")
	SET(CPACK_NSIS_MUI_ICON ${WIN32_ICON})
	SET(CPACK_NSIS_MUI_UNIICON ${WIN32_ICON})
	SET(CPACK_NSIS_INSTALLED_ICON_NAME launcher)
	SET(CPACK_PACKAGE_INSTALL_DIRECTORY "Synergy+")
	SET(CPACK_PACKAGE_EXECUTABLES launcher;Synergy+)
ENDIF(WIN32)

# For source package, leave out temp and Mercurial stuff.
SET(CPACK_SOURCE_IGNORE_FILES
	"/build/"		# Temp CMake build dir.
	"/bin/"			# Temp binary output dir.
	"/.hg/"			# Mercurial repo cache.
	"/.hgignore"	# Mercurial ignore list (not neede by end-user).
	".*~"			# Emacs temporary files.
	"/config.h"		# The config.h file should be generated.
)

# Must be last (since it relies of CPACK_ vars).
INCLUDE(CPack)
