1 include(CheckCXXSourceCompiles)
2 MACRO(GMX_TEST_CXX11 VARIABLE FLAG)
3 IF(NOT DEFINED HAVE_${VARIABLE})
4 MESSAGE(STATUS "Checking for C++11 support")
6 set(CXX11_FLAG "-std=c++0x")
8 set(CXX11_FLAG "/Qstd=c++0x")
10 CHECK_CXX_COMPILER_FLAG("${CXX11_FLAG}" CXXFLAG_STD_CXX0X)
11 if(NOT CXXFLAG_STD_CXX0X)
14 set(CMAKE_REQUIRED_DEFINITIONS "${CXX11_FLAG}")
15 check_cxx_source_compiles(
20 A(int *i=NULL) : p(i) {} ;
21 std::unique_ptr<int> p;
24 typedef std::unique_ptr<int> intPointer;
25 intPointer p(new int(10));
26 std::vector<intPointer> v;
27 v.push_back(std::move(p));
29 v2.push_back(A()); //requires default move constructor
30 v2.push_back(A(new int(5))); //detects bug in ICC
32 set(CMAKE_REQUIRED_DEFINITIONS "")
34 set(${VARIABLE} 1 CACHE INTERNAL "Result of C++11 support test" FORCE)
35 set(${FLAG} ${CXX11_FLAG} CACHE INTERNAL "Compiler flag for C++11 support" FORCE)
36 MESSAGE(STATUS "Checking for C++11 support - yes")
38 set(${VARIABLE} 0 CACHE INTERNAL "Result of C++11 support test" FORCE)
39 set(${FLAG} "" CACHE INTERNAL "Compiler flag for C++11 support" FORCE)
40 MESSAGE(STATUS "Checking for C++11 support - no")
42 ENDIF(NOT DEFINED HAVE_${VARIABLE})