INCLUDE(NewExecutable)

FUNCTION(OPENMEEG_TEST TEST_NAME)
    PARSE_ARGUMENTS("DEPENDS" "" "DEFAULT" ${ARGN})
    ADD_TEST(${TEST_NAME} ${DEFAULT})
    FOREACH (DEPENDENCY ${DEPENDS})
        SET_PROPERTY(TEST ${TEST_NAME} APPEND PROPERTY DEPENDS ${DEPENDENCY})
    ENDFOREACH()
ENDFUNCTION()

FUNCTION(OPENMEEG_UNIT_TEST TEST_NAME)
    PARSE_ARGUMENTS("SOURCES;LIBRARIES;PARAMETERS;DEPENDS" "" "DEFAULT" ${ARGN})
    NEW_EXECUTABLE(${TEST_NAME} SOURCES ${SOURCES} LIBRARIES ${LIBRARIES})
    #NEW_EXECUTABLE(${TEST_NAME} ${ARGN} EXCLUDE_FROM_ALL)
    #ADD_DEPENDENCIES(TARGET test ${TEST_NAME})
    IF (WIN32)
        SET(TEST_PATH ${EXECUTABLE_OUTPUT_PATH})
    ELSE()
        SET(TEST_PATH ${CMAKE_CURRENT_BINARY_DIR})
    ENDIF()
    IF (DEPENDS)
        SET(DEPENDS DEPENDS ${DEPENDS})
    ENDIF()
    OPENMEEG_TEST(${TEST_NAME} ${TEST_PATH}/${TEST_NAME} ${PARAMETERS} ${DEPENDS})
ENDFUNCTION()
