Debian Codegraph @

meson.build

raw
1 #### Project Information
2 project(
3 'scikit-misc',
4 'c', 'cython',
5 version: run_command('skmisc/_build_utils/version_please.py', check: true).stdout().strip(),
6 license: 'BSD-3',
7 meson_version: '>= 1.1.0',
8 default_options: [
9 'buildtype=debugoptimized',
10 'c_std=c99',
11 'fortran_std=legacy',
12 'blas=openblas',
13 'lapack=openblas'
14 ],
15 )
16
17 # Adding at project level causes many spurious -lgfortran flags.
18 add_languages('fortran', native: false)
19 ###
20
21 #### Configuration Information
22 conf_data = configuration_data()
23
24 # The object above is stored so that we can write it to
25 # a file.
26 conf_data.set('VERSION', meson.project_version())
27 ###
28
29 #### Setup Python
30 # https://mesonbuild.com/Python-module.html
31 py_mod = import('python')
32 py = py_mod.find_installation(pure: false)
33 py_dep = py.dependency()
34
35 skmisc_dir = py.get_install_dir() / 'skmisc'
36
37 conf_data.set('PYTHON_PATH', py.full_path())
38 conf_data.set('PYTHON_VERSION', py.language_version())
39 ###
40
41 #### Setup Compilers
42 cc = meson.get_compiler('c')
43 ff = meson.get_compiler('fortran')
44 # generator() doesn't accept compilers, only found programs. Cast it.
45 cy = meson.get_compiler('cython')
46 cython = find_program(cy.cmd_array()[0])
47
48 compilers = {
49 'C': cc,
50 'CYTHON': cy,
51 'FORTRAN': ff
52 }
53
54 foreach name, compiler : compilers
55 # conf_data.set(name + '_COMP_CMD_ARRAY', compiler.cmd_array())
56 conf_data.set(name + '_COMP_CMD_ARRAY', compiler.get_id())
57 conf_data.set(name + '_COMP', compiler.get_id())
58 conf_data.set(name + '_COMP_LINKER_ID', compiler.get_linker_id())
59 conf_data.set(name + '_COMP_VERSION', compiler.version())
60 conf_data.set(name + '_COMP_CMD_ARRAY', ', '.join(compiler.cmd_array()))
61 endforeach
62 ###
63
64 #### Setup Machine CPU & System Information
65 machines = {
66 'HOST': host_machine,
67 'BUILD': build_machine,
68 }
69
70 foreach name, machine : machines
71 conf_data.set(name + '_CPU', machine.cpu())
72 conf_data.set(name + '_CPU_FAMILY', machine.cpu_family())
73 conf_data.set(name + '_CPU_ENDIAN', machine.endian())
74 conf_data.set(name + '_CPU_SYSTEM', machine.system())
75 endforeach
76
77 conf_data.set('CROSS_COMPILED', meson.is_cross_build())
78 ###
79
80 #### Compiler Arguments and Settings
81 # Check compiler is recent enough (see "Toolchain Roadmap" for details)
82 if cc.get_id() == 'gcc'
83 if not cc.version().version_compare('>=8.0')
84 error('scikit-misc requires GCC >= 8.0')
85 endif
86 elif cc.get_id() == 'msvc'
87 if not cc.version().version_compare('>=19.20')
88 error('scikit-misc requires at least vc142 (default with Visual Studio 2019) ' + \
89 'when building with MSVC')
90 endif
91 endif
92
93 # link against the standard math library since we use it in c
94 m_dep = cc.find_library('m', required : false)
95 if m_dep.found()
96 add_project_link_arguments('-lm', language : 'c')
97 endif
98
99 add_languages('fortran', native: false)
100 if ff.has_argument('-Wno-conversion')
101 add_project_arguments('-Wno-conversion', language: 'fortran')
102 endif
103
104
105 is_windows = host_machine.system() == 'windows'
106 is_macos = host_machine.system() == 'darwin'
107
108 # Intel compilers default to fast-math, so disable it if we detect Intel
109 # compilers. A word of warning: this may not work with the conda-forge
110 # compilers, because those have the annoying habit of including lots of flags
111 # that are gcc-specific in CFLAGS/CXXFLAGS/FFLAGS, which throws off the
112 # detection logic below. You have to remove the wrong flags (only `-isystem`
113 # is actually needed, everything else shouldn't be there).
114 _intel_cflags = []
115 _intel_fflags = []
116 if cc.get_id() == 'intel'
117 _intel_cflags += cc.get_supported_arguments('-fp-model=strict')
118 elif cc.get_id() == 'intel-cl'
119 _intel_cflags += cc.get_supported_arguments('/fp:strict')
120 endif
121 if ff.get_id() == 'intel'
122 _intel_fflags = ff.get_supported_arguments('-fp-model=strict')
123 minus0_arg = ['-assume', 'minus0']
124 if ff.has_multi_arguments(minus0_arg)
125 _intel_fflags += minus0_arg
126 endif
127 elif ff.get_id() == 'intel-cl'
128 # Intel Fortran on Windows does things differently, so deal with that
129 # (also specify dynamic linking and the right name mangling)
130 _intel_fflags = ff.get_supported_arguments(
131 '/fp:strict', '/MD', '/names:lowercase', '/assume:underscore',
132 '/assume:minus0'
133 )
134 endif
135 add_project_arguments(_intel_cflags, language: ['c'])
136 add_project_arguments(_intel_fflags, language: 'fortran')
137
138 cython_c_args = []
139 cython_args = ['-3', '--fast-fail', '--output-file', '@OUTPUT@', '--include-dir', '@BUILD_ROOT@', '@INPUT@']
140 cython_c_link_args = []
141 ###
142
143 #### Include Main Package
144 subdir('skmisc')
145 ###