Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-fatal Boost detection failures #36

Open
mdeters opened this issue Oct 24, 2012 · 1 comment
Open

Non-fatal Boost detection failures #36

mdeters opened this issue Oct 24, 2012 · 1 comment

Comments

@mdeters
Copy link

mdeters commented Oct 24, 2012

We want to provide support for conditional Boost support---in particular, we require Boost for one of our projects, but Boost threading is optionally supported. To support this, we've modified boost.m4's BOOST_FIND_LIB and BOOST_THREADS to run an optionally-provided ACTION-IF-NOT-FOUND (if not provided, the usual AC_MSG_ERROR behavior is retained). Patch follows in a comment. Thanks!

@mdeters
Copy link
Author

mdeters commented Oct 24, 2012

diff --git a/build-aux/boost.m4 b/build-aux/boost.m4
index 3d4e47c..6252f96 100644
--- a/build-aux/boost.m4
+++ b/build-aux/boost.m4
@@ -265,13 +265,14 @@ fi

BOOST_FIND_LIB([LIB-NAME], [PREFERRED-RT-OPT], [HEADER-NAME], [CXX-TEST],

-# [CXX-PROLOGUE])
+# [CXX-PROLOGUE], [ACTION-IF-NOT-FOUND])

-------------------------------------------------------------------------

Look for the Boost library LIB-NAME (e.g., LIB-NAME = `thread', for

libboost_thread). Check that HEADER-NAME works and check that

libboost_LIB-NAME can link with the code CXX-TEST. The optional argument

CXX-PROLOGUE can be used to include some C++ code before the`main'

-# function.
+# function. If ACTION-IF-NOT-FOUND is given, errors are nonfatal (otherwise
+# they are fatal).

Invokes BOOST_FIND_HEADER([HEADER-NAME]) (see above).

@@ -299,7 +300,7 @@ AS_VAR_PUSHDEF([Boost_lib], [boost_cv_lib_$1])dnl
AS_VAR_PUSHDEF([Boost_lib_LDFLAGS], [boost_cv_lib_$1_LDFLAGS])dnl
AS_VAR_PUSHDEF([Boost_lib_LDPATH], [boost_cv_lib_$1_LDPATH])dnl
AS_VAR_PUSHDEF([Boost_lib_LIBS], [boost_cv_lib_$1_LIBS])dnl
-BOOST_FIND_HEADER([$3])
+BOOST_FIND_HEADER([$3], [$6])
boost_save_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"

Now let's try to find the library. The algorithm is as follows: first look

@@ -355,7 +356,9 @@ dnl empty because the test file is generated only once above (before we
dnl start the for loops).
AC_COMPILE_IFELSE([],
[ac_objext=do_not_rm_me_plz],

  • [AC_MSG_ERROR([cannot compile a test that uses Boost $1])])
  • [m4_if([$6], [], [AC_MSG_ERROR([cannot compile a test that uses Boost $1])],
  •                  [AC_MSG_NOTICE([cannot compile a test that uses Boost $1])])
    
  • $6])
    
    ac_objext=$boost_save_ac_objext
    boost_failed_libs=

    Don't bother to ident the 6 nested for loops, only the 2 innermost ones

    @@ -419,7 +422,9 @@ rm -f conftest.$ac_objext
    ])
    case $Boost_lib in #(
    no) _AC_MSG_LOG_CONFTEST
  • AC_MSG_ERROR([cannot find the flags to link with Boost $1])
  • m4_if([$6], [], [AC_MSG_ERROR([cannot find the flags to link with Boost $1])],
  •                [AC_MSG_NOTICE([cannot find the flags to link with Boost $1])])
    
  • $6
    ;;
    esac
    AC_SUBST(AS_TR_CPP([BOOST_$1_LDFLAGS]), [$Boost_lib_LDFLAGS])dnl
    @@ -825,10 +830,11 @@ BOOST_FIND_LIB([unit_test_framework], [$1],
    ])# BOOST_TEST

-# BOOST_THREADS([PREFERRED-RT-OPT])
-# ---------------------------------
+# BOOST_THREADS([PREFERRED-RT-OPT], [ACTION-IF-NOT-FOUND])
+# --------------------------------------------------------

Look for Boost.Thread. For the documentation of PREFERRED-RT-OPT, see the

-# documentation of BOOST_FIND_LIB above.
+# documentation of BOOST_FIND_LIB above. If ACTION-IF-NOT-FOUND is given,
+# errors are non-fatal; if it's absent, errors are fatal.

FIXME: Provide an alias "BOOST_THREAD".

BOOST_DEFUN([Threads],
[dnl Having the pthread flag is required at least on GCC3 where
@@ -857,14 +863,14 @@ CPPFLAGS="$CPPFLAGS $boost_cv_pthread_flag"
case $host_os in
(mingw)
BOOST_FIND_LIB([thread_win32], [$1],

  •               [boost/thread.hpp], [boost::thread t; boost::mutex m;])
    
  •               [boost/thread.hpp], [boost::thread t; boost::mutex m;], [], [$2])
    
    BOOST_THREAD_LDFLAGS=$BOOST_THREAD_WIN32_LDFLAGS
    BOOST_THREAD_LDPATH=$BOOST_THREAD_WIN32_LDPATH
    BOOST_THREAD_LIBS=$BOOST_THREAD_WIN32_LIBS
    ;;
    (*)
    BOOST_FIND_LIB([thread], [$1],
  •               [boost/thread.hpp], [boost::thread t; boost::mutex m;])
    
  •               [boost/thread.hpp], [boost::thread t; boost::mutex m;], [], [$2])
    
    ;;
    esac

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant