Check for lambda support before using it.

This commit is contained in:
John Maguire 2012-11-26 15:36:05 +01:00
parent 303ef3ce2f
commit 875b297278
3 changed files with 11 additions and 0 deletions

View File

@ -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)

View File

@ -44,5 +44,6 @@
#cmakedefine USE_INSTALL_PREFIX
#cmakedefine USE_SYSTEM_PROJECTM
#cmakedefine USE_STD_UNORDERED_MAP
#cmakedefine HAVE_LAMBDAS
#endif // CONFIG_H_IN

View File

@ -5,6 +5,7 @@
#include <QSharedPointer>
#include <QSignalSpy>
#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