Commit cc03351a authored by Niklas Haas's avatar Niklas Haas

meson: switch to using feature options

Annoyingly, this requires using =enabled/disabled instead of
=true/false, but it's less boilerplate and more consistency in the long
run to do things this way.
parent 696f8bab
......@@ -220,7 +220,7 @@ If you want to disable a component, for example Vulkan support, you can
explicitly set it to `false`, i.e.:
```bash
$ meson configure $DIR -Dvulkan=false -Dshaderc=false
$ meson configure $DIR -Dvulkan=disabled -Dshaderc=disabled
$ ninja -C$DIR
```
......
# Optional components
option('vulkan', type: 'combo', choices: ['auto', 'true', 'false'],
option('vulkan', type: 'feature', value: 'auto',
description: 'Vulkan-based renderer')
option('glslang', type: 'combo', choices: ['auto', 'true', 'false'],
option('glslang', type: 'feature', value: 'auto',
description: 'glslang SPIR-V compiler')
option('shaderc', type: 'combo', choices: ['auto', 'true', 'false'],
option('shaderc', type: 'feature', value: 'auto',
description: 'libshaderc SPIR-V compiler')
option('lcms', type: 'combo', choices: ['auto', 'true', 'false'],
option('lcms', type: 'feature', value: 'auto',
description: 'LittleCMS 2 support')
# Miscellaneous
......
......@@ -42,7 +42,7 @@ build_deps = [
cc.find_library('m', required: false),
]
vulkan = dependency('vulkan', version: '>=1.0.42', required: false)
vulkan = dependency('vulkan', version: '>=1.0.42', required: get_option('vulkan'))
# Source files
sources = [
......@@ -81,13 +81,14 @@ tests = [
# Work-arounds for glslang braindeath
glslang_combined = disabler()
glslang_min_ver = 2763
glslang_req = get_option('glslang')
glslang_deps = [
cxx.find_library('glslang', required: false),
cxx.find_library('HLSL', required: false),
cxx.find_library('OGLCompiler', required: false),
cxx.find_library('OSDependent', required: false),
cxx.find_library('SPIRV', required: false),
cxx.find_library('SPVRemapper', required: false),
cxx.find_library('glslang', required: glslang_req),
cxx.find_library('HLSL', required: glslang_req),
cxx.find_library('OGLCompiler', required: glslang_req),
cxx.find_library('OSDependent', required: glslang_req),
cxx.find_library('SPIRV', required: glslang_req),
cxx.find_library('SPVRemapper', required: glslang_req),
]
glslang_found = true
......@@ -112,7 +113,7 @@ endif
components = [
{
'name': 'lcms',
'deps': dependency('lcms2', version: '>=2.6', required: false),
'deps': dependency('lcms2', version: '>=2.6', required: get_option('lcms')),
'srcs': 'lcms.c',
}, {
'name': 'glslang',
......@@ -122,7 +123,7 @@ components = [
],
}, {
'name': 'shaderc',
'deps': cc.find_library('shaderc_shared', required: false),
'deps': cc.find_library('shaderc_shared', required: get_option('shaderc')),
'srcs': 'spirv_shaderc.c',
}, {
'name': 'vulkan',
......@@ -162,17 +163,11 @@ comps = configuration_data()
foreach c : components
name = c['name']
deps = c['deps']
opt = get_option(name)
avail = opt == 'false' ? false : deps.found()
if opt == 'true' and not avail
error(('Dependency \'@0@\', marked as required, is not found. To build ' +
'without support for @0@, use -D@0@=false.').format(name))
endif
pretty = name.underscorify().to_upper()
defs += '#define PL_HAVE_@0@ @1@\n'.format(pretty, avail ? 1 : 0)
if avail
defs += '#define PL_HAVE_@0@ @1@\n'.format(pretty, deps.found() ? 1 : 0)
if deps.found()
comps.set(name, 1)
build_deps += deps
sources += c.get('srcs', [])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment