## general purpose nightly testing script for SeqAn
## call this using
## e.g. ctest -S ../Nightly.cmake -VV > ../CTEST_release.log
## TODO
##   * add initial checkout
##   * maybe we should read arguments from cmd line to be more generic

CMAKE_MINIMUM_REQUIRED (VERSION 2.6)

# ------------------------------------------------------------
# Set Variables
# ------------------------------------------------------------
# General CTest settings.
SET (CTEST_TIMEOUT "7200")
SET ($ENV{LC_MESSAGES} "en_EN")

# Variables describing the build.
SET (CTEST_SITE       "<SITE NAME>")
SET (CTEST_BUILD_NAME "<BUILD NAME>")

# Increase reported warning and error count.
SET (CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS 1000000)
SET (CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 1000000)

# Variables describing the build environments.
SET (CTEST_DIRECTORY "$ENV{HOME}/Nightly")
SET (CTEST_SOURCE_ROOT_DIRECTORY "${CTEST_DIRECTORY}/seqan-trunk")
SET (CTEST_SOURCE_DIRECTORY "${CTEST_SOURCE_ROOT_DIRECTORY}/projects/library/cmake")
SET (CTEST_BINARY_DIRECTORY "${CTEST_DIRECTORY}/seqan-build-${CTEST_BUILD_NAME}/projects/library/cmake")
SET (CTEST_BINARY_TEST_DIRECTORY "${CTEST_BINARY_DIRECTORY}/tests")

# General ctest/cmake/other programs.
SET (CTEST_CMAKE_COMMAND   "cmake")
FIND_PROGRAM (CTEST_SVN_COMMAND NAMES svn)
SET (CTEST_CHECKOUT_COMMAND "${CTEST_SVN_COMMAND} co http://svn.mi.fu-berlin.de/seqan/trunk/seqan ${CTEST_SOURCE_ROOT_DIRECTORY}")
SET (CTEST_UPDATE_COMMAND "${CTEST_SVN_COMMAND}")

# Define generator.
SET (CTEST_CMAKE_GENERATOR "Unix Makefiles")

# Clear the binary directory to avoid problems.
CTEST_EMPTY_BINARY_DIRECTORY (${CTEST_BINARY_DIRECTORY})

## this is the initial cache to use for the binary tree, be careful to escape
## any quotes inside of this string if you use it
FILE(WRITE "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt" "
CMAKE_GENERATOR:INTERNAL=${CTEST_CMAKE_GENERATOR}
")

# Set the default model to Nightly.
IF (MODEL)
ELSE (MODEL)
  SET(MODEL "Nightly")
ENDIF (MODEL)

# ------------------------------------------------------------
# Perform the dashboard/testings steps.
# ------------------------------------------------------------
CTEST_START     (${MODEL} ${CTEST_SOURCE_DIRECTORY})
CONFIGURE_FILE  (${CTEST_SOURCE_DIRECTORY}/CTestConfig.cmake ${CTEST_SOURCE_ROOT_DIRECTORY}/CTestConfig.cmake COPYONLY)
CTEST_UPDATE    (SOURCE "${CTEST_SOURCE_ROOT_DIRECTORY}")
CTEST_CONFIGURE (BUILD "${CTEST_BINARY_DIRECTORY}")
CTEST_BUILD     (BUILD "${CTEST_BINARY_DIRECTORY}")
#SET (CTEST_PROJECT_NAME "SeqAn_tests")
#CTEST_BUILD     (BUILD "${CTEST_BINARY_TEST_DIRECTORY}")
SET (CTEST_PROJECT_NAME "SeqAn")
CTEST_TEST      (BUILD "${CTEST_BINARY_TEST_DIRECTORY}")
CTEST_SUBMIT    ()
