build: Auto-detect whether -DBOOST_TEST_DYN_LINK is needed

Use AC_LINK_IFELSE to auto-detect whether boost test is linked
dynamically, instead of assuming based on target.
This commit is contained in:
Wladimir J. van der Laan 2014-01-16 11:55:54 +01:00
parent 417aad4a38
commit e4b991e56d

View File

@ -207,10 +207,8 @@ case $host in
fi fi
CPPFLAGS="$CPPFLAGS -DMAC_OSX" CPPFLAGS="$CPPFLAGS -DMAC_OSX"
TESTDEFS="-DBOOST_TEST_DYN_LINK"
;; ;;
*) *)
TESTDEFS="-DBOOST_TEST_DYN_LINK"
;; ;;
esac esac
@ -345,6 +343,24 @@ if test x$use_tests = xyes; then
AX_BOOST_UNIT_TEST_FRAMEWORK AX_BOOST_UNIT_TEST_FRAMEWORK
dnl Determine if -DBOOST_TEST_DYN_LINK is needed
AC_MSG_CHECKING([for dynamic linked boost test])
TEMP_LIBS="$LIBS"
LIBS="$LIBS $BOOST_UNIT_TEST_FRAMEWORK_LIB"
TEMP_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
AC_LINK_IFELSE([AC_LANG_SOURCE([
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MAIN
#include <boost/test/unit_test.hpp>
])],
[AC_MSG_RESULT(yes)]
[TESTDEFS="$TESTDEFS -DBOOST_TEST_DYN_LINK"],
[AC_MSG_RESULT(no)])
LIBS="$TEMP_LIBS"
CPPFLAGS="$TEMP_CPPFLAGS"
fi fi
BOOST_LIBS="$BOOST_LDFLAGS $BOOST_SYSTEM_LIB $BOOST_FILESYSTEM_LIB $BOOST_PROGRAM_OPTIONS_LIB $BOOST_THREAD_LIB" BOOST_LIBS="$BOOST_LDFLAGS $BOOST_SYSTEM_LIB $BOOST_FILESYSTEM_LIB $BOOST_PROGRAM_OPTIONS_LIB $BOOST_THREAD_LIB"