summaryrefslogtreecommitdiff
path: root/meson.build
blob: 499de0094a9b4b6b98be29eb100b3f35be2494ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
project('timer', 'cpp',
        version: '0.2',
        default_options: [
          'warning_level=3',
          'cpp_std=c++17',
          'cpp_rtti=false'
        ])

cpp_optional_flags = [
  '-fvisibility=hidden',
  # Redefining explicit to be able to include xkb.h
  '-Wno-keyword-macro',
]
cpp_flags = [
  '-DVERSION="' + meson.project_version() + '"'
]
if get_option('buildtype') == 'release'
  cpp_flags += '-DNDEBUG'
endif

cpp = meson.get_compiler('cpp')
cpp_flags += cpp.get_supported_arguments(cpp_optional_flags)
add_project_arguments(cpp_flags, language: 'cpp')

thread_dep = dependency('threads')

xcb_dep = [dependency('xcb', version: '>= 1.14'),
           dependency('xcb-xkb', version: '>= 1.14'),
           dependency('xcb-event', version: '>= 0.4.0'),
           dependency('xcb-icccm', version: '>= 0.4.1'),
           dependency('xcb-keysyms', version: '>= 0.4.0'),
           dependency('xkbcommon-x11', version: '>= 1.0.3')]

xcb_xrm_dep = dependency('xcb-xrm', version: '>= 1.0', required: false)

dbus_dep = dependency('sdbus-c++', version: '>= 0.8.3')

timer_sources =  [
  'src/args.cc',
  'src/io.cc',
  'src/timer.cc',
  'src/timer_state.cc',
  'src/unique_fd.cc',
  'src/xcb_atoms.cc',
  'src/xcb_colors.cc',
  'src/xcb_connection.cc',
  'src/xcb_resource.cc',
  'src/xcb_xkb.cc',
  'src/xdg.cc',
]

if xcb_xrm_dep.found()
  timer_sources += 'src/xcb_resources_xrm.cc'
else
  timer_sources += 'src/xcb_resources_none.cc'
endif

exe = executable('timer',
                 sources: timer_sources,
                 dependencies: [dbus_dep, thread_dep, xcb_dep, xcb_xrm_dep],
                 install: true)

xdg_desktop_menu = find_program('xdg-desktop-menu', required: false,
                                native: true)
if xdg_desktop_menu.found()
  meson.add_install_script(xdg_desktop_menu, 'install', '--novendor',
                           files('data/org.the_jk.timer.desktop'))
else
  desktop_path = get_option('datadir') / 'applications'

  install_data('data/org.the_jk.timer.desktop', install_dir : desktop_path)
endif

xdg_icon_resource = find_program('xdg-icon-resource', required: false,
                                 native: true)
if xdg_icon_resource.found()
  meson.add_install_script(xdg_icon_resource, 'install', '--novendor',
                           '--size', '128', files('data/org.the_jk.timer.png'))
else
  icon_path = get_option('datadir') / 'icons' / 'hicolor' / '128x128' / 'apps'
  install_data('data/org.the_jk.timer.png', install_dir : icon_path)

  gtk_update_icon_cache = find_program('gtk-update-icon-cache',
                                       required: false, native: true)
  if gtk_update_icon_cache.found()
    meson.add_install_script(gtk_update_icon_cache, icon_path)
  endif
endif