From 875b297278057f1b40c87ec1c3a532288e7a057d Mon Sep 17 00:00:00 2001 From: John Maguire Date: Mon, 26 Nov 2012 15:36:05 +0100 Subject: [PATCH] Check for lambda support before using it. --- CMakeLists.txt | 7 +++++++ src/config.h.in | 1 + tests/closure_test.cpp | 3 +++ 3 files changed, 11 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ec3230ba..f032e0a48 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,8 +25,15 @@ check_cxx_source_compiles( } " USE_STD_UNORDERED_MAP) +check_cxx_source_compiles( + "int main() { + [](){}(); + } + " + HAVE_LAMBDAS) unset(CMAKE_REQUIRED_FLAGS) + if (UNIX AND NOT APPLE) set(LINUX 1) endif (UNIX AND NOT APPLE) diff --git a/src/config.h.in b/src/config.h.in index 97e5803c1..7b85e6355 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -44,5 +44,6 @@ #cmakedefine USE_INSTALL_PREFIX #cmakedefine USE_SYSTEM_PROJECTM #cmakedefine USE_STD_UNORDERED_MAP +#cmakedefine HAVE_LAMBDAS #endif // CONFIG_H_IN diff --git a/tests/closure_test.cpp b/tests/closure_test.cpp index 486a6d75b..4a76dc0e2 100644 --- a/tests/closure_test.cpp +++ b/tests/closure_test.cpp @@ -5,6 +5,7 @@ #include #include +#include "config.h" #include "core/closure.h" #include "test_utils.h" @@ -63,6 +64,7 @@ TEST(ClosureTest, ClosureDoesNotCrashWithSharedPointerSender) { EXPECT_TRUE(closure.isNull()); } +#ifdef HAVE_LAMBDAS TEST(ClosureTest, ClosureCallsLambda) { TestQObject sender; bool called = false; @@ -73,3 +75,4 @@ TEST(ClosureTest, ClosureCallsLambda) { sender.Emit(); EXPECT_TRUE(called); } +#endif // HAVE_LAMBDAS