PROJECT ( fysxasteroids C CXX )

CMAKE_MINIMUM_REQUIRED(VERSION 2.6)

LIST( APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMake )

# Perform the proper linking
SET (CMAKE_SKIP_BUILD_RPATH FALSE)
SET (CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
SET (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
SET (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

FIND_PACKAGE (SDL REQUIRED)
FIND_PACKAGE (SDL_net REQUIRED)

INCLUDE_DIRECTORIES ( 
	engine/
	asteroids/
	include/
	engine/libraries/mathlib/
	engine/libraries/coll2d/include
	engine/libraries/oglft/liboglft
	${FREETYPE2_INCLUDE_DIR}
	)

ADD_SUBDIRECTORY ( engine )

SET ( ASTEROIDS_SOURCES 
	asteroids/AsteroidEntity.cc
	asteroids/Controller.cc
	asteroids/ControllerCommands.cc
	asteroids/EntityFactory.cc
	asteroids/EnumToString.cc
	asteroids/Game.cc
	asteroids/main.cc
	asteroids/Model.cc
	asteroids/ModelCommands.cc
	asteroids/Physics.cc
	asteroids/RocketEntity.cc
	asteroids/ShipEntity.cc
	asteroids/View.cc
	)

SET ( ASTEROIDSEDITOR_SOURCES 
	asteroids/AsteroidEntity.cc
	asteroids/Controller.cc
	asteroids/ControllerCommands.cc
	asteroids/EntityFactory.cc
	asteroids/EnumToString.cc
	asteroids/Game.cc
	asteroids/editormain.cc
	asteroids/Model.cc
	asteroids/ModelCommands.cc
	asteroids/Physics.cc
	asteroids/RocketEntity.cc
	asteroids/ShipEntity.cc
	asteroids/View.cc
	)

INCLUDE_DIRECTORIES (
	${SDLMIXER_INCLUDE_DIRS}
	${SDLNET_INCLUDE_DIRS}
	)

ADD_EXECUTABLE ( fysxasteroids ${ASTEROIDS_SOURCES} ) 
ADD_EXECUTABLE ( fysxasteroidseditor ${ASTEROIDSEDITOR_SOURCES} ) 

TARGET_LINK_LIBRARIES ( fysxasteroids
	Engine
	oglft
	)

TARGET_LINK_LIBRARIES ( fysxasteroidseditor
	Engine
	oglft
	)

SET ( DATA_DIR
	data/
	)

SET ( DATA_FILES
	asteroids.rc
	config.rc
	)

INSTALL (TARGETS fysxasteroids
	RUNTIME DESTINATION bin
	LIBRARY DESTINATION lib
	)

INSTALL (TARGETS fysxasteroidseditor
	RUNTIME DESTINATION bin
	LIBRARY DESTINATION lib
	)

INSTALL (DIRECTORY ${DATA_DIR}
	DESTINATION share/fysxasteroids/data
	)

INSTALL (FILES ${DATA_FILES}
	DESTINATION share/fysxasteroids
	)

INSTALL (FILES fysxasteroids.desktop fysxasteroidseditor.desktop
	DESTINATION /usr/share/applications
	)

# CPack specific stuff
# INCLUDE(InstallRequiredSystemLibraries)

SET(CPACK_PACKAGE_NAME "fysxasteroids")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A fun and good looking clone of the popular 80's game")
SET(CPACK_PACKAGE_VENDOR "Martin Felis <martin@fysx.org>")
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.txt")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.txt")
SET(CPACK_PACKAGE_VERSION_MAJOR "0")
SET(CPACK_PACKAGE_VERSION_MINOR "9")
SET(CPACK_PACKAGE_VERSION_PATCH "1")
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}")
SET(CPACK_PACKAGE_CONTACT "Martin Felis <martin@fysx.org>")

IF(WIN32 AND NOT UNIX)
  # There is a bug in NSI that does not handle full unix paths properly. Make
  # sure there is at least one set of four (4) backlasshes.
  SET(CPACK_PACKAGE_ICON "${CMake_SOURCE_DIR}/Utilities/Release\\\\InstallIcon.bmp")
  SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\fysxasteroids.exe")
  SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} fysxdotorg")
  SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\www.fysx.org")
  SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.fysx.org")
  SET(CPACK_NSIS_CONTACT "martin@fysx.org")
  SET(CPACK_NSIS_MODIFY_PATH ON)
ELSE(WIN32 AND NOT UNIX)
	# Debian stuff
	SET(CPACK_GENERATOR "DEB")
	SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Martin Felis <martin@fysx.org>")
  SET(CPACK_STRIP_FILES "bin/fysxasteroids" "bin/fysxasteroidseditor")
  SET(CPACK_SOURCE_STRIP_FILES "TRUE")
  SET(CPACK_DEBIAN_PACKAGE_SECTION "Games and Amusement")

	SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libboost-filesystem1.40.0 (>= 1.40.0-1), libboost-system1.40.0 (>= 1.40.0-1), libc6 (>= 2.4), libfreetype6 (>= 2.2.1), libgcc1 (>= 1:4.1.1), libglu1-mesa | libglu1, libice6 (>= 1:1.0.0), libpng12-0 (>= 1.2.13-4), libsdl-net1.2 (>= 1.2.7), libsdl-mixer1.2 (>= 1.2.6), libsdl1.2debian (>= 1.2.10-1), libsm6, libstdc++6 (>= 4.4.0), libx11-6, libxext6, zlib1g (>= 1:1.1.4)")

ENDIF(WIN32 AND NOT UNIX)
SET(CPACK_PACKAGE_EXECUTABLES "fysxasteroids" "fysxasteroidseditor")

INCLUDE ( CPack )
