tests: fix 'make check' build for setups where no c++ compiler is available
authorTim-Philipp Müller <tim.muller@collabora.co.uk>
Thu, 23 Sep 2010 13:37:45 +0000 (14:37 +0100)
committerTim-Philipp Müller <tim.muller@collabora.co.uk>
Thu, 23 Sep 2010 13:41:27 +0000 (14:41 +0100)
Only try to build (pseudo-)C++ unit test if a working C++ compiler has been
found, otherwise the build will fail. (We do this to make sure our headers
are 'C++ clean').

configure.ac
tests/check/Makefile.am

index c434b09..be99576 100644 (file)
@@ -228,10 +228,15 @@ AM_PROG_CC_C_O
 dnl find an assembler
 AM_PROG_AS
 
-dnl determine c++ compiler
-AC_PROG_CXX
 dnl determine if c++ is available on this system
-AC_CHECK_PROG(HAVE_CXX, $CXX, yes, no)
+AC_PROG_CXX
+dnl CXX may be set to some default even if no c++ compiler is available
+dnl (thanks autotools!), so just try to compile some c++ code to make sure
+AC_LANG_PUSH([C++])
+AC_TRY_COMPILE([ class Foo { int bar; };], , working_cxx=yes, working_cxx=no)
+AC_LANG_POP([C++])
+AC_MSG_NOTICE([working c++ compiler found: $working_cxx])
+AM_CONDITIONAL(HAVE_CXX, test "x$working_cxx" == "xyes")
 
 dnl Perl is used in building documentation and in the version checks
 AC_PATH_PROG(PERL_PATH, perl, no)
index 26fe8a7..31db03d 100644 (file)
@@ -43,6 +43,11 @@ endif
 endif
 endif
 
+if HAVE_CXX
+CXX_CHECKS = gst/gstcpp
+else
+CXX_CHECKS =
+endif
 
 # if it's calling gst_element_factory_make(), it will probably not work without
 # a registry
@@ -89,7 +94,7 @@ check_PROGRAMS =                              \
        gst/gstbufferlist                       \
        gst/gstbus                              \
        gst/gstcaps                             \
-       gst/gstcpp                              \
+       $(CXX_CHECKS)                           \
        gst/gstdatetime                         \
        gst/gstinfo                             \
        gst/gstiterator                         \