project(
	'wlr-randr',
	'c',
	version : '0.5.0',
	license : 'MIT',
	meson_version : '>=0.59.0',
	default_options : ['c_std=c99', 'warning_level=3', 'werror=true']
)

cc = meson.get_compiler('c')

add_project_arguments(cc.get_supported_arguments([
	'-Wundef',
	'-Wlogical-op',
	'-Wmissing-include-dirs',
	'-Wold-style-definition',
	'-Wpointer-arith',
	'-Winit-self',
	'-Wfloat-equal',
	'-Wstrict-prototypes',
	'-Wredundant-decls',
	'-Wimplicit-fallthrough=2',
	'-Wendif-labels',
	'-Wstrict-aliasing=2',
	'-Woverflow',
	'-Wformat=2',

	'-Wno-missing-braces',
	'-Wno-missing-field-initializers',
	'-Wno-unused-parameter',
]), language: 'c')

wayland_client = dependency('wayland-client')

math = cc.find_library('m', required: false)

subdir('protocol')

wlr_randr_exe = executable(
	meson.project_name(),
	['main.c', protocol_src],
	dependencies: [wayland_client, math],
	install: true,
)

scdoc = dependency('scdoc', required: false, native: true)
if scdoc.found()
	scdoc_prog = find_program(scdoc.get_variable(pkgconfig: 'scdoc'), native: true)
	mandir = get_option('mandir')

	foreach src : ['wlr-randr.1.scd']
		topic = src.split('.')[0]
		section = src.split('.')[1]
		output = '@0@.@1@'.format(topic, section)

		custom_target(
			output,
			input: src,
			capture: true,
			feed: true,
			output: output,
			command: scdoc_prog.full_path(),
			install: true,
			install_dir: '@0@/man@1@'.format(mandir, section)
		)
	endforeach
endif
