[RFC wayland] cpp-test: check for C++ compiler

Marek Chalupa mchqwerty at gmail.com
Fri Dec 19 08:40:50 PST 2014


Do not try to build it if no C++ compiler is present

Signed-off-by: Marek Chalupa <mchqwerty at gmail.com>
---
 Makefile.am  | 10 ++++++++--
 configure.ac | 13 ++++++++++++-
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index ea9ffc1..43b741a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -128,8 +128,11 @@ TESTS =						\
 	queue-test				\
 	signal-test				\
 	resources-test				\
-	message-test    \
-	cpp-compile-test
+	message-test
+
+if ENABLE_CPP_TEST
+TESTS += cpp-compile-test
+endif
 
 check_PROGRAMS =				\
 	$(TESTS)				\
@@ -181,7 +184,10 @@ resources_test_SOURCES = tests/resources-test.c
 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
diff --git a/configure.ac b/configure.ac
index a5f7e61..0822d39 100644
--- a/configure.ac
+++ b/configure.ac
@@ -25,8 +25,19 @@ AM_INIT_AUTOMAKE([1.11 foreign no-dist-gzip dist-xz subdir-objects])
 AM_SILENT_RULES([yes])
 
 # Check for programs
-AC_PROG_CXX
 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])
-- 
2.1.0



More information about the wayland-devel mailing list