Skip to content

Commit

Permalink
Adjust configure.ac to accept the pybind11 include path as --with-pyb…
Browse files Browse the repository at this point in the history
…ind11=/path
  • Loading branch information
codereader committed Jul 23, 2017
1 parent f90d8c9 commit 6275951
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
20 changes: 17 additions & 3 deletions configure.ac
Expand Up @@ -65,6 +65,10 @@ AC_ARG_ENABLE([python],
[python_scripting=$enableval],
[python_scripting='yes'])

AC_ARG_WITH(pybind11,
[--with-pybind11=/path/to/pybind11/include pybind11 include path to use (optional)],
pybind11_include_path="$withval")

if [[ "$darkmod_plugins" != 'no' ]]
then
# Enable conditional directories (used by plugins/Makefile.am)
Expand Down Expand Up @@ -157,7 +161,6 @@ BOOST_BIND
BOOST_FOREACH
BOOST_FORMAT
BOOST_FUNCTION
BOOST_SMART_PTR
BOOST_TOKENIZER

# These ones require libraries too
Expand All @@ -174,14 +177,25 @@ then
then
PYTHON_LIBS=`$PYTHON_CONFIG --libs`
PYTHON_CPPFLAGS=`$PYTHON_CONFIG --includes`
PYBIND11_CPPFLAGS=``

# Add the path to the pybind11 library if we got one from the arguments
if test "x$pybind11_include_path" != x ; then
PYBIND11_CPPFLAGS="-I$pybind11_include_path"
fi

# pybind11.h is including Python.h, need to help it find the Python.h header
CPPFLAGS="$USER_CPPFLAGS $PYTHON_CPPFLAGS"
AC_CHECK_HEADER([pybind11/pybind11.h], [], [AC_MSG_ERROR([Missing pybind11.h, please install the pybind11 package])])
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])])
script_module='script'
AC_SUBST([script_module])
AC_SUBST([PYTHON_CPPFLAGS])
AC_SUBST([PYTHON_LIBS])
AC_SUBST([PYBIND11_CPPFLAGS])
fi
fi

Expand Down
1 change: 1 addition & 0 deletions m4/libtool.m4
Expand Up @@ -728,6 +728,7 @@ _LT_CONFIG_SAVE_COMMANDS([
cat <<_LT_EOF >> "$cfgfile"
#! $SHELL
# Generated automatically by $as_me ($PACKAGE) $VERSION
# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
# NOTE: Changes made to this file will be lost: look at ltmain.sh.
# Provide generalized library-building support services.
Expand Down
1 change: 1 addition & 0 deletions plugins/script/Makefile.am
@@ -1,6 +1,7 @@
AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/libs \
$(XML_CFLAGS) \
$(PYTHON_CPPFLAGS) \
$(PYBIND11_CPPFLAGS) \
-DPKGLIBDIR='"$(pkglibdir)"'

modulesdir = $(pkglibdir)/modules
Expand Down
5 changes: 5 additions & 0 deletions plugins/script/PythonModule.cpp
Expand Up @@ -24,6 +24,11 @@ void PythonModule::RegisterToPython(const ModuleRegistrationCallback& callback)
{
_registrationCallback = callback;

rMessage() << "Registering darkradiant module to Python using pybind11 version " <<
PYBIND11_VERSION_MAJOR << "." <<
PYBIND11_VERSION_MINOR << "." <<
PYBIND11_VERSION_PATCH << std::endl;

// Register the darkradiant module to Python
int result = PyImport_AppendInittab(NAME(), InitModule);

Expand Down

0 comments on commit 6275951

Please sign in to comment.