Skip to content

Commit bfdc74c

Browse files
committed
meson: Support building in both top level and libvmaf/
1 parent 9035764 commit bfdc74c

File tree

6 files changed

+100
-40
lines changed

6 files changed

+100
-40
lines changed

libvmaf/include/libvmaf/meson.build

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
vmaf_api_version_array = meson.project_version().split('.')
2+
vmaf_api_version_major = vmaf_api_version_array[0]
3+
vmaf_api_version_minor = vmaf_api_version_array[1]
4+
vmaf_api_version_revision = vmaf_api_version_array[2]
5+
16
# installed version.h header generation
27
version_h_data = configuration_data()
38
version_h_data.set('VMAF_API_VERSION_MAJOR', vmaf_api_version_major)

libvmaf/include/meson.build

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Revision file (vcs_version.h) generation
2-
vmaf_git_dir = join_paths(libvmaf_src_root + '/../', '.git')
2+
vmaf_git_dir = meson.project_source_root() / '.git'
33
rev_target = vcs_tag(command: [
44
'git', '--git-dir', vmaf_git_dir,
55
'describe', '--tags', '--long',
@@ -9,4 +9,6 @@ rev_target = vcs_tag(command: [
99
output: 'vcs_version.h'
1010
)
1111

12+
libvmaf_inc = include_directories('.')
13+
1214
subdir('libvmaf')

libvmaf/meson.build

Lines changed: 10 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,14 @@
1-
vmaf_soname_version = '3.0.0'
2-
vmaf_api_version_array = vmaf_soname_version.split('.')
3-
vmaf_api_version_major = vmaf_api_version_array[0]
4-
vmaf_api_version_minor = vmaf_api_version_array[1]
5-
vmaf_api_version_revision = vmaf_api_version_array[2]
1+
project('libvmaf', ['c', 'cpp'],
2+
version : '3.0.0',
3+
default_options : ['c_std=c11',
4+
'cpp_std=c++11',
5+
'warning_level=2',
6+
'buildtype=release',
7+
'default_library=both',
8+
],
9+
meson_version: '>= 0.56.1')
610

7-
libvmaf_src_root = meson.current_source_dir()
8-
cc = meson.get_compiler('c')
9-
libvmaf_inc = include_directories(['include'])
10-
11-
# Arguments in test_args will be used even on feature tests
12-
test_args = []
13-
if host_machine.system() == 'linux' or host_machine.system() == 'windows' or host_machine.system() == 'cygwin'
14-
test_args += '-D_GNU_SOURCE'
15-
add_project_arguments('-D_GNU_SOURCE', language: ['c', 'cpp'])
16-
elif host_machine.system() == 'darwin'
17-
test_args += '-D_DARWIN_C_SOURCE'
18-
add_project_arguments('-D_DARWIN_C_SOURCE', language: ['c', 'cpp'])
19-
endif
20-
21-
# Header checks
22-
stdatomic_dependency = []
23-
if not cc.check_header('stdatomic.h')
24-
if cc.get_id() == 'msvc'
25-
# we have a custom replacement for MSVC
26-
stdatomic_dependency = declare_dependency(
27-
include_directories : include_directories('src/compat/msvc'),
28-
)
29-
elif cc.compiles('''int main() { int v = 0; return __atomic_fetch_add(&v, 1, __ATOMIC_SEQ_CST); }''',
30-
name : 'GCC-style atomics', args : test_args)
31-
stdatomic_dependency = declare_dependency(
32-
include_directories : include_directories('src/compat/gcc'),
33-
)
34-
else
35-
error('Atomics not supported')
36-
endif
37-
endif
11+
warning('Please run meson in top source directory instead of libvmaf/ subdir.')
3812

3913
subdir('include')
4014
subdir('src')

libvmaf/meson_options.txt

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
option('enable_tests',
2+
type: 'boolean',
3+
value: true,
4+
description: 'Build libvmaf tests')
5+
6+
option('enable_docs',
7+
type: 'boolean',
8+
value: true,
9+
description: 'Build libvmaf documentation')
10+
11+
option('enable_asm',
12+
type: 'boolean',
13+
value: true,
14+
description: 'Build asm files, if available')
15+
16+
option('enable_avx512',
17+
type: 'boolean',
18+
value: true,
19+
description: 'Build AVX-512 asm files, requires nasm 2.14')
20+
21+
option('built_in_models',
22+
type: 'boolean',
23+
value: true,
24+
description: 'Compile default vmaf models into the library')
25+
26+
option('enable_float',
27+
type: 'boolean',
28+
value: false,
29+
description: 'Compile floating-point feature extractors into the library')
30+
31+
option('enable_cuda',
32+
type: 'boolean',
33+
value: false,
34+
description: 'Enable CUDA support')
35+
36+
option('enable_nvtx',
37+
type: 'boolean',
38+
value: false,
39+
description: 'Enable NVTX range support')
40+
41+
option('enable_nvcc',
42+
type: 'boolean',
43+
value: true,
44+
description: 'Use clang to compile CUDA code.')

libvmaf/src/meson.build

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
vmaf_soname_version = vmaf_api_version_major + '.0.0'
12
vmaf_soversion = vmaf_api_version_major
23

34
# Build libvmaf
@@ -8,6 +9,36 @@ cuda_dir = './cuda/'
89

910
vmaf_base_include = include_directories('./', './feature/common')
1011

12+
cc = meson.get_compiler('c')
13+
14+
# Arguments in test_args will be used even on feature tests
15+
test_args = []
16+
if host_machine.system() == 'linux' or host_machine.system() == 'windows' or host_machine.system() == 'cygwin'
17+
test_args += '-D_GNU_SOURCE'
18+
add_project_arguments('-D_GNU_SOURCE', language: ['c', 'cpp'])
19+
elif host_machine.system() == 'darwin'
20+
test_args += '-D_DARWIN_C_SOURCE'
21+
add_project_arguments('-D_DARWIN_C_SOURCE', language: ['c', 'cpp'])
22+
endif
23+
24+
# Header checks
25+
stdatomic_dependency = []
26+
if not cc.check_header('stdatomic.h')
27+
if cc.get_id() == 'msvc'
28+
# we have a custom replacement for MSVC
29+
stdatomic_dependency = declare_dependency(
30+
include_directories : include_directories('src/compat/msvc'),
31+
)
32+
elif cc.compiles('''int main() { int v = 0; return __atomic_fetch_add(&v, 1, __ATOMIC_SEQ_CST); }''',
33+
name : 'GCC-style atomics', args : test_args)
34+
stdatomic_dependency = declare_dependency(
35+
include_directories : include_directories('src/compat/gcc'),
36+
)
37+
else
38+
error('Atomics not supported')
39+
endif
40+
endif
41+
1142
if cc.get_id() != 'msvc'
1243
vmaf_cflags_common = [
1344
'-pedantic',
@@ -111,7 +142,7 @@ if is_asm_enabled
111142
depfile: '@BASENAME@.obj.ndep',
112143
arguments: [
113144
'-f', nasm_format,
114-
'-I', '@0@/src/'.format(libvmaf_src_root),
145+
'-I', '@0@/'.format(meson.current_source_dir()),
115146
'-I', '@0@/'.format(meson.current_build_dir()),
116147
'-MQ', '@OUTPUT@', '-MF', '@DEPFILE@',
117148
'@EXTRA_ARGS@',
@@ -561,7 +592,7 @@ libvmaf = library(
561592
libvmaf_cpu_static_lib.extract_all_objects(recursive: true),
562593
libsvm_static_lib.extract_all_objects(recursive: true),
563594
],
564-
version : vmaf_soname_version,
595+
version: vmaf_soname_version,
565596
soversion : vmaf_soversion,
566597
install: true,
567598
)

meson.build

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,8 @@ project('libvmaf', ['c', 'cpp'],
88
],
99
meson_version: '>= 0.56.1')
1010

11-
subdir('libvmaf')
11+
subdir('libvmaf/include')
12+
subdir('libvmaf/src')
13+
subdir('libvmaf/tools')
14+
subdir('libvmaf/doc')
15+
subdir('libvmaf/test')

0 commit comments

Comments
 (0)