You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ax_boost_unit_test_framework.m4 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. # ================================================================================
  2. # http://www.gnu.org/software/autoconf-archive/ax_boost_unit_test_framework.html
  3. # ================================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_BOOST_UNIT_TEST_FRAMEWORK
  8. #
  9. # DESCRIPTION
  10. #
  11. # Test for Unit_Test_Framework library from the Boost C++ libraries. The
  12. # macro requires a preceding call to AX_BOOST_BASE. Further documentation
  13. # is available at <http://randspringer.de/boost/index.html>.
  14. #
  15. # This macro calls:
  16. #
  17. # AC_SUBST(BOOST_UNIT_TEST_FRAMEWORK_LIB)
  18. #
  19. # And sets:
  20. #
  21. # HAVE_BOOST_UNIT_TEST_FRAMEWORK
  22. #
  23. # LICENSE
  24. #
  25. # Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
  26. #
  27. # Copying and distribution of this file, with or without modification, are
  28. # permitted in any medium without royalty provided the copyright notice
  29. # and this notice are preserved. This file is offered as-is, without any
  30. # warranty.
  31. #serial 19
  32. AC_DEFUN([AX_BOOST_UNIT_TEST_FRAMEWORK],
  33. [
  34. AC_ARG_WITH([boost-unit-test-framework],
  35. AS_HELP_STRING([--with-boost-unit-test-framework@<:@=special-lib@:>@],
  36. [use the Unit_Test_Framework library from boost - it is possible to specify a certain library for the linker
  37. e.g. --with-boost-unit-test-framework=boost_unit_test_framework-gcc ]),
  38. [
  39. if test "$withval" = "no"; then
  40. want_boost="no"
  41. elif test "$withval" = "yes"; then
  42. want_boost="yes"
  43. ax_boost_user_unit_test_framework_lib=""
  44. else
  45. want_boost="yes"
  46. ax_boost_user_unit_test_framework_lib="$withval"
  47. fi
  48. ],
  49. [want_boost="yes"]
  50. )
  51. if test "x$want_boost" = "xyes"; then
  52. AC_REQUIRE([AC_PROG_CC])
  53. CPPFLAGS_SAVED="$CPPFLAGS"
  54. CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
  55. export CPPFLAGS
  56. LDFLAGS_SAVED="$LDFLAGS"
  57. LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
  58. export LDFLAGS
  59. AC_CACHE_CHECK(whether the Boost::Unit_Test_Framework library is available,
  60. ax_cv_boost_unit_test_framework,
  61. [AC_LANG_PUSH([C++])
  62. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <boost/test/unit_test.hpp>]],
  63. [[using boost::unit_test::test_suite;
  64. test_suite* test= BOOST_TEST_SUITE( "Unit test example 1" ); return 0;]])],
  65. ax_cv_boost_unit_test_framework=yes, ax_cv_boost_unit_test_framework=no)
  66. AC_LANG_POP([C++])
  67. ])
  68. if test "x$ax_cv_boost_unit_test_framework" = "xyes"; then
  69. AC_DEFINE(HAVE_BOOST_UNIT_TEST_FRAMEWORK,,[define if the Boost::Unit_Test_Framework library is available])
  70. BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
  71. if test "x$ax_boost_user_unit_test_framework_lib" = "x"; then
  72. saved_ldflags="${LDFLAGS}"
  73. ax_lib=
  74. for monitor_library in `ls $BOOSTLIBDIR/libboost_unit_test_framework*.so* $BOOSTLIBDIR/libboost_unit_test_framework*.dylib* $BOOSTLIBDIR/libboost_unit_test_framework*.a* 2>/dev/null` ; do
  75. if test -r $monitor_library ; then
  76. libextension=`echo $monitor_library | sed 's,.*/,,' | sed -e 's;^lib\(boost_unit_test_framework.*\)\.so.*$;\1;' -e 's;^lib\(boost_unit_test_framework.*\)\.dylib.*$;\1;' -e 's;^lib\(boost_unit_test_framework.*\)\.a.*$;\1;'`
  77. ax_lib=${libextension}
  78. link_unit_test_framework="yes"
  79. else
  80. link_unit_test_framework="no"
  81. fi
  82. if test "x$link_unit_test_framework" = "xyes"; then
  83. BOOST_UNIT_TEST_FRAMEWORK_LIB="-l$ax_lib"
  84. AC_SUBST(BOOST_UNIT_TEST_FRAMEWORK_LIB)
  85. break
  86. fi
  87. done
  88. if test "x$link_unit_test_framework" != "xyes"; then
  89. for libextension in `ls $BOOSTLIBDIR/boost_unit_test_framework*.dll* $BOOSTLIBDIR/boost_unit_test_framework*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_unit_test_framework.*\)\.dll.*$;\1;' -e 's;^\(boost_unit_test_framework.*\)\.a.*$;\1;'` ; do
  90. ax_lib=${libextension}
  91. AC_CHECK_LIB($ax_lib, exit,
  92. [BOOST_UNIT_TEST_FRAMEWORK_LIB="-l$ax_lib"; AC_SUBST(BOOST_UNIT_TEST_FRAMEWORK_LIB) link_unit_test_framework="yes"; break],
  93. [link_unit_test_framework="no"])
  94. done
  95. fi
  96. else
  97. link_unit_test_framework="no"
  98. saved_ldflags="${LDFLAGS}"
  99. for ax_lib in boost_unit_test_framework-$ax_boost_user_unit_test_framework_lib $ax_boost_user_unit_test_framework_lib ; do
  100. if test "x$link_unit_test_framework" = "xyes"; then
  101. break;
  102. fi
  103. for unittest_library in `ls $BOOSTLIBDIR/lib${ax_lib}.so* $BOOSTLIBDIR/lib${ax_lib}.a* 2>/dev/null` ; do
  104. if test -r $unittest_library ; then
  105. libextension=`echo $unittest_library | sed 's,.*/,,' | sed -e 's;^lib\(boost_unit_test_framework.*\)\.so.*$;\1;' -e 's;^lib\(boost_unit_test_framework.*\)\.a*$;\1;'`
  106. ax_lib=${libextension}
  107. link_unit_test_framework="yes"
  108. else
  109. link_unit_test_framework="no"
  110. fi
  111. if test "x$link_unit_test_framework" = "xyes"; then
  112. BOOST_UNIT_TEST_FRAMEWORK_LIB="-l$ax_lib"
  113. AC_SUBST(BOOST_UNIT_TEST_FRAMEWORK_LIB)
  114. break
  115. fi
  116. done
  117. done
  118. fi
  119. if test "x$ax_lib" = "x"; then
  120. AC_MSG_ERROR(Could not find a version of the boost_unit_test_framework library!)
  121. fi
  122. if test "x$link_unit_test_framework" != "xyes"; then
  123. AC_MSG_ERROR(Could not link against $ax_lib !)
  124. fi
  125. fi
  126. CPPFLAGS="$CPPFLAGS_SAVED"
  127. LDFLAGS="$LDFLAGS_SAVED"
  128. fi
  129. ])