-
Notifications
You must be signed in to change notification settings - Fork 0
/
meson.build
101 lines (79 loc) · 2.28 KB
/
meson.build
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
101
project(
'nomaR', 'c',
version : '0.4.0',
license : 'GPL3',
meson_version : '>= 0.56.0',
default_options : ['c_std=c99']
)
# Package executable
package = 'nomar'
# Package name as in project
package_name = meson.project_name()
# Version template
version_t = '@version@'
# Package string as in autoheader
package_string = ' '.join([meson.project_name(), version_t])
# Package bugreport
package_bugreport = 'https://github.com/galantelab/nomar/issues'
# Create a configuration structure
config = configuration_data()
# Defines
set_defines = [
['PACKAGE', package],
['PACKAGE_NAME', package_name],
['PACKAGE_BUGREPORT', package_bugreport],
['PACKAGE_STRING', package_string],
['PACKAGE_VERSION', version_t],
['VERSION', version_t]
]
# Set config values
foreach define: set_defines
config.set_quoted(define[0], define[1])
endforeach
# Write macros to 'config.h.in' file
config_in = configure_file(
output : 'config.h.in',
configuration : config
)
# The version is dynamically generated according to
# the 'git tag and commit'
# Read config.h.in and replace the version template
# generating in turn config.h
config_out = vcs_tag(
command : ['git', 'describe', '--tags', '--dirty=+'],
input : config_in,
output : 'config.h',
replace_string : version_t
)
# Declare 'config.h' as dependency in order to obligate
# the build system to generate it before compiling
# Fix issue #1
config_dep = declare_dependency(sources : config_out)
# Compiler flags
common_flags = ['-DHAVE_CONFIG_H', '-D_GNU_SOURCE']
# Set project flags and language
add_project_arguments(common_flags, language: 'c')
# Let the compiler find required libraries
cc = meson.get_compiler('c')
# Math library portably
m_dep = cc.find_library('m', required : false)
# Zlib
zlib_dep = dependency('zlib')
# HDF5
hdf5_dep = dependency('hdf5', language: 'c')
# Libcheck framework is used for testing, so it is not
# required for building and installing
check_dep = dependency('check', version : '>= 0.15.0', required : false)
# All required deps
deps = [
config_dep,
zlib_dep,
hdf5_dep,
m_dep
]
# Set the path to find 'config.h'
inc = include_directories('.')
# Build static library and executable
subdir('src')
# Testing
subdir('tests')