aboutsummaryrefslogtreecommitdiffstats
path: root/share/qtcreator/templates/wizards/projects/cpplibrary/meson.build
blob: 73b1e67fbcfef2baeedc0df9baf6cb028a2d68a4 (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
project('%{ProjectName}', 'cpp',
@if %{IsStatic}
        default_options : ['cpp_std=c++11', 'default_library=static'],
@else
        default_options : ['cpp_std=c++11', 'default_library=shared'],
@endif
        meson_version:'>=0.48')

@if '%{QtModule}' != 'none'
# Documentation: https://mesonbuild.com/Qt5-module.html
qt5 = import('qt5')

@if '%{QtModule}' == 'core'
qt5dep = dependency('qt5', modules : ['Core'])
@endif
@if '%{QtModule}' == 'gui'
qt5dep = dependency('qt5', modules : ['Core', 'Gui'])
@endif
@if '%{QtModule}' == 'widgets'
qt5dep = dependency('qt5', modules : ['Core', 'Gui', 'Widgets'])
@endif

@if %{HasTranslation}
translations = qt5.compile_translations(ts_files : '%{TsFileName}', build_by_default : true)
@endif

cpp_args = [
@if %{IsShared}
    '-D%{LibraryDefine}'
    @if %{IsQtPlugin}
    ,'-DQT_PLUGIN'
    @endif
@else
    @if %{IsQtPlugin}
    '-DQT_STATICPLUGIN'
    @endif
@endif
]

moc_files = qt5.preprocess(moc_headers : [
                            @if '%{Type}' === 'shared'
                            '%{GlobalHdrFileName}',
                            @endif
                            '%{HdrFileName}'],
                            moc_extra_arguments : cpp_args,
                            dependencies: [qt5dep])
@endif


library('%{ProjectName}', '%{SrcFileName}'
@if '%{QtModule}' != 'none'
        , moc_files
        , dependencies : [qt5dep]
        , cpp_args : cpp_args
@endif
        , install : true)