From 22ab47d3ee002c5f63dfad5428847e7cc61af39e Mon Sep 17 00:00:00 2001 From: Pauli Nieminen Date: Sun, 13 Jan 2008 19:22:09 +0000 Subject: [PATCH] Fixed boost test compilation with 1.34.1 --- changelog | 3 +++ configure.ac | 64 +++++++++++++++++++++++++++++++++++++++++++--- src/Makefile.am | 30 ++++++++++++++++------ src/tests/main.cpp | 7 +++-- 4 files changed, 91 insertions(+), 13 deletions(-) diff --git a/changelog b/changelog index 6c8a3579f82..414b4df9a33 100644 --- a/changelog +++ b/changelog @@ -1,6 +1,9 @@ Version 1.3.14+svn: * language and i18n: * updated translations: Dutch, Spanish + * miscellaneous and bug fixes: + * Fixed :control comamnd to work + * Fixed boost test compile with 1.34.1 Version 1.3.14: * campaigns: diff --git a/configure.ac b/configure.ac index be234f9c664..fd35762186c 100644 --- a/configure.ac +++ b/configure.ac @@ -76,10 +76,20 @@ else CXXFLAGS="-O2 -W -Wall -ansi $CXXFLAGS" fi + +# Make tests default in svn version +svn_in_version=`expr match "$WESNOTH_VERSION" '.*svn'` +test_build=yes +if test $svn_in_version == 0 +then + #disabling building tests for release version + test_build=no +fi + AC_ARG_ENABLE([tests], - AS_HELP_STRING([--enable-tests], [build unit tests]), + AS_HELP_STRING([--enable-tests], [build unit tests]), [tests=$enableval], - [tests=no]) + [tests=$test_build]) AC_ARG_ENABLE([static], AS_HELP_STRING([--enable-static], [enable static building of wesnoth]), @@ -885,14 +895,62 @@ CPPFLAGS="$BOOST_CPPFLAGS $CPPFLAGS" LDFLAGS="$BOOST_IOSTREAMS_LDFLAGS $LDFLAGS" LIBS="$BOOST_IOSTREAMS_LIBS $LIBS" -if test "x$tests" = "xyes"; then +if test "x$tests" = "xyes"; then + BOOST_TEST LDFLAGS="$BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS $LDFLAGS" LIBS="$BOOST_UNIT_TEST_FRAMEWORK_LIBS $LIBS" + AC_LANG([C++]) + AC_MSG_CHECKING([for dynamic linked boost test]) + + OLD_CPPFLAGS=$CPPFLAGS + OLD_CFLAGS=$CFLAGS + OLD_LIBS=$LIBS + + + CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" + CFLAGS="$CFLAGS $BOOST_CPPFLAGS" + LIBS="$LIBS $BOOST_UNIT_TEST_FRAMEWORK_LIBS" + + ac_link="$LDPREFIX $ac_link" + AC_LINK_IFELSE([AC_LANG_SOURCE([ + #define BOOST_TEST_DYN_LINK + #define BOOST_TEST_MAIN + #include + + ])], + [AC_MSG_RESULT(yes)] + [boost_test_dyn_link=yes], + [AC_MSG_RESULT(no)] + [boost_test_dyn_link=no]) + + AC_MSG_CHECKING([for boost auto test not in core]) + + AC_LINK_IFELSE([AC_LANG_SOURCE([ + #define BOOST_AUTO_TEST_MAIN + #include + + ])], + [AC_MSG_RESULT(yes)] + [boost_auto_test=yes], + [AC_MSG_RESULT(no)] + [boost_auto_test=no]) + + + CPPFLAGS=$OLD_CPPFLAGS + CFLAGS=$OLD_CFLAGS + LIBS=$OLD_LIBS + fi +m4_pattern_allow([^BOOST_TEST_DYN_LINK$]) +m4_pattern_allow([^BOOST_AUTO_TEST$]) + +AM_CONDITIONAL([BOOST_TEST_DYN_LINK], [test x"$boost_test_dyn_link" = xyes]) +AM_CONDITIONAL([BOOST_AUTO_TEST], [test x"$boost_auto_test" = xyes]) + ####################################################################### # Tune gettext stuff for our needs # ####################################################################### diff --git a/src/Makefile.am b/src/Makefile.am index 26ccb2f7bb2..6ca51b59878 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -44,11 +44,7 @@ pkgdatadir=$(datadir)/@DATADIR@ THELIBS = -L. -lwesnoth-core $(SDL_IMAGE_LIBS) $(SDL_MIXER_LIBS) $(SDL_NET_LIBS) \ $(SDL_TTF_LIBS) $(SDL_LIBS) $(PYTHON_LIBS) $(FREETYPE_LIBS) $(LIBINTL) -############################################################################# -# Wesnoth # -############################################################################# - -wesnoth_SOURCES = \ +wesnoth_source = \ about.cpp \ actions.cpp \ ai.cpp \ @@ -62,7 +58,6 @@ wesnoth_SOURCES = \ config_adapter.cpp \ dialogs.cpp \ floating_textbox.cpp \ - game.cpp \ game_display.cpp \ game_events.cpp \ game_preferences.cpp \ @@ -112,6 +107,14 @@ wesnoth_SOURCES = \ widgets/combo.cpp \ widgets/scrollpane.cpp +############################################################################# +# Wesnoth # +############################################################################# + +wesnoth_SOURCES = \ + $(wesnoth_source) \ + game.cpp + wesnoth_LDADD = $(THELIBS) libwesnoth.a wesnoth_DEPENDENCIES=libwesnoth-core.a libwesnoth.a @@ -199,11 +202,12 @@ cutter_DEPENDENCIES=libwesnoth-core.a ############################################################################# test_SOURCES = \ + $(wesnoth_source) \ tests/main.cpp \ tests/test_util.cpp -test_LDADD = -L. -lwesnoth-core -lboost_unit_test_framework @SDL_IMAGE_LIBS@ @SDL_LIBS@ $(LIBINTL) $(PNG_LIBS) -test_DEPENDENCIES=libwesnoth-core.a +test_LDADD = -lboost_unit_test_framework $(THELIBS) libwesnoth.a +test_DEPENDENCIES=libwesnoth-core.a libwesnoth.a ############################################################################# # Headers @@ -472,6 +476,16 @@ if PREFSDIR CXXFLAGS += -DPREFERENCES_DIR=\"$(prefsdir)\" endif +if BOOST_TEST_DYN_LINK + CXXFLAGS += -DBOOST_TEST_DYN_LINK +endif + +if BOOST_AUTO_TEST + CXXFLAGS += -DBOOST_AUTO_TEST_MAIN +else + CXXFLAGS += -DBOOST_TEST_MAIN +endif + CXXLD = $(LDPREFIX) $(CXX) diff --git a/src/tests/main.cpp b/src/tests/main.cpp index ff96bcdbe4e..fea69690208 100644 --- a/src/tests/main.cpp +++ b/src/tests/main.cpp @@ -11,8 +11,11 @@ See the COPYING file for more details. */ -#define BOOST_AUTO_TEST_MAIN -#include +#ifdef BOOST_AUTO_TEST_MAIN + #include +#else + #include +#endif /* * This is a main compilation unit for the test program.