1From ae92a466e203c8aec43f682a3a7aa617b820c3ba Mon Sep 17 00:00:00 2001
2From: Sergio Prado <sergio.prado@e-labworks.com>
3Date: Sat, 10 Apr 2021 11:03:38 -0300
4Subject: [PATCH] Build unit tests only when --enable-unit-tests is passed
5
6Building unit tests by default requires all dependencies to be
7installed (jpeg, tiff, etc) and users may not want that.
8
9So let's disable the build of unit tests by default and introduce
10--enable-unit-tests configure option to enable it.
11
12Signed-off-by: Sergio Prado <sergio.prado@e-labworks.com>
13---
14 Makefile.am  | 8 ++++++--
15 configure.ac | 4 ++++
16 2 files changed, 10 insertions(+), 2 deletions(-)
17
18diff --git a/Makefile.am b/Makefile.am
19index f40bdee0c2e9..152e0d64fdd9 100644
20--- a/Makefile.am
21+++ b/Makefile.am
22@@ -1,7 +1,11 @@
23 ACLOCAL_AMFLAGS = -I m4
24
25-SUBDIRS = src tests
26-DIST_SUBDIRS = src tests
27+if BUILD_UNIT_TESTS
28+SUBDIRS_TESTS = tests
29+endif
30+
31+SUBDIRS = src $(SUBDIRS_TESTS)
32+DIST_SUBDIRS = src $(SUBDIRS_TESTS)
33
34 pkgconfigdir = $(libdir)/pkgconfig
35
36diff --git a/configure.ac b/configure.ac
37index 098fd0a664bd..c126ff091e58 100644
38--- a/configure.ac
39+++ b/configure.ac
40@@ -39,6 +39,10 @@ if test $warnaserror = "yes"; then
41   GDIPLUS_CFLAGS="$GDIPLUS_CFLAGS -Werror -Wno-unknown-warning-option -Wno-clobbered -Wno-typedef-redefinition"
42 fi
43
44+AC_ARG_ENABLE(unittests, AS_HELP_STRING([--enable-unittests],[Enable building unit tests.]),[unittests=yes],[unittests=no])
45+
46+AM_CONDITIONAL([BUILD_UNIT_TESTS], [test x$unittests = xyes])
47+
48 AC_ARG_ENABLE(asan, AS_HELP_STRING([--enable-asan],[Enable address sanitizer.]),[asan=yes],[asan=no])
49
50 if test $asan = "yes"; then
51--
522.17.1
53
54