if get_option('build_vk')
  vma_proj = subproject('vulkan-memory-allocator', default_options: ['warning_level=0', 'werror=false'])
  vma_dep = vma_proj.get_variable('vma_allocator_dep')

  vk_inc_proj = subproject('vulkan-headers')
  vk_inc_dep = vk_inc_proj.get_variable('vulkan_headers_dep')

  platform_defs = []
  if get_option('use_xlib')
    platform_defs = ['-DVK_USE_PLATFORM_XLIB_KHR']
  elif host_machine.system() == 'windows'
    platform_defs = ['-DVK_USE_PLATFORM_WIN32_KHR']
  endif

  vk_renderer_lib = library('rtvk',
    'bindless_registry.h',
    'device.h',
    'physical_resource_manager.h',

    'bindless_registry.c',
    'device.c',
    'init.c',
    'physical_resource_manager.c',
    'swapchain.c',
    'vma_impl.cpp',

    '../../../contrib/volk/volk.c',
    '../../../contrib/volk/volk.h',
    dependencies: [m_dep, vk_inc_dep, vma_dep, thread_dep],
    include_directories: [engine_incdir, contrib_incdir],
    link_with: [runtime_lib],
    c_pch: 'pch/vk_pch.h',
    c_args: platform_defs,
    install: true)

  engine_libs += vk_renderer_lib
  engine_lib_paths += vk_renderer_lib.full_path()
endif

