cmake_minimum_required(VERSION 3.19)

project(asgard_testing VERSION @asgard_VERSION@ LANGUAGES CXX)
enable_testing()

message(STATUS "Testing the ASGarD installation ...")

find_package(asgard @asgard_VERSION@ PATHS "@__asgard_install_prefix@")

add_subdirectory("@__asgard_install_prefix@/share/asgard/examples" examples_cxx)

foreach (_example @_asgard_doc_pdes_str@)

    if ("${_example}" STREQUAL "continuity_2d" OR "${_example}" STREQUAL "inputs_1d")
        if ("${_example}" STREQUAL "continuity_2d")
            add_test (NAME ${_example}
                      COMMAND "${CMAKE_CURRENT_BINARY_DIR}/examples_cxx/${_example}"
                      WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
        else ()
            add_test (NAME ${_example}
                      COMMAND "${CMAKE_CURRENT_BINARY_DIR}/examples_cxx/${_example}" -if "examples_cxx/inputs_1d_1.txt"
                      WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
        endif()
    else()
        add_test(${_example}  "${CMAKE_CURRENT_BINARY_DIR}/examples_cxx/${_example}" -test)
    endif()

endforeach()

if ("@ASGARD_USE_CUDA@" OR "@ASGARD_USE_ROCM@")
    foreach (_example @_asgard_gpu_pdes_str@)
        add_test(${_example}  "${CMAKE_CURRENT_BINARY_DIR}/examples_cxx/${_example}" -test)
    endforeach()
endif()
