summaryrefslogtreecommitdiff
path: root/meson.build
diff options
context:
space:
mode:
Diffstat (limited to 'meson.build')
-rw-r--r--meson.build373
1 files changed, 373 insertions, 0 deletions
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..7edf83c
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,373 @@
+project(
+ 'sawmill',
+ 'cpp',
+ 'c',
+ version : '0.10',
+ meson_version : '>= 1.3.0',
+ default_options : [
+ 'warning_level=3',
+ 'cpp_std=c++26',
+ 'cpp_eh=none',
+ 'cpp_rtti=false',
+ 'default_library=static',
+ ],
+)
+
+c_flags = []
+c_optional_flags = []
+cpp_flags = []
+if get_option('buildtype') == 'release'
+ # If asserts are disabled parameters and variables used for only that
+ # end up causing warnings
+ c_optional_flags += ['-Wno-unused-parameter', '-Wno-unused-variable',
+ '-Wno-unused-but-set-variable']
+ c_flags += '-DNDEBUG'
+ cpp_flags += '-DNDEBUG'
+endif
+cpp = meson.get_compiler('cpp')
+foreach flag : c_optional_flags
+ if cpp.has_argument(flag)
+ cpp_flags += flag
+ endif
+endforeach
+c = meson.get_compiler('c')
+foreach flag : c_optional_flags
+ if c.has_argument(flag)
+ c_flags += flag
+ endif
+endforeach
+add_project_arguments([cpp_flags], language: 'cpp')
+add_project_arguments([c_flags], language: 'c')
+
+jpeg = dependency('libjpeg', version: '>= 2.1.5', required: false)
+png = dependency('libpng', version: '>= 1.6.0', required: true)
+rsvg = dependency('librsvg-2.0', version: '>= 2.61.0', required: false)
+xpm = dependency('xpm', version: '>= 3.5.0', required: false)
+
+image_deps = [png]
+
+if jpeg.found()
+ image_deps += jpeg
+endif
+
+if rsvg.found()
+ image_deps += rsvg
+endif
+
+if xpm.found()
+ image_deps += xpm
+endif
+
+conf_data = configuration_data()
+conf_data.set('version', meson.project_version())
+conf_data.set10('have_jpeg', jpeg.found())
+conf_data.set10('have_png', png.found())
+conf_data.set10('have_rsvg', rsvg.found())
+conf_data.set10('have_xpm', xpm.found())
+configure_file(input: 'src/config.h.in',
+ output: 'config.h',
+ configuration : conf_data)
+
+inc = include_directories('src')
+
+args_lib = library(
+ 'args',
+ sources: [
+ 'src/args.cc',
+ 'src/args.hh',
+ ],
+ include_directories: inc,
+)
+args_dep = declare_dependency(link_with: args_lib)
+
+io_lib = library(
+ 'io',
+ sources: [
+ 'src/check.hh',
+ 'src/line.cc',
+ 'src/line.hh',
+ 'src/io.cc',
+ 'src/io.hh',
+ 'src/unique_fd.cc',
+ 'src/unique_fd.hh',
+ ],
+ include_directories: inc,
+)
+io_dep = declare_dependency(link_with: io_lib)
+
+str_lib = library(
+ 'str',
+ sources: [
+ 'src/str.cc',
+ 'src/str.hh',
+ ],
+ include_directories: inc,
+)
+str_dep = declare_dependency(link_with: str_lib)
+
+paths_lib = library(
+ 'paths',
+ sources: [
+ 'src/paths.cc',
+ 'src/paths.hh',
+ ],
+ include_directories: inc,
+ dependencies: [str_dep],
+)
+paths_dep = declare_dependency(
+ link_with: paths_lib,
+ dependencies: [str_dep],
+)
+
+cfg_lib = library(
+ 'cfg',
+ sources: [
+ 'src/cfg.cc',
+ 'src/cfg.hh',
+ ],
+ include_directories: inc,
+ dependencies: [io_dep, paths_dep, str_dep],
+)
+cfg_dep = declare_dependency(
+ link_with: cfg_lib,
+ dependencies: [io_dep, paths_dep, str_dep],
+)
+
+logger_lib = library(
+ 'logger',
+ sources: [
+ 'src/logger.cc',
+ 'src/logger.hh',
+ ],
+ include_directories: inc,
+)
+logger_dep = declare_dependency(link_with: logger_lib)
+
+if xpm.found()
+ xpm_color_inc = include_directories('src/xpm')
+ xpm_color_lib = library(
+ 'xpm_color',
+ sources: [
+ 'src/xpm/dix-config.h',
+ 'src/xpm/dix/dix_priv.h',
+ 'src/xpm/include/dix.h',
+ 'src/xpm/color.c',
+ ],
+ c_args: ['-Wno-sign-compare', '-Wno-unused-parameter'],
+ include_directories: xpm_color_inc,
+ dependencies: [xpm],
+ )
+ xpm_color_dep = declare_dependency(
+ link_with: xpm_color_lib,
+ dependencies: [xpm],
+ )
+
+ image_deps += xpm_color_dep
+endif
+
+image_processor_lib = library(
+ 'image_processor',
+ sources: [
+ 'src/colour.cc',
+ 'src/colour.hh',
+ 'src/image.cc',
+ 'src/image.hh',
+ 'src/image_processor.cc',
+ 'src/image_processor.hh',
+ 'src/size.hh',
+ ],
+ include_directories: inc,
+ dependencies : image_deps,
+)
+image_processor_dep = declare_dependency(
+ link_with: image_processor_lib,
+ dependencies: image_deps,
+)
+
+spawner_lib = library(
+ 'spawner',
+ sources: [
+ 'src/spawner.cc',
+ 'src/spawner.hh',
+ ],
+ include_directories: inc,
+ dependencies : [
+ io_dep,
+ ],
+)
+spawner_dep = declare_dependency(
+ link_with: spawner_lib,
+ dependencies: [
+ io_dep,
+ ],
+)
+
+sawmill = executable(
+ 'sawmill',
+ sources: [
+ 'src/main.cc',
+ ],
+ include_directories: inc,
+ install : true,
+ dependencies : [
+ args_dep,
+ cfg_dep,
+ image_processor_dep,
+ spawner_dep,
+ ],
+)
+
+gtest_main_dep = dependency('gtest_main', fallback : ['gtest', 'gtest_main_dep'])
+gmock_dep = dependency('gmock', fallback : ['gtest', 'gmock_dep'])
+
+test_dependencies = [
+ gtest_main_dep,
+]
+
+test('args', executable(
+ 'test_args',
+ sources: ['test/args.cc'],
+ include_directories: inc,
+ dependencies: [
+ args_dep,
+ test_dependencies,
+ ],
+))
+
+io_test_helper_lib = library(
+ 'io_test_helper',
+ sources: [
+ 'test/io_test_helper.cc',
+ 'test/io_test_helper.hh',
+ ],
+ include_directories: inc,
+ dependencies: io_dep,
+)
+io_test_helper_dep = declare_dependency(
+ link_with: io_test_helper_lib,
+ dependencies: io_dep,
+)
+
+testdir_lib = library(
+ 'testdir',
+ sources: [
+ 'test/testdir.cc',
+ 'test/testdir.hh',
+ ],
+ include_directories: inc,
+ dependencies: test_dependencies,
+)
+testdir_dep = declare_dependency(
+ link_with: testdir_lib,
+ dependencies: test_dependencies,
+)
+
+testenv_lib = library(
+ 'testenv',
+ sources: [
+ 'test/testenv.cc',
+ 'test/testenv.hh',
+ ],
+ include_directories: inc,
+ dependencies: test_dependencies,
+)
+testenv_dep = declare_dependency(
+ link_with: testenv_lib,
+ dependencies: test_dependencies,
+)
+
+test('line', executable(
+ 'test_line',
+ sources: ['test/line.cc'],
+ include_directories: inc,
+ dependencies: [
+ io_dep,
+ io_test_helper_dep,
+ test_dependencies,
+ ],
+))
+
+test('str', executable(
+ 'test_str',
+ sources: ['test/str.cc'],
+ include_directories: inc,
+ dependencies: [
+ str_dep,
+ test_dependencies,
+ ],
+))
+
+test('io', executable(
+ 'test_io',
+ sources: ['test/io.cc'],
+ include_directories: inc,
+ dependencies: [
+ io_dep,
+ io_test_helper_dep,
+ test_dependencies,
+ ],
+))
+
+test('paths', executable(
+ 'test_paths',
+ sources: ['test/paths.cc'],
+ include_directories: inc,
+ dependencies : [
+ paths_dep,
+ test_dependencies,
+ testenv_dep,
+ ],
+))
+
+test('cfg', executable(
+ 'test_cfg',
+ sources: ['test/cfg.cc'],
+ include_directories: inc,
+ dependencies : [
+ cfg_dep,
+ test_dependencies,
+ testdir_dep,
+ testenv_dep,
+ ],
+))
+
+test('u8', executable(
+ 'test_u8',
+ sources: [
+ 'src/u.hh',
+ 'src/u8.hh',
+ 'test/u8.cc',
+ ],
+ include_directories: inc,
+ dependencies : [
+ test_dependencies,
+ ],
+))
+
+test('image_processor', executable(
+ 'test_image_processor',
+ sources: ['test/image_processor.cc'],
+ cpp_args: ['-DTESTDIR="@0@/test/data"'.format(meson.current_source_dir())],
+ include_directories: inc,
+ dependencies : [
+ gmock_dep,
+ image_processor_dep,
+ spawner_dep,
+ test_dependencies,
+ ],
+))
+
+run_clang_tidy = find_program('run-clang-tidy', required: false)
+
+if run_clang_tidy.found()
+ # The clang-tidy target generated by meson misses most of the
+ # source files, so create our own.
+ run_target(
+ 'clang-tidy',
+ command: [
+ run_clang_tidy,
+ '-quiet',
+ '-use-color',
+ ],
+ )
+endif