cmake_minimum_required(VERSION 3.0)

function(createTest)
	set(options)
  	set(oneValueArgs NAME SOURCE LOCATION)
  	set(multiValueArgs LIBS)
  	cmake_parse_arguments(TEST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
	message("Creating test: ${TEST_NAME}")
	set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests/${APP_TARGET})
	file(GLOB ${TEST_NAME}_files ${TEST_SOURCE}/*.cpp)
	add_executable(${TEST_NAME} ${${TEST_NAME}_files})
	target_link_libraries(${TEST_NAME} ${TEST_LIBS})
	catch_discover_tests(${TEST_NAME})
	set_target_properties (${TEST_NAME} PROPERTIES FOLDER ${TEST_LOCATION})
endFunction(createTest)