#http://www.cmake.org/Wiki/CMake:Packaging_With_CPack
cmake_minimum_required(VERSION 2.6)
PROJECT(populations CXX C)

#cpack -G TGZ --config CPackSourceConfig.cmake
# cpack -G TGZ --config CPackSourceConfig.cmake


#.dput.cf
#[olivier-langella]
#fqdn = ppa.launchpad.net
#method = ftp
#incoming = ~olivier-langella/ppa/ubuntu/
#login = olivier-langella
#allow_unsigned_uploads = 0
#
#  debuild -S -sa
# dput -f olivier-langella *changes




message ("compiler : ${CMAKE_BASE_NAME}")


# cross compilation Win32 :
#cd build_win32
#export CC=/usr/bin/i586-mingw32msvc-gcc
#export CXX=/usr/bin/i586-mingw32msvc-g++
#INCLUDE(${populations_SOURCE_DIR}/win32/Toolchain-mingw32.cmake)
#cmake -DCMAKE_TOOLCHAIN_FILE=../win32/Toolchain-mingw32.cmake ..

#IF (MINGW32)
#	ADD_DEFINITIONS(-DCOMPILATION_MINGW32)
#	MESSAGE(coucou)
#	SET( CMAKE_BUILD_TYPE "Debug")
#	SET(CMAKE_CXX_FLAGS_DEBUG "-g")
#ELSE (MINGW32)
#	SET( CMAKE_BUILD_TYPE "Release")
#ENDIF(MINGW32)


IF ( CMAKE_BASE_NAME MATCHES "cl")
	message ("on est sous Windows")
	SET( CMAKE_BUILD_TYPE "Release")
	SET( WIN32 "windows")
ELSE (CMAKE_BASE_NAME MATCHES "cl")
	SET( CMAKE_BUILD_TYPE "Release")
	#SET( CMAKE_BUILD_TYPE "Debug")
ENDIF(CMAKE_BASE_NAME MATCHES "cl")

IF ( CMAKE_BUILD_TYPE MATCHES "Release")
	MESSAGE("compiling as release version")
	ADD_DEFINITIONS("-DQT_NO_DEBUG_OUTPUT")
ELSE ( CMAKE_BUILD_TYPE MATCHES "Release" )
	MESSAGE("compiling as debug version")
ENDIF( CMAKE_BUILD_TYPE MATCHES "Release" )


#CMAKE_CXX_FLAGS
#CMAKE_CXX_FLAGS_DEBUG           -g
#CMAKE_CXX_FLAGS_MINSIZEREL      -Os -DNDEBUG
#CMAKE_CXX_FLAGS_RELEASE         -O3 -DNDEBUG
#CMAKE_CXX_FLAGS_RELWITHDEBINFO  -O2 -g

SET (POPULATIONS_VERSION "1.2.33")

SET(CPACK_CMAKE_GENERATOR "Unix Makefiles")
SET(CPACK_GENERATOR "STGZ;TGZ;TZ")
#SET(CPACK_INSTALL_CMAKE_PROJECTS "/tmp;Populations;src;/src")
#SET(CPACK_NSIS_DISPLAY_NAME "CMake 2.5")
SET(CPACK_OUTPUT_CONFIG_FILE "./CPackConfig.cmake")
SET(CPACK_PACKAGE_DESCRIPTION_FILE ${populations_SOURCE_DIR}/COPYING)
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Populations is population genetic software")
SET(CPACK_PACKAGE_EXECUTABLES "populations")
SET(CPACK_PACKAGE_FILE_NAME "populations-${POPULATIONS_VERSION}-Linux-i686")
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "populations ${POPULATIONS_VERSION}")
SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "populations ${POPULATIONS_VERSION}")
SET(CPACK_PACKAGE_NAME "populations")
SET(CPACK_PACKAGE_VENDOR "CNRS")
SET(CPACK_PACKAGE_VERSION ${POPULATIONS_VERSION})
SET(CPACK_PACKAGE_VERSION_MAJOR "1")
SET(CPACK_PACKAGE_VERSION_MINOR "2")
SET(CPACK_PACKAGE_VERSION_PATCH "33")
SET(CPACK_RESOURCE_FILE_LICENSE ${populations_SOURCE_DIR}/COPYING)
SET(CPACK_RESOURCE_FILE_README ${populations_SOURCE_DIR}/README)
SET(CPACK_RESOURCE_FILE_WELCOME ${populations_SOURCE_DIR}/INSTALL)
SET(CPACK_RESOURCE_FILE_LICENSE ${populations_SOURCE_DIR}/ChangeLog)
SET(CPACK_SOURCE_GENERATOR "TGZ;TZ")
SET(CPACK_SOURCE_OUTPUT_CONFIG_FILE "./CPackSourceConfig.cmake")
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "populations-${POPULATIONS_VERSION}")
SET(CPACK_SOURCE_STRIP_FILES "")
SET(CPACK_STRIP_FILES "bin/populations")
SET(CPACK_SYSTEM_NAME "Linux-i686")
SET(CPACK_TOPLEVEL_TAG "Linux-i686")


SET(CPACK_SOURCE_IGNORE_FILES 
	"/devel_archives/"
	"/figures/"
	"/Soumis/"
	"Makefile"
	"install_manifest.txt"
	"cmake_install.cmake"
	"cmake_install.cmake"
	"CMakeCache.txt"
	"CPackConfig.cmake"
	"CPackSourceConfig.cmake"
	"install_manifest.txt"
	"/CMakeFiles/"
	"/_CPack_Packages/"
	"/Debug/"
	"/Release/"
	"/\\\\.externalToolBuilders/"
	"/\\\\.svn/"
	"/\\\\.settings/"
	"Makefile"
	"\\\\.cdtbuild"
	"\\\\.cdtproject"
	"\\\\.project"
	"/win32/"
)
# cpack -G TGZ --config CPackSourceConfig.cmake
# dpkg-buildpackage -rfakeroot
configure_file (${populations_SOURCE_DIR}/src/config.h.cmake ${populations_SOURCE_DIR}/src/config.h)

#SET(CPACK_SOURCE_IGNORE_FILES "/CMakeFiles/;/_CPack_Packages/;/templates/;/debug/;/Debug/;/Release/;/\\\\.svn/;/\\\\.settings/;Makefile;\\\\.cdtbuild;\\\\.cdtproject;\\\\.project")
# cpack -G TGZ --config CPackSourceConfig.cmake
SET(CPACK_PACKAGE_EXECUTABLES "populations" "populations")


SET(CPACK_STRIP_FILES "src/populations")



# for debian package :
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Olivier Langella <olivier.langella@moulon.inra.fr>")
SET(DEBIAN_PACKAGE_BUILDS_DEPENDS "Olivier Langella <olivier.langella@moulon.inra.fr>")
 


INCLUDE(CPack)

# The name of our project is "HELLO".  CMakeLists files in this project can
# refer to the root source directory of the project as ${HELLO_SOURCE_DIR} and
# to the root binary directory of the project as ${HELLO_BINARY_DIR}.
project (populations)

# Recurse into the "Hello" and "Demo" subdirectories.  This does not actually
# cause another cmake executable to run.  The same process will walk through
# the project's entire directory structure.
add_subdirectory (src)
if (NOT CMAKE_INSTALL_PREFIX)
	SET (CMAKE_INSTALL_PREFIX /usr/local)
endif (NOT CMAKE_INSTALL_PREFIX)
INSTALL(PROGRAMS src/populations DESTINATION bin)
#INSTALL(DIRECTORY doc/man1 DESTINATION share/man/man1)
#INSTALL(FILES doc/man1/beads.1 DESTINATION share/man/man1)
