set(CTEST_BUILD_NAME "$ENV{CTEST_BUILD_NAME}")

set(CTEST_SOURCE_DIRECTORY $ENV{YAKL_CTEST_SRC})
set(CTEST_BINARY_DIRECTORY $ENV{YAKL_CTEST_BIN})
set(CTEST_NIGHTLY_START_TIME "18:00:00 EST")
set(CTEST_CMAKE_GENERATOR "Unix Makefiles")
set(CTEST_COVERAGE_COMMAND "gcov")
set(CTEST_MEMORYCHECK_COMMAND "/usr/bin/valgrind")

SET(CTEST_DROP_METHOD "http")
set(CTEST_SITE "thatchroof")
SET(CTEST_DROP_LOCATION "my.cdash.org/submit.php?project=YAKL")
SET(CTEST_DROP_SITE_CDASH TRUE)

set(CTEST_OPTIONS "-DYAKL_ARCH='$ENV{CTEST_YAKL_ARCH}'")
set(CTEST_OPTIONS "${CTEST_OPTIONS};-DYAKL_CXX_FLAGS='$ENV{CTEST_CXX_FLAGS}'")
set(CTEST_OPTIONS "${CTEST_OPTIONS};-DYAKL_CUDA_FLAGS='$ENV{CTEST_CUDA_FLAGS}'")
set(CTEST_OPTIONS "${CTEST_OPTIONS};-DYAKL_HIP_FLAGS='$ENV{CTEST_HIP_FLAGS}'")
set(CTEST_OPTIONS "${CTEST_OPTIONS};-DYAKL_OPENMP_FLAGS='$ENV{CTEST_OPENMP_FLAGS}'")
set(CTEST_OPTIONS "${CTEST_OPTIONS};-DYAKL_OPENMP45_FLAGS='$ENV{CTEST_OPENMP45_FLAGS}'")
set(CTEST_OPTIONS "${CTEST_OPTIONS};-DYAKL_SYCL_FLAGS='$ENV{CTEST_SYCL_FLAGS}'")
set(CTEST_OPTIONS "${CTEST_OPTIONS};-DYAKL_C_FLAGS='$ENV{CTEST_C_FLAGS}'")
set(CTEST_OPTIONS "${CTEST_OPTIONS};-DYAKL_F90_FLAGS='$ENV{CTEST_F90_FLAGS}'")
set(CTEST_OPTIONS "${CTEST_OPTIONS};-DCMAKE_EXE_LINKER_FLAGS='$ENV{CTEST_LD_FLAGS}'")

ctest_start("Nightly")
ctest_configure(BUILD ${CTEST_BINARY_DIRECTORY} SOURCE ${CTEST_SOURCE_DIRECTORY}/unit OPTIONS "${CTEST_OPTIONS}")
ctest_build()
ctest_test()
if ( "$ENV{CTEST_GCOV}" STREQUAL "1" )
  ctest_coverage()
endif()
if ( "$ENV{CTEST_VALGRIND}" STREQUAL "1" )
  ctest_memcheck()
endif()
ctest_submit()

