File: meson.build

package info (click to toggle)
python-rtmidi 1.5.8-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,248 kB
  • sloc: cpp: 4,228; python: 2,853; makefile: 287; sh: 109; ansic: 19
file content (100 lines) | stat: -rw-r--r-- 3,426 bytes parent folder | download
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
89
90
91
92
93
94
95
96
97
98
99
100
project(
    'python-rtmidi',
    'cpp',
    version: '1.5.8',
    license: 'MIT',
    default_options: [
        'warning_level=2',
        'cpp_std=c++11'
    ],
    meson_version: '>=0.64.0'
)

cpp = meson.get_compiler('cpp')

# Jack API (portable)
jack2_dep = dependency('jack', version: '>=1.9.11', required: false)
jack1_dep = dependency('jack', version: ['>=0.125.0', '<1.0'], required: false)

if not jack2_dep.found() and jack1_dep.found()
    jack_dep = jack1_dep
elif jack2_dep.found()
    jack_dep = jack2_dep
else
    warning('No version of JACK found, which is recent enough (jack2>=1.9.11 or jack1>=0.125.0)')
    jack_dep = disabler()
endif

jack_not_found = jack_dep.found() ? false : true

## From https://github.com/numpy/numpy/blob/main/numpy/meson.build
# Platform dependent config
if host_machine.system().to_lower() == 'windows'
    # WINDOWS
    if cpp.get_id() == 'gcc'
        # For mingw-w64, link statically against the UCRT.
        gcc_link_args = ['-lucrtbase', '-static']
        add_project_link_arguments(gcc_link_args, language: ['c', 'cpp'])
        # Make fprintf("%zd") work (see https://github.com/rgommers/scipy/issues/118)
        add_project_arguments('-D__USE_MINGW_ANSI_STDIO=1', language: ['c', 'cpp'])
        # Manual add of MS_WIN64 macro when not using MSVC.
        # https://bugs.python.org/issue28267
        add_project_arguments('-DMS_WIN64', language: ['c', 'cpp'])
    elif cpp.get_id() == 'msvc'
        # Force gcc to float64 long doubles for compatibility with MSVC
        # builds, for C only.
        add_project_arguments('-mlong-double-64', language: 'c')
    endif

    # API
    winmm_dep = cpp.find_library('winmm', required: jack_not_found)
    alsa_dep = disabler()
elif host_machine.system().to_lower() == 'darwin'
    # OSX

    # API
    coremidi_dep = dependency(
        'appleframeworks',
        modules: ['coreaudio', 'coremidi', 'foundation'],
        required: jack_not_found
    )
    alsa_dep = disabler()
else
    # LINUX

    # API
    alsa_dep = dependency('alsa', required: jack_not_found)
endif # Platform detection

jack_support = jack_dep.found() and get_option('jack')
alsa_support = host_machine.system().to_lower() == 'linux' and alsa_dep.found() and get_option('alsa')
coremidi_support = host_machine.system().to_lower() == 'darwin' and coremidi_dep.found() and get_option('coremidi')
winmm_support = host_machine.system().to_lower() == 'windows' and winmm_dep.found() and get_option('winmm')

threads_dep = dependency('threads', required: alsa_support or jack_support)
have_semaphore = cpp.has_header('semaphore.h')

pymod = import('python')
python = pymod.find_installation(get_option('python'), required: true, pure: false)

# Generate _rtmidi extension source
subdir('src')

# Build & install C++ extension module and Python package
subdir('rtmidi')

if meson.version().version_compare('<1.2.0') and not get_option('wheel')
    postinstall_script = files('meson_postinstall.py')
    meson.add_install_script(python, postinstall_script)
endif

summary({
    'Host machine system': host_machine.system(),
    'Python version': python.language_version(),
    'Debug messages (verbose)': get_option('verbose'),
    'Build for wheel': get_option('wheel'),
    'JACK support': jack_support,
    'ALSA support': alsa_support,
    'CoreMIDI support': coremidi_support,
    'Window MM support': winmm_support,
}, section: 'Configuration')