configure: Detect compatibility of Boost.Process rather than hardcode non-Windows

pull/25696/head
Luke Dashjr 3 years ago committed by Hennadii Stepanov
parent 911a40ead2
commit 989451d068
No known key found for this signature in database
GPG Key ID: 410108112E7EA81F

@ -1493,45 +1493,45 @@ if test "$use_boost" = "yes"; then
fi fi
if test "$use_external_signer" != "no"; then if test "$use_external_signer" != "no"; then
case $host in AC_MSG_CHECKING([whether Boost.Process can be used])
*mingw*) TEMP_CXXFLAGS="$CXXFLAGS"
dnl Boost Process uses Boost Filesystem when targeting Windows. Also, dnl Boost 1.78 requires the following workaround.
dnl since Boost 1.71.0, Process does not work with mingw-w64 without dnl See: https://github.com/boostorg/process/issues/235
dnl workarounds. See 67669ab425b52a2b6be3d2f3b3b7e3939b676a2c. CXXFLAGS="$CXXFLAGS -Wno-error=narrowing"
if test "$use_external_signer" = "yes"; then TEMP_CPPFLAGS="$CPPFLAGS"
AC_MSG_ERROR([External signing is not supported on Windows]) CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
fi TEMP_LDFLAGS="$LDFLAGS"
use_external_signer="no"; dnl Boost 1.73 and older require the following workaround.
;; LDFLAGS="$LDFLAGS $PTHREAD_CFLAGS"
*) AC_LINK_IFELSE([AC_LANG_PROGRAM([[
AC_MSG_CHECKING([whether Boost.Process can be used]) #define BOOST_PROCESS_USE_STD_FS
TEMP_CXXFLAGS="$CXXFLAGS" #include <boost/process.hpp>
dnl Boost 1.78 requires the following workaround. ]],[[
dnl See: https://github.com/boostorg/process/issues/235 namespace bp = boost::process;
CXXFLAGS="$CXXFLAGS -Wno-error=narrowing" bp::opstream stdin_stream;
TEMP_CPPFLAGS="$CPPFLAGS" bp::ipstream stdout_stream;
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" bp::child c("dummy", bp::std_out > stdout_stream, bp::std_err > stdout_stream, bp::std_in < stdin_stream);
TEMP_LDFLAGS="$LDFLAGS" stdin_stream << std::string{"test"} << std::endl;
dnl Boost 1.73 and older require the following workaround. if (c.running()) c.terminate();
LDFLAGS="$LDFLAGS $PTHREAD_CFLAGS" c.wait();
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <boost/process.hpp>]])], c.exit_code();
[have_boost_process="yes"], ]])],
[have_boost_process="no"]) [have_boost_process="yes"],
LDFLAGS="$TEMP_LDFLAGS" [have_boost_process="no"])
CPPFLAGS="$TEMP_CPPFLAGS" LDFLAGS="$TEMP_LDFLAGS"
CXXFLAGS="$TEMP_CXXFLAGS" CPPFLAGS="$TEMP_CPPFLAGS"
AC_MSG_RESULT([$have_boost_process]) CXXFLAGS="$TEMP_CXXFLAGS"
if test "$have_boost_process" = "yes"; then AC_MSG_RESULT([$have_boost_process])
use_external_signer="yes" if test "$have_boost_process" = "yes"; then
AC_DEFINE([ENABLE_EXTERNAL_SIGNER], [1], [Define if external signer support is enabled]) use_external_signer="yes"
else AC_DEFINE([ENABLE_EXTERNAL_SIGNER], [1], [Define if external signer support is enabled])
if test "$use_external_signer" = "yes"; then AC_DEFINE([BOOST_PROCESS_USE_STD_FS], [1], [Defined to avoid Boost::Process trying to use Boost Filesystem])
AC_MSG_ERROR([External signing is not supported for this Boost version]) else
fi if test "$use_external_signer" = "yes"; then
use_external_signer="no"; AC_MSG_ERROR([External signing is not supported for this Boost version])
fi fi
;; use_external_signer="no";
esac fi
fi fi
AM_CONDITIONAL([ENABLE_EXTERNAL_SIGNER], [test "$use_external_signer" = "yes"]) AM_CONDITIONAL([ENABLE_EXTERNAL_SIGNER], [test "$use_external_signer" = "yes"])

Loading…
Cancel
Save