option(PSEMEK_BUILD_TESTS "Build tests" OFF)

cmake_policy(SET CMP0079 NEW)

if(PSEMEK_BUILD_TESTS)

	add_executable(psemek-run-tests source/main.cpp include/psemek/test/test.hpp)
	set(PSEMEK_TESTS_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
	target_include_directories(psemek-run-tests PUBLIC "${PSEMEK_TESTS_INCLUDE_DIR}")
	target_link_libraries(psemek-run-tests PUBLIC psemek-log)
	target_compile_options(psemek-run-tests PUBLIC -Wno-restrict)

	function(psemek_glob_tests lib dir)
		file(GLOB_RECURSE _PSEMEK_ADD_TESTS_SOURCES "${dir}/*.cpp")
		list(LENGTH _PSEMEK_ADD_TESTS_SOURCES _PSEMEK_ADD_TESTS_SOURCES_LENGTH)
		if(_PSEMEK_ADD_TESTS_SOURCES_LENGTH EQUAL 0)
			message(WARNING "No tests found in ${dir}")
		else()
			target_sources(psemek-run-tests PUBLIC ${_PSEMEK_ADD_TESTS_SOURCES})
			target_link_libraries(psemek-run-tests PUBLIC ${lib})
		endif()
	endfunction()

else()

	function(psemek_add_test source)
	endfunction()

	function(psemek_glob_tests dir)
	endfunction()

endif()
