-- didrik
dnl See whether $CXX supports flag in arg1.
dnl Set $2 to "yes" or "no" accordingly.
AC_DEFUN([TRY_COMPILER_FLAG], [
AC_MSG_CHECKING([whether $CXX supports $1])
save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS $1"
AC_LINK_IFELSE([int main(void){ return 0;} ],
[$2=yes],
[$2=no])
CXXFLAGS="$save_CXXFLAGS"
AC_MSG_RESULT([$[$2]])
])
Index: configure.ac
===================================================================
--- configure.ac (revision 336)
+++ configure.ac (working copy)
@@ -1,4 +1,5 @@
m4_include(m4/acx_pthread.m4)
+m4_include(m4/compiler_flags.m4)
# At this point, the Xcode project assumes the version string will be three
# integers separated by periods and surrounded by square brackets (e.g.
@@ -28,6 +29,14 @@
AC_LANG([C++])
AC_PROG_LIBTOOL
+# Check for some compiler flags.
+TRY_COMPILER_FLAG("-fexceptions", exceptions_flag)
+TRY_COMPILER_FLAG("-fno-exceptions", no_exceptions_flag)
+TRY_COMPILER_FLAG("-fno-rtti", no_rtti_flag)
+AM_CONDITIONAL([HAVE_EXCEPTIONS_FLAG], [test "$exceptions_flag" == "yes"])
+AM_CONDITIONAL([HAVE_NO_EXCEPTIONS_FLAG], [test "$no_exceptions_flag"
== "yes"])
+AM_CONDITIONAL([HAVE_NO_RTTI_FLAG], [test "$no_rtti_flag" == "yes"])
+
# TODO(chan...@google.com): Currently we aren't running the Python tests
# against the interpreter detected by AM_PATH_PYTHON, and so we condition
# HAVE_PYTHON by requiring "python" to be in the PATH, and that interpreter's
===================================================================
--- Makefile.am (revision 336)
+++ Makefile.am (working copy)
@@ -285,12 +285,14 @@
test_gtest_test_part_test_SOURCES = test/gtest-test-part_test.cc
test_gtest_test_part_test_LDADD = lib/libgtest_main.la
+if HAVE_EXCEPTIONS_FLAG
TESTS += test/gtest_throw_on_failure_ex_test
check_PROGRAMS += test/gtest_throw_on_failure_ex_test
test_gtest_throw_on_failure_ex_test_SOURCES = \
test/gtest_throw_on_failure_ex_test.cc \
src/gtest-all.cc
test_gtest_throw_on_failure_ex_test_CXXFLAGS = $(AM_CXXFLAGS) -fexceptions
+endif
TESTS += test/gtest-typed-test_test
check_PROGRAMS += test/gtest-typed-test_test
@@ -315,12 +317,14 @@
test_gtest_listener_test_LDADD = lib/libgtest_main.la
# Verifies that Google Test works when RTTI is disabled.
+if HAVE_NO_RTTI_FLAG
TESTS += test/gtest_no_rtti_test
check_PROGRAMS += test/gtest_no_rtti_test
test_gtest_no_rtti_test_SOURCES = test/gtest_unittest.cc \
src/gtest-all.cc \
src/gtest_main.cc
test_gtest_no_rtti_test_CXXFLAGS = $(AM_CXXFLAGS) -fno-rtti -DGTEST_HAS_RTTI=0
+endif
# Verifies that Google Test's own TR1 tuple implementation works.
TESTS += test/gtest-tuple_test
@@ -403,6 +407,7 @@
check_SCRIPTS += test/gtest_shuffle_test.py
TESTS += test/gtest_shuffle_test.py
+if HAVE_NO_EXCEPTIONS_FLAG
check_PROGRAMS += test/gtest_throw_on_failure_test_
test_gtest_throw_on_failure_test__SOURCES = \
test/gtest_throw_on_failure_test_.cc \
@@ -410,6 +415,7 @@
test_gtest_throw_on_failure_test__CXXFLAGS = $(AM_CXXFLAGS) -fno-exceptions
check_SCRIPTS += test/gtest_throw_on_failure_test.py
TESTS += test/gtest_throw_on_failure_test.py
+endif
check_PROGRAMS += test/gtest_uninitialized_test_
test_gtest_uninitialized_test__SOURCES = test/gtest_uninitialized_test_.cc
It should be fairly easy to extend my proposal to have a list of options to try,
and also to take input from the command line/environment.
-- didrik
Btw, is using autotools a 'must'. Can't we use something more 'modern' like CMake (http://www.cmake.org/)? I'll be more than happy to hack on it.