aboutsummaryrefslogtreecommitdiffstats
path: root/cmake/cmake-cxx11/Tests/Module
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/cmake-cxx11/Tests/Module')
-rw-r--r--cmake/cmake-cxx11/Tests/Module/CXX11Features/CMakeLists.txt33
-rw-r--r--cmake/cmake-cxx11/Tests/Module/CXX11Features/cxx11features.cxx57
2 files changed, 90 insertions, 0 deletions
diff --git a/cmake/cmake-cxx11/Tests/Module/CXX11Features/CMakeLists.txt b/cmake/cmake-cxx11/Tests/Module/CXX11Features/CMakeLists.txt
new file mode 100644
index 00000000..f117eb16
--- /dev/null
+++ b/cmake/cmake-cxx11/Tests/Module/CXX11Features/CMakeLists.txt
@@ -0,0 +1,33 @@
+cmake_minimum_required(VERSION 2.8.3 FATAL_ERROR)
+project(Cxx11Features CXX)
+
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../Modules")
+
+include(CheckCXX11Features)
+
+foreach (flag IN ITEMS
+ HAS_CXX11_AUTO
+ HAS_CXX11_AUTO_RET_TYPE
+ HAS_CXX11_CLASS_OVERRIDE
+ HAS_CXX11_CONSTEXPR
+ HAS_CXX11_CSTDINT_H
+ HAS_CXX11_DECLTYPE
+ HAS_CXX11_FUNC
+ HAS_CXX11_INITIALIZER_LIST
+ HAS_CXX11_LAMBDA
+ HAS_CXX11_LIB_REGEX
+ HAS_CXX11_LONG_LONG
+ HAS_CXX11_NULLPTR
+ HAS_CXX11_RVALUE_REFERENCES
+ HAS_CXX11_SIZEOF_MEMBER
+ HAS_CXX11_STATIC_ASSERT
+ HAS_CXX11_VARIADIC_TEMPLATES
+ )
+ if (${flag})
+ add_definitions("-D${flag}")
+ message(STATUS "Compiler C++11 support flag ${flag} set")
+ endif ()
+endforeach (flag)
+
+set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${CXX11_COMPILER_FLAGS})
+add_executable(CXX11Features cxx11features.cxx)
diff --git a/cmake/cmake-cxx11/Tests/Module/CXX11Features/cxx11features.cxx b/cmake/cmake-cxx11/Tests/Module/CXX11Features/cxx11features.cxx
new file mode 100644
index 00000000..c09038fb
--- /dev/null
+++ b/cmake/cmake-cxx11/Tests/Module/CXX11Features/cxx11features.cxx
@@ -0,0 +1,57 @@
+#if defined(HAS_CXX0X_CSTDINT_H)
+#include <cstdint>
+#endif
+
+#include <sys/types.h>
+
+struct thing {
+ unsigned char one;
+#if defined(HAS_CXX0X_CSTDINT_H)
+ uint32_t four;
+#endif
+#if defined(HAS_CXX0X_LONG_LONG)
+ long long eight;
+#endif
+};
+
+#include <stdio.h>
+
+int main()
+{
+#if defined (HAS_CXX0X_NULLPTR)
+ void *nix = nullptr;
+#else /* HAS_CXX0X_NULLPTR */
+ void *nix = 0;
+#endif /* HAS_CXX0X_NULLPTR */
+
+#if defined(HAS_CXX0X_STATIC_ASSERT)
+ static_assert(1 < 42, "Your C++ compiler is b0rked");
+#endif /* HAS_CXX0X_STATIC_ASSERT */
+
+#if defined(HAS_CXX0X_FUNC)
+ const char *funcname = __func__;
+ printf("the name of main() function is: %s\n", funcname);
+#endif /* HAS_CXX0X_FUNC */
+
+#if defined(HAS_CXX0X_SIZEOF_MEMBER)
+ size_t onesize = sizeof(thing::one);
+#if defined(HAS_CXX0X_STATIC_ASSERT)
+ static_assert(sizeof(thing::one) == 1, "Your char is not one byte long");
+#endif /* HAS_CXX0X_STATIC_ASSERT */
+
+#if defined(HAS_CXX0X_CSTDINT_H)
+ size_t foursize = sizeof(thing::four);
+#if defined(HAS_CXX0X_STATIC_ASSERT)
+ static_assert(sizeof(thing::four) == 4, "Your uint32_t is not 32 bit long");
+#endif /* HAS_CXX0X_STATIC_ASSERT */
+#endif /* HAS_CXX0X_CSTDINT_H */
+#if defined(HAS_CXX0X_LONG_LONG)
+ size_t eightsize = sizeof(thing::eight);
+#if defined(HAS_CXX0X_STATIC_ASSERT)
+ static_assert(sizeof(thing::eight) == 8, "Your long long is not 64 bit long");
+#endif /* HAS_CXX0X_STATIC_ASSERT */
+#endif /* HAS_CXX0X_LONG_LONG */
+#endif /* HAS_CXX0X_SIZEOF_MEMBER */
+
+ return 0;
+}