link_libraries (
	piglitutil_${piglit_target_api}
	${OPENGL_gl_LIBRARY}
)

piglit_add_executable (ext_external_objects-memory-object-api-errors
		       memory-object-api-errors.c)
piglit_add_executable (ext_external_objects-semaphore-api-errors
		       semaphore-api-errors.c)

IF(PIGLIT_BUILD_VK_TESTS)
	set(VK_BANDS_VERT vk_bands.vert.spv)
	set(VK_BANDS_FRAG vk_bands.frag.spv)
	set(VK_BANDS_VERT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/${VK_BANDS_VERT})
	set(VK_BANDS_FRAG_PATH ${CMAKE_CURRENT_SOURCE_DIR}/${VK_BANDS_FRAG})

	add_definitions(-DVK_BANDS_VERT="${VK_BANDS_VERT}")
	add_definitions(-DVK_BANDS_FRAG="${VK_BANDS_FRAG}")

	set(VK_BANDS_REVERSE_FRAG vk_bands_reverse_frag.spv)
	set(VK_BANDS_REVERSE_FRAG_PATH ${CMAKE_CURRENT_SOURCE_DIR}/${VK_BANDS_REVERSE_FRAG})
	add_definitions(-DVK_BANDS_REVERSE_FRAG="${VK_BANDS_REVERSE_FRAG}")

	set(VK_BLUE_VERT vk_blue.vert.spv)
	set(VK_BLUE_FRAG vk_blue.frag.spv)
	set(VK_BLUE_VERT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/${VK_BLUE_VERT})
	set(VK_BLUE_FRAG_PATH ${CMAKE_CURRENT_SOURCE_DIR}/${VK_BLUE_FRAG})

	add_definitions(-DVK_BLUE_VERT="${VK_BLUE_VERT}")
	add_definitions(-DVK_BLUE_FRAG="${VK_BLUE_FRAG}")

	set(VK_PING_PONG_COMP vk_blue.comp.spv)
	set(VK_PING_PONG_COMP_PATH ${CMAKE_CURRENT_SOURCE_DIR}/${VK_PING_PONG_COMP})

	add_definitions(-DVK_PING_PONG_COMP="${VK_PING_PONG_COMP}")

	set(VK_ZQUAD_VERT vk_zquad.vert.spv)
	set(VK_ZQUAD_FRAG vk_zquad.frag.spv)
	set(VK_ZQUAD_VERT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/${VK_ZQUAD_VERT})
	set(VK_ZQUAD_FRAG_PATH ${CMAKE_CURRENT_SOURCE_DIR}/${VK_ZQUAD_FRAG})

	add_definitions(-DVK_ZQUAD_VERT="${VK_ZQUAD_VERT}")
	add_definitions(-DVK_ZQUAD_FRAG="${VK_ZQUAD_FRAG}")

	add_custom_command(
		OUTPUT ${VK_BANDS_VERT_PATH}
		COMMAND ${GLSLANG_VALIDATOR} -V ${CMAKE_CURRENT_SOURCE_DIR}/vk_bands.vert -o ${VK_BANDS_VERT_PATH}
		DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/vk_bands.vert
	)

	add_custom_command(
		OUTPUT ${VK_BANDS_FRAG_PATH}
		COMMAND ${GLSLANG_VALIDATOR} -V ${CMAKE_CURRENT_SOURCE_DIR}/vk_bands.frag -o ${VK_BANDS_FRAG_PATH}
		DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/vk_bands.frag
	)

	add_custom_command(
		OUTPUT ${VK_BANDS_REVERSE_FRAG_PATH}
		COMMAND ${GLSLANG_VALIDATOR} -V ${CMAKE_CURRENT_SOURCE_DIR}/vk_bands_reverse.frag -o ${VK_BANDS_REVERSE_FRAG_PATH}
		DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/vk_bands_reverse.frag
	)

	add_custom_command(
		OUTPUT ${VK_BLUE_VERT_PATH}
		COMMAND ${GLSLANG_VALIDATOR} -V ${CMAKE_CURRENT_SOURCE_DIR}/vk_blue.vert -o ${VK_BLUE_VERT_PATH}
		DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/vk_blue.vert
	)

	add_custom_command(
		OUTPUT ${VK_BLUE_FRAG_PATH}
		COMMAND ${GLSLANG_VALIDATOR} -V ${CMAKE_CURRENT_SOURCE_DIR}/vk_blue.frag -o ${VK_BLUE_FRAG_PATH}
		DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/vk_blue.frag
	)

	add_custom_command(
		OUTPUT ${VK_PING_PONG_COMP_PATH}
		COMMAND ${GLSLANG_VALIDATOR} -V ${CMAKE_CURRENT_SOURCE_DIR}/vk_ping_pong.comp -o ${VK_PING_PONG_COMP_PATH}
		DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/vk_ping_pong.comp
	)

	add_custom_command(
		OUTPUT ${VK_ZQUAD_VERT_PATH}
		COMMAND ${GLSLANG_VALIDATOR} -V ${CMAKE_CURRENT_SOURCE_DIR}/vk_zquad.vert -o ${VK_ZQUAD_VERT_PATH}
		DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/vk_zquad.vert
	)

	add_custom_command(
		OUTPUT ${VK_ZQUAD_FRAG_PATH}
		COMMAND ${GLSLANG_VALIDATOR} -V ${CMAKE_CURRENT_SOURCE_DIR}/vk_zquad.frag -o ${VK_ZQUAD_FRAG_PATH}
		DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/vk_zquad.frag
	)

	include_directories(
		${GLEXT_INCLUDE_DIR}
		${LIBVULKAN_INCLUDE_DIRS}
		${OPENGL_INCLUDE_PATH}
	)

	link_libraries (
		piglitutil_${piglit_target_api}
		${OPENGL_gl_LIBRARY}
		${LIBVULKAN_LDFLAGS}
	)

	piglit_add_executable (ext_external_objects-vk-image-overwrite
		vk.c interop.c helpers.c vk_image_overwrite.c)
	piglit_add_executable (ext_external_objects-vk-image-display
		vk.c interop.c helpers.c vk_image_display.c ${VK_BANDS_VERT_PATH} ${VK_BANDS_FRAG_PATH})
	piglit_add_executable (ext_external_objects-vk-image-display-overwrite
		vk.c interop.c helpers.c vk_image_display_overwrite.c ${VK_BANDS_VERT_PATH} ${VK_BANDS_FRAG_PATH})
	piglit_add_executable (ext_external_objects-vk-buf-exchange
		vk.c interop.c helpers.c vk_buf_exchange.c ${VK_BANDS_VERT_PATH} ${VK_BANDS_FRAG_PATH})
	piglit_add_executable (ext_external_objects-vk-pix-buf-update-errors
		vk.c interop.c helpers.c vk_pix_buf_update_errors.c ${VK_BANDS_VERT_PATH} ${VK_BANDS_FRAG_PATH} ${VK_BANDS_REVERSE_FRAG_PATH})
	piglit_add_executable (ext_external_objects-vk-ping-pong
		vk.c interop.c helpers.c vk_ping_pong.c ${VK_PING_PONG_COMP_PATH})
	piglit_add_executable (ext_external_objects-vk-vert-buf-update-errors
		vk.c interop.c helpers.c vk_vert_buf_update_errors.c)
	piglit_add_executable (ext_external_objects-vk-vert-buf-reuse
		vk.c interop.c helpers.c vk_vert_buf_reuse.c ${VK_BLUE_VERT_PATH} ${VK_BLUE_FRAG_PATH})
	piglit_add_executable (ext_external_objects-vk-depth-display
		vk.c interop.c helpers.c vk_depth_display.c ${VK_ZQUAD_VERT_PATH} ${VK_ZQUAD_FRAG_PATH})
	piglit_add_executable (ext_external_objects-vk-semaphores
		vk.c interop.c helpers.c vk_semaphores.c ${VK_BANDS_VERT_PATH} ${VK_BANDS_FRAG_PATH})
	piglit_add_executable (ext_external_objects-vk-semaphores-2
		vk.c interop.c helpers.c vk_semaphores2.c ${VK_BANDS_VERT_PATH} ${VK_BANDS_FRAG_PATH})
	piglit_add_executable (ext_external_objects-vk-stencil-display
		vk.c interop.c helpers.c vk_stencil_display.c ${VK_ZQUAD_VERT_PATH} ${VK_ZQUAD_FRAG_PATH})
	piglit_add_executable (ext_external_objects-vk-image-display-multiple-textures
		vk.c interop.c helpers.c vk_image_display_multiple_textures.c ${VK_BANDS_VERT_PATH} ${VK_BANDS_FRAG_PATH})
ENDIF()

# vim: ft=cmake:
