[geos-devel] First glance at the Unit Test

Mark Coletti mcoletti at gmail.com
Mon Mar 6 17:10:54 EST 2006


On 3/6/06, strk at refractions.net <strk at refractions.net> wrote:
>
> Does anybody have an m4 file that can be used
> to detect availability of boost ?
>
> I've found some online, but they don't seem to be checking
> for the UTF library.


Here're some of mine that I use; feel free to hack to fit:

------------------------------->8 snip
8<-----------------------------------------

dnl
dnl Look for the Boost C++ class template header files
dnl

AC_ARG_WITH( [boost],
             AC_HELP_STRING([--with-boost=path],[path to Boost C++ class
library headers]),
             BOOST_PATH="$withval" )

if ! test -z "$BOOST_PATH" ; then
  CPPFLAGS="$CPPFLAGS -I${BOOST_PATH}"
fi


AC_CHECK_HEADERS([boost/smart_ptr.hpp],,
         AC_MSG_ERROR([No Boost C++ library -- get from
http://www.boost.org/]))


dnl
dnl NOw look for Boost binaries, such as the boost date/time stuff
dnl

AC_ARG_WITH( [boost-lib],
             AC_HELP_STRING([--with-boost-lib=path],
                [path to Boost C++ class library librarys]),
              [BOOST_LDPATH="$withval"] )

if test ! -z "$BOOST_LDPATH" ; then
  LIBS="$LIBS -L$BOOST_LDPATH"
fi

dnl find Boost library names
dnl AC_SEARCH_LIBS( [_init],
dnl         [libboost_date_time, libboost_date_time-gcc],
dnl         [],
dnl         AC_MSG_ERROR([Unable to find Boost date library]) )


dnl AC_SEARCH_LIBS( [boost::c_regex_traits<char>::init()],
dnl         [libboost_regex libboost_regex-gcc],
dnl         [],
dnl         AC_MSG_ERROR([Unable to find Boost regex library]) )



AC_LIB_HAVE_LINKFLAGS( boost_date_time,,
[
#include <boost/date_time/gregorian/gregorian.hpp>
#include <boost/date_time/date_parsing.hpp>
#include <iostream>
#include <string>
],
[boost::gregorian::date d(boost::gregorian::from_string("2001-10-9"));] )

dnl failing the previous, try the common name variant
if test x${HAVE_LIBBOOST_DATE_TIME} = "xno"; then

AC_LIB_HAVE_LINKFLAGS( boost_date_time-gcc,,
[
#include <boost/date_time/gregorian/gregorian.hpp>
#include <boost/date_time/date_parsing.hpp>
#include <iostream>
#include <string>
],
[boost::gregorian::date d(boost::gregorian::from_string("2001-10-9"));] )

dnl substitute back canonical name (i.e., without gcc suffix)
LIBBOOST_DATE_TIME=${LIBBOOST_DATE_TIME_GCC}
LTLIBBOOST_DATE_TIME=${LTLIBBOOST_DATE_TIME_GCC}
HAVE_LIBBOOST_DATE_TIME=${HAVE_LIBBOOST_DATE_TIME_GCC}

dnl note that these will be 'no' or blank if even the "-gcc" suffix failed

fi


AC_LIB_HAVE_LINKFLAGS( boost_test_exec_monitor, ,
[
  #include <boost/test/test_tools.hpp>
  int test_main( int, char* [] )
  {
    int i = 2;
    int j = 1;
    BOOST_CHECK_EQUAL( i, j );

    return 0;
  }
],
[] )


dnl failing the previous, try the common name variant
if test x${HAVE_LIBBOOST_TEST_EXEC_MONITOR} = "xno"; then


AC_LIB_HAVE_LINKFLAGS( boost_test_exec_monitor-gcc, ,
[
  #include <boost/test/test_tools.hpp>
  int test_main( int, char* [] )
  {
    int i = 2;
    int j = 1;
    BOOST_CHECK_EQUAL( i, j );

    return 0;
  }
],
[] )

dnl substitute back canonical name (i.e., without gcc suffix)
LIBBOOST_TEST_EXEC_MONITOR=$LIBBOOST_TEST_EXEC_MONITOR_GCC
LTLIBBOOST_TEST_EXEC_MONITOR=$LTLIBBOOST_TEST_EXEC_MONITOR_GCC
HAVE_LIBBOOST_TEST_EXEC_MONITOR=$HAVE_LIBBOOST_TEST_EXEC_MONITOR_GCC

dnl note that these will be 'no' or blank if even the "-gcc" suffix failed


fi


AC_LIB_HAVE_LINKFLAGS( boost_filesystem, ,
[
  #include <boost/filesystem/path.hpp>
],
[boost::filesystem::path myPath("somedir/file.txt");] )


dnl failing the previous, try the common name variant
if test x${HAVE_LIBBOOST_FILESYSTEM} = "xno"; then


AC_LIB_HAVE_LINKFLAGS( boost_filesystem-gcc, ,
[
  #include <boost/filesystem/path.hpp>
],
[boost::filesystem::path myPath("somedir/file.txt");] )

dnl substitute back canonical name (i.e., without gcc suffix)
LIBBOOST_FILESYSTEM=${LIBBOOST_FILESYSTEM_GCC}
LTLIBBOOST_FILESYSTEM=${LTLIBBOOST_FILESYSTEM_GCC}
HAVE_LIBBOOST_FILESYSTEM=${HAVE_LIBBOOST_FILESYSTEM_GCC}

dnl note that these will be 'no' or blank if even the "-gcc" suffix failed


fi


AC_LIB_HAVE_LINKFLAGS( boost_regex,,
[
#include <boost/regex.hpp>
#include <string>
],
[static const boost::regex e("(\\d{4}[- ]){3}\\d{4}");] )

dnl failing the previous, try the common name variant
if test x${HAVE_LIBBOOST_REGEX} = "xno"; then

AC_LIB_HAVE_LINKFLAGS( boost_regex-gcc,,
[
#include <boost/regex.hpp>
#include <string>
],
[static const boost::regex e("(\\d{4}[- ]){3}\\d{4}");] )

dnl substitute back canonical name (i.e., without gcc suffix)
LIBBOOST_REGEX=${LIBBOOST_REGEX_GCC}
LTLIBBOOST_REGEX=${LTLIBBOOST_REGEX_GCC}
HAVE_LIBBOOST_REGEX=${HAVE_LIBBOOST_REGEX_GCC}

dnl note that these will be 'no' or blank if even the "-gcc" suffix failed

fi
------------------------------->8 snip
8<-----------------------------------------

Admittedly these check for other boost items, so you may want to snip out
all but the unit test stuff.  Note, too, that BOOST_PATH and BOOST_LDPATH
are set after a successful invocation of the configure script.  So I have
things like this in my Makefile.am files:


INCLUDES = -I.. -I$(top_srcdir)/featurelib -I$(includedir) -I$(BOOST_PATH)
$(GDAL_CFLAGS)

schema_type_t_SOURCES      = schema_type_t.cpp
schema_type_t_LDADD        = ../featurelib/SchemaType.o
$(LIBBOOST_TEST_EXEC_MONITOR)



Hope this helps!

Cheers,

Mark
--
I'm taking reality in small doses to build immunity.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/geos-devel/attachments/20060306/9410cf44/attachment.html


More information about the geos-devel mailing list