tests: C++ compilation test
authorMariusz Ceier <mceier+wayland@gmail.com>
Mon, 15 Dec 2014 10:33:53 +0000 (11:33 +0100)
committerDaniel Stone <daniels@collabora.com>
Tue, 27 Jan 2015 11:17:42 +0000 (11:17 +0000)
This test includes one of wayland headers, which produced
error with C++ compiler. C compiler can't be used for this test,
because it issues only a warning[1] and only when wayland headers
are not installed in system headers path (/usr/include).

[1] wayland-server-protocol.h:201:2: warning: implicit declaration of function ‘wl_resource_post_event’

[daniels: Merged in Marek's follow-up to check for a C++ compiler.]

Signed-off-by: Mariusz Ceier <mceier+wayland@gmail.com>
Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Makefile.am
configure.ac
tests/cpp-compile-test.cpp [new file with mode: 0644]

index 1551762..43b741a 100644 (file)
@@ -130,6 +130,10 @@ TESTS =                                            \
        resources-test                          \
        message-test
 
+if ENABLE_CPP_TEST
+TESTS += cpp-compile-test
+endif
+
 check_PROGRAMS =                               \
        $(TESTS)                                \
        exec-fd-leak-checker
@@ -181,6 +185,10 @@ resources_test_LDADD = libtest-runner.la
 message_test_SOURCES = tests/message-test.c
 message_test_LDADD = libtest-runner.la
 
+if ENABLE_CPP_TEST
+cpp_compile_test_SOURCES = tests/cpp-compile-test.cpp
+endif
+
 fixed_benchmark_SOURCES = tests/fixed-benchmark.c
 fixed_benchmark_LDADD = libtest-runner.la
 
index 0249002..e749b00 100644 (file)
@@ -26,6 +26,18 @@ AM_SILENT_RULES([yes])
 
 # Check for programs
 AC_PROG_CC
+AC_PROG_CXX
+
+# check if we have C++ compiler. This is hacky workaround,
+# for a reason why it is this way see
+# http://lists.gnu.org/archive/html/bug-autoconf/2010-05/msg00001.html
+have_cpp_compiler=yes
+
+if ! which "$CXX" &>/dev/null; then
+       have_cpp_compiler=no
+fi
+
+AM_CONDITIONAL(ENABLE_CPP_TEST, test "x$have_cpp_compiler" = "xyes")
 
 # Initialize libtool
 LT_PREREQ([2.2])
diff --git a/tests/cpp-compile-test.cpp b/tests/cpp-compile-test.cpp
new file mode 100644 (file)
index 0000000..1e84e63
--- /dev/null
@@ -0,0 +1,5 @@
+/* This source should compile fine with C++ compiler */
+#include "wayland-server-protocol.h"
+
+int main() { return 0; }
+