From 445c7d81f5df22923a32cbfc0a1a45c497ed5d98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Balzarotti?= Date: Wed, 20 Jan 2021 10:29:22 +0100 Subject: [PATCH 1/3] meson: Use system doctest if available * meson.build (doctest_proj): check if available as system dependency * blurhash.cpp: change doctest include path to doctest/doctest.h --- blurhash.cpp | 2 +- meson.build | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/blurhash.cpp b/blurhash.cpp index a4adf89f..c17802ac 100644 --- a/blurhash.cpp +++ b/blurhash.cpp @@ -11,7 +11,7 @@ #endif #ifdef DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN -#include +#include #endif using namespace std::literals; diff --git a/meson.build b/meson.build index 6000a65a..8cefcecd 100644 --- a/meson.build +++ b/meson.build @@ -6,8 +6,13 @@ lib = static_library('blurhash', 'blurhash.cpp', install : true) -doctest_proj = subproject('doctest') -doctest_dep = doctest_proj.get_variable('doctest_dep') +doctest_dep = dependency('doctest', required : false) + +if not doctest_dep.found() + doctest_proj = subproject('doctest') + doctest_dep = doctest_proj.get_variable('doctest_dep') +endif + tests = executable('blurhash-tests', 'blurhash.cpp', cpp_args : '-DDOCTEST_CONFIG_IMPLEMENT_WITH_MAIN', From db53931b8cde84530db9b684dbb1eb75efa650a4 Mon Sep 17 00:00:00 2001 From: nixo Date: Wed, 20 Jan 2021 12:12:14 +0100 Subject: [PATCH 2/3] meson: install pkgconfig and header files --- meson.build | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/meson.build b/meson.build index 8cefcecd..152c4e7b 100644 --- a/meson.build +++ b/meson.build @@ -6,12 +6,7 @@ lib = static_library('blurhash', 'blurhash.cpp', install : true) -doctest_dep = dependency('doctest', required : false) - -if not doctest_dep.found() - doctest_proj = subproject('doctest') - doctest_dep = doctest_proj.get_variable('doctest_dep') -endif +doctest_dep = dependency('doctest', fallback : ['doctest', 'doctest_dep']) tests = executable('blurhash-tests', 'blurhash.cpp', @@ -22,3 +17,13 @@ test('blurhash-tests', tests) executable('blurhash2bmp', 'blurhash2bmp.cpp', link_with: lib, install: true) executable('blurhash', 'image2blurhash.cpp', link_with: lib, install: true) + +install_headers('blurhash.hpp') + +pkg = import('pkgconfig') +pkg.generate(libraries : [lib], + subdirs : ['.'], + version : meson.project_version(), + name : meson.project_name(), + filebase : meson.project_name(), + description : 'C++ blurhash encoder/decoder') From e7d1113a2b254bc37b098f0cdda4c0908e20487f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Balzarotti?= Date: Wed, 20 Jan 2021 15:18:47 +0100 Subject: [PATCH 3/3] Update blurhash.cpp Apply suggestion from github interface (will need to be squashed before merge) Co-authored-by: DeepBlueV7.X --- blurhash.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/blurhash.cpp b/blurhash.cpp index c17802ac..b8c0eba4 100644 --- a/blurhash.cpp +++ b/blurhash.cpp @@ -11,8 +11,12 @@ #endif #ifdef DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN +#if __has_include() +#include +#else #include #endif +#endif using namespace std::literals;