# SPDX-FileCopyrightText: 2022 John Scott <jscott@posteo.net>
# SPDX-License-Identifier: GPL-3.0-or-later
# This is free software subject to the GNU General Public License,
# either version three or, at your option, any later version.
project('pdfpartition', 'c', license: 'GPL-3.0-or-later')
cc = meson.get_compiler('c')
if not cc.compiles('''
#define _POSIX_C_SOURCE 200809L
#include <unistd.h>
#if _POSIX_VERSION < _POSIX_C_SOURCE
#error
#endif''')
warning('A POSIX-conformant system is required')
endif
posix = ['-D_POSIX_C_SOURCE=200809L']
assert(cc.has_function('getopt', args: posix, prefix: '#include <unistd.h>'))
cairo = dependency('cairo-pdf')
if not cc.compiles('''
#include <cairo.h>
#include <cairo-pdf.h>
#if !CAIRO_HAS_PDF_SURFACE
#error
#endif''', dependencies: cairo, name: 'check for Cairo PDF support')
error('Cairo PDF support is required')
endif
gio = dependency('gio-2.0')
glib = dependency('glib-2.0')
poppler = dependency('poppler-glib')
if not cc.compiles('''
#include <poppler.h>
#if !POPPLER_HAS_CAIRO
#error
#endif''', dependencies: poppler, name: 'check that Poppler has Cairo support')
error('support for Poppler Cairo output is required')
endif
executable('pdfpartition', 'main.c', install: true, dependencies: [cairo, gio, glib, poppler])