meson.build 1.67 KB
Newer Older
Niklas Haas's avatar
Niklas Haas committed
1
project('libplacebo', ['c', 'cpp'],
Niklas Haas's avatar
Niklas Haas committed
2 3
  license: 'LGPL2.1+',
  default_options: ['c_std=c99'],
4
  meson_version: '>=0.47',
Niklas Haas's avatar
Niklas Haas committed
5
  version: '1.18.0',
Niklas Haas's avatar
Niklas Haas committed
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
# Version number
version = meson.project_version()
version_pretty = 'v' + version
version_split = version.split('.')

majorver = version_split[0]
apiver = version_split[1]
fixver = version_split[2]

# update `version_pretty` with `git describe` information if available
git = find_program('git', required: false)
if git.found()
  gitdesc = run_command(git, 'describe')
  if gitdesc.returncode() == 0
    version_pretty = gitdesc.stdout().strip()
  endif
endif


# Global build options
build_opts = [
  # Warnings
  '-Wall', '-Wundef', '-Wshadow', '-Wparentheses', '-Wpointer-arith',

  # Warnings to treat as errors
  '-Werror=implicit-function-declaration',
]

link_args = []

cc = meson.get_compiler('c')
cxx = meson.get_compiler('cpp')

c_opts = [
  '-D_ISOC99_SOURCE', '-D_GNU_SOURCE', '-D_XOPEN_SOURCE=700',
  '-U__STRICT_ANSI__', '-fvisibility=hidden',
  '-Wmissing-prototypes', '-Wno-pointer-sign'
]

# glslang needs c++11
cpp_opts = [
  '-std=c++11', '-fvisibility=hidden',
]

if cc.has_argument('-Wincompatible-pointer-types')
  build_opts += ['-Werror=incompatible-pointer-types']
endif

# clang's version of -Wmissing-braces rejects the common {0} initializers
if cc.get_id() == 'clang'
  build_opts += ['-Wno-missing-braces']
endif

# don't leak library symbols if possible
vflag = '-Wl,--exclude-libs=ALL'
if cc.has_link_argument(vflag)
  link_args += [vflag]
endif

add_global_arguments(build_opts + c_opts, language: 'c')
add_global_arguments(build_opts + cpp_opts, language: 'cpp')
add_global_link_arguments(link_args, language: 'c')

Niklas Haas's avatar
Niklas Haas committed
71
subdir('src')