meson: add 'install' option

This is useful for people who want to use cglm as a meson subproject
without polluting the main project's install target.
This commit is contained in:
Andrei Alexeyev
2020-11-08 20:27:24 +02:00
parent 9da74f9654
commit 2a2d51624b
2 changed files with 16 additions and 14 deletions

View File

@@ -11,6 +11,7 @@ project('cglm', 'c',
cc = meson.get_compiler('c') cc = meson.get_compiler('c')
cglm_install = get_option('install')
cglm_deps = cc.find_library('m', required : false) cglm_deps = cc.find_library('m', required : false)
cglm_args = [] cglm_args = []
@@ -50,11 +51,9 @@ cglm_src = files(
'src/vec4.c' 'src/vec4.c'
) )
install_subdir('include/cglm', install_dir : get_option('includedir'))
cglm_lib = library('cglm', cglm_lib = library('cglm',
cglm_src, cglm_src,
install : true, install : cglm_install,
dependencies : cglm_deps, dependencies : cglm_deps,
c_args : [ build_args, cglm_args ] c_args : [ build_args, cglm_args ]
) )
@@ -71,17 +70,19 @@ if meson.version().version_compare('>= 0.54.0')
meson.override_dependency('cglm', cglm_dep) meson.override_dependency('cglm', cglm_dep)
endif endif
if cglm_install
install_subdir('include/cglm', install_dir : get_option('includedir'))
pkg = import('pkgconfig') pkg = import('pkgconfig')
pkg.generate(
pkg.generate( name : 'cglm',
name : 'cglm', libraries : cglm_lib,
libraries : cglm_lib, extra_cflags : cglm_args,
extra_cflags : cglm_args, version : meson.project_version(),
version : meson.project_version(), url : 'https://github.com/recp/cglm',
url : 'https://github.com/recp/cglm', description : 'OpenGL Mathematics (glm) for C'
description : 'OpenGL Mathematics (glm) for C' )
) endif
if get_option('build_tests') == true if get_option('build_tests') == true

View File

@@ -1 +1,2 @@
option('build_tests', type : 'boolean', value : false, description : 'Build tests') option('build_tests', type : 'boolean', value : false, description : 'Build tests')
option('install', type : 'boolean', value : true, description : 'Include the library, headers, and pkg-config file in the install target')