find_package(ZLIB REQUIRED)

file(GLOB PSEMEK_EXAMPLES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")

find_package(OpenMP)

foreach(example ${PSEMEK_EXAMPLES})
	get_filename_component(TARGET_NAME "${example}" NAME_WLE)
	set(TARGET_NAME psemek-example-${TARGET_NAME})
	psemek_add_application(${TARGET_NAME} ${example})
	if(TARGET ${TARGET_NAME})
		target_link_libraries(${TARGET_NAME} PUBLIC psemek ZLIB::ZLIB)
		if(OpenMP_CXX_FOUND)
			target_link_libraries(${TARGET_NAME} PUBLIC OpenMP::OpenMP_CXX)
		endif()
		target_compile_definitions(${TARGET_NAME} PUBLIC -DPSEMEK_EXAMPLES_DIR="${CMAKE_CURRENT_SOURCE_DIR}")
	endif()
endforeach()
