From 87d629753b767c2f553c94ab7a14172184c1af87 Mon Sep 17 00:00:00 2001 From: codereader Date: Fri, 18 Aug 2017 09:11:36 +0200 Subject: [PATCH] Adjust configure.ac script to detect whether pybind11 is provided by the system. Fall back to use the one shipped with the sources if nothing is found. --- configure.ac | 21 +++++++++++++++++---- plugins/script/Makefile.am | 6 ++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index 3e9dff9db5..05ce381862 100644 --- a/configure.ac +++ b/configure.ac @@ -187,15 +187,28 @@ then # pybind11.h is including Python.h, need to help it find the Python.h header CPPFLAGS="$USER_CPPFLAGS $PYTHON_CPPFLAGS $PYBIND11_CPPFLAGS" - AC_CHECK_HEADER([pybind11/pybind11.h], [], - [AC_MSG_ERROR([Missing pybind11.h, please install the pybind11 package for your system. \ -If there's no pybind11 package for your distribution, please download it from the pybind11 \ -website and specify the path to the include folder using --with-pybind11=/path/to/pybind11/include])]) + AC_MSG_NOTICE([Checking for pybind11 headers...]) + found_local_pybind11=no + + # Check for a system-provided pybind11, otherwise fall back on + # the pybind11 headers we ship in the libs/pybind folder + AC_CHECK_HEADER([pybind11/pybind11.h], [found_local_pybind11=yes], [found_local_pybind11=no]) + + if test "$found_local_pybind11" = 'yes' + then + AC_MSG_NOTICE([Using the system-provided pybind11 headers]) + else + AC_MSG_NOTICE([Using the pybind11 headers shipped with the sources]) + fi + + AM_CONDITIONAL([SYSTEM_HAS_PYBIND11], [test "$found_local_pybind11" = 'yes']) + script_module='script' AC_SUBST([script_module]) AC_SUBST([PYTHON_CPPFLAGS]) AC_SUBST([PYTHON_LIBS]) AC_SUBST([PYBIND11_CPPFLAGS]) + AC_SUBST([SYSTEM_HAS_PYBIND11]) # Used by Makefile.am in plugins/script/ fi fi diff --git a/plugins/script/Makefile.am b/plugins/script/Makefile.am index fa4b1dfee9..3f4f8f0c75 100644 --- a/plugins/script/Makefile.am +++ b/plugins/script/Makefile.am @@ -1,3 +1,9 @@ + +# If system doesn't provide pybind11, fall back to the pybind11 headers we ship in the libs/pybind folder +if !SYSTEM_HAS_PYBIND11 +PYBIND11_CPPFLAGS += -I$(top_srcdir)/libs/pybind +endif + AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/libs \ $(XML_CFLAGS) \ $(PYTHON_CPPFLAGS) \