diff mbox series

[libgpiod,2/5] bindings: cxx: Try using pkg-config to detect catch2

Message ID 20190807195132.7538-2-alexander.stein@mailbox.org
State New
Headers show
Series [libgpiod,1/5] bindings: cxx: Use 'upstream' include path | expand

Commit Message

Alexander Stein Aug. 7, 2019, 7:51 p.m. UTC
If there is no system wide package, try using a regular header as before.

Signed-off-by: Alexander Stein <alexander.stein@mailbox.org>
---
 bindings/cxx/tests/Makefile.am | 2 +-
 configure.ac                   | 8 +++++---
 2 files changed, 6 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/bindings/cxx/tests/Makefile.am b/bindings/cxx/tests/Makefile.am
index 155445f..d1da0d3 100644
--- a/bindings/cxx/tests/Makefile.am
+++ b/bindings/cxx/tests/Makefile.am
@@ -8,7 +8,7 @@ 
 
 AM_CPPFLAGS = -I$(top_srcdir)/bindings/cxx/ -I$(top_srcdir)/include
 AM_CPPFLAGS += -I$(top_srcdir)/tests/mockup/
-AM_CPPFLAGS += -Wall -Wextra -g -std=gnu++11
+AM_CPPFLAGS += -Wall -Wextra -g -std=gnu++11 $(CATCH2_CFLAGS)
 AM_LDFLAGS = -lgpiodcxx -L$(top_builddir)/bindings/cxx/
 AM_LDFLAGS += -lgpiomockup -L$(top_builddir)/tests/mockup/
 AM_LDFLAGS += -pthread
diff --git a/configure.ac b/configure.ac
index 0459007..bf364e7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -164,9 +164,11 @@  then
 
 	if test "x$with_tests" = xtrue
 	then
-		AC_LANG_PUSH([C++])
-		AC_CHECK_HEADERS([catch2/catch.hpp], [], [HEADER_NOT_FOUND_CXX([catch2/catch.hpp])])
-		AC_LANG_POP([C++])
+		PKG_CHECK_MODULES([CATCH2], [catch2],, [
+			AC_LANG_PUSH([C++])
+			AC_CHECK_HEADERS([catch2/catch.hpp], [], [HEADER_NOT_FOUND_CXX([catch2/catch.hpp])])
+			AC_LANG_POP([C++])
+		])
 	fi
 fi