dependencies = [
    dependency('gtk4', required : true),
    dependency('libadwaita-1', required : true),
    dependency('gio-2.0', required : true), 
    dependency('gee-0.8', required : true),
    dependency('gio-unix-2.0', required : true),
    dependency('libsecret-1', required : true),
]

gnome = import('gnome')
kp_prefix = get_option('prefix')
datadir = join_paths(kp_prefix, get_option('datadir'))
resources = gnome.compile_resources(
    'kordophone-resources',
    'resources/kordophone.gresource.xml',
    source_dir: 'resources'
)

# Icons
app_icon_dirs = [
  '16x16',
  '24x24',
  '32x32',
  '48x48',
  '256x256',
  '512x512',
]

build_tools_dir = meson.source_root() / 'build-aux'

image_magick = find_program('convert', required : true)
resizer = find_program(build_tools_dir / 'resize.py')
icons = custom_target('icons', 
    output: 'hicolor',
    input: 'resources/net.buzzert.kordophone.png',
    command: [resizer, image_magick, '@INPUT@', '@OUTPUT@'],
    install: true,
    install_dir: join_paths(datadir, 'icons'),
)

# Full res icon for Desktop Entry
install_data('resources/net.buzzert.kordophone.png',
    install_dir: join_paths(datadir, 'icons'),
)

# Desktop
install_data('resources/net.buzzert.kordophone.desktop',
    install_dir: join_paths(datadir, 'applications')
)

sources = [
    'application/kordophone-application.vala',
    'application/main-window.vala',
    'application/preferences-window.vala',

    'service/interface/dbusservice.vala',
    'service/dbus-service-base.vala',
    'service/repository.vala',
    'service/settings.vala',

    'conversation-list/conversation-list-view.vala',
    'conversation-list/conversation-list-model.vala',
    'conversation-list/conversation-row.vala',

    'transcript/attachment-preview.vala',
    'transcript/message-list-model.vala',
    'transcript/transcript-container-view.vala',
    'transcript/transcript-drawing-area.vala',
    'transcript/transcript-view.vala',

    'transcript/layouts/bubble-layout.vala',
    'transcript/layouts/chat-item-layout.vala',
    'transcript/layouts/date-item-layout.vala',
    'transcript/layouts/image-bubble-layout.vala',
    'transcript/layouts/sender-annotation-layout.vala',
    'transcript/layouts/text-bubble-layout.vala',

    'models/attachment.vala',
    'models/conversation.vala',
    'models/message.vala',
]

executable('kordophone',
    sources,
    resources,
    icons,
    dependencies : dependencies,
    vala_args: ['--pkg', 'posix'],
    link_args: ['-lm'],
    install : true
)
