Debian Codegraph @

meson.build

raw
1 project('picom', 'c', version: '13',
2 default_options: ['c_std=c11', 'warning_level=1'])
3
4 cc = meson.get_compiler('c')
5
6 # use git describe if that's available
7 git = find_program('git', required: false)
8 if git.found()
9 gitv = run_command('git', 'rev-parse', '--short=7', 'HEAD', check: false)
10 if gitv.returncode() == 0
11 commit_hash_short = gitv.stdout().strip()
12 endif
13 git_upstream = run_command('git', 'rev-parse', '--abbrev-ref', '--symbolic-full-name', '@{upstream}', check: false)
14 if git_upstream.returncode() == 0
15 remote = git_upstream.stdout().strip().split('/')[0]
16 else
17 remote = 'origin'
18 endif
19 git_repository = run_command('git', 'remote', 'get-url', remote, check: false)
20 if git_repository.returncode() == 0
21 repository = git_repository.stdout().strip()
22 endif
23 endif
24
25 add_global_arguments('-DPICOM_VERSION="v'+meson.project_version()+'"', language: 'c')
26 if is_variable('repository')
27 add_global_arguments('-DPICOM_FULL_VERSION="v'+meson.project_version()+' ('+repository+' revision '+commit_hash_short+')"', language: 'c')
28 elif is_variable('commit_hash_short')
29 add_global_arguments('-DPICOM_FULL_VERSION="v'+meson.project_version()+' (revision '+commit_hash_short+')"', language: 'c')
30 else
31 add_global_arguments('-DPICOM_FULL_VERSION="v'+meson.project_version()+'"', language: 'c')
32 endif
33
34 if get_option('buildtype') == 'release'
35 add_global_arguments('-DNDEBUG', language: 'c')
36 endif
37
38 if get_option('sanitize')
39 sanitizers = ['address', 'undefined']
40 if cc.has_argument('-fsanitize=integer')
41 sanitizers += ['integer']
42 endif
43 if cc.has_argument('-fsanitize=nullability')
44 sanitizers += ['nullability']
45 endif
46 add_global_arguments('-fsanitize='+','.join(sanitizers), language: 'c')
47 add_global_link_arguments('-fsanitize='+','.join(sanitizers), language: 'c')
48 if cc.has_argument('-fno-sanitize=unsigned-integer-overflow')
49 add_global_arguments('-fno-sanitize=unsigned-integer-overflow', language: 'c')
50 endif
51 if cc.has_argument('-fno-sanitize=unsigned-shift-base')
52 # uthash does a lot of this
53 add_global_arguments('-fno-sanitize=unsigned-shift-base', language: 'c')
54 endif
55 endif
56
57 if get_option('llvm_coverage')
58 if cc.get_id() != 'clang'
59 error('option \'llvm_coverage\' requires clang')
60 endif
61 coverage_flags = ['-fprofile-instr-generate', '-fcoverage-mapping']
62 add_global_arguments(coverage_flags, language: 'c')
63 add_global_link_arguments(coverage_flags, language: 'c')
64 endif
65
66 if get_option('modularize')
67 if not cc.has_argument('-fmodules')
68 error('option \'modularize\' requires clang')
69 endif
70 add_global_arguments(['-fmodules',
71 '-fmodule-map-file='+
72 meson.current_source_dir()+
73 '/src/picom.modulemap'],
74 language: 'c')
75 endif
76
77 add_global_arguments('-D_GNU_SOURCE', language: 'c')
78
79 if cc.has_header('stdc-predef.h')
80 add_global_arguments('-DHAS_STDC_PREDEF_H', language: 'c')
81 endif
82
83 if get_option('warning_level') != '0'
84 warns = [ 'cast-function-type', 'ignored-qualifiers', 'missing-parameter-type',
85 'nonnull', 'shadow', 'no-type-limits', 'old-style-declaration', 'override-init',
86 'sign-compare', 'type-limits', 'uninitialized', 'shift-negative-value',
87 'unused-but-set-parameter', 'unused-parameter', 'implicit-fallthrough=2',
88 'no-unknown-warning-option', 'no-missing-braces', 'conversion', 'empty-body',
89 'no-c2x-extensions' ]
90 bad_warns_ubsan = [
91 'no-format-overflow' # see gcc bug 87884, enabling UBSAN makes gcc spit out spurious warnings
92 # (if you saw this comment, went and checked gcc bugzilla, and found out
93 # bug has been fixed, please open a PR to remove this).
94 ]
95 if get_option('b_sanitize').contains('undefined') and cc.get_id() == 'gcc'
96 warns = warns + bad_warns_ubsan
97 endif
98 foreach w : warns
99 if cc.has_argument('-W'+w)
100 add_global_arguments('-W'+w, language: 'c')
101 endif
102 endforeach
103 endif
104
105 test_h_dep = subproject('test.h').get_variable('test_h_dep')
106
107 subdir('src')
108 subdir('man')
109 subdir('tools')
110 subdir('include')
111
112 install_data('bin/picom-trans', install_dir: get_option('bindir'))
113 install_data('picom.desktop', install_dir: 'share/applications')
114 install_data('picom.desktop', install_dir: get_option('sysconfdir') / 'xdg' / 'autostart')
115
116 pkgconf = import('pkgconfig')
117
118 picom_pc = pkgconf.generate(
119 name: 'picom-api',
120 description: 'picom API headers',
121 requires: [ 'pixman-1', 'xcb' ],
122 subdirs: 'picom',
123 )
124
125 if get_option('compton')
126 install_data('compton.desktop', install_dir: 'share/applications')
127 install_data('media/icons/48x48/compton.png',
128 install_dir: 'share/icons/hicolor/48x48/apps')
129 install_data('media/compton.svg',
130 install_dir: 'share/icons/hicolor/scalable/apps')
131
132 meson.add_install_script('meson/install.sh')
133 endif