Thu, 22 Aug 2013 20:24:16 +0300
Changed build system from qmake to CMake.
473
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | # Checks for C++11 features |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | # CXX11_FEATURE_LIST - a list containing all supported features |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
3 | # HAS_CXX11_AUTO - auto keyword |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
4 | # HAS_CXX11_NULLPTR - nullptr |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | # HAS_CXX11_LAMBDA - lambdas |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | # HAS_CXX11_STATIC_ASSERT - static_assert() |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | # HAS_CXX11_RVALUE_REFERENCES - rvalue references |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | # HAS_CXX11_DECLTYPE - decltype keyword |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | # HAS_CXX11_CSTDINT_H - cstdint header |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | # HAS_CXX11_LONG_LONG - long long signed & unsigned types |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | # HAS_CXX11_VARIADIC_TEMPLATES - variadic templates |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | # HAS_CXX11_CONSTEXPR - constexpr keyword |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | # HAS_CXX11_SIZEOF_MEMBER - sizeof() non-static members |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | # HAS_CXX11_FUNC - __func__ preprocessor constant |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | # |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | # Original script by Rolf Eike Beer |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | # Modifications by Andreas Weis |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | # |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | CMAKE_MINIMUM_REQUIRED(VERSION 2.8.3) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
21 | SET(CHECK_CXX11_OLD_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
22 | IF(CMAKE_COMPILER_IS_GNUCXX) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | SET(CMAKE_CXX_FLAGS "-std=c++0x") |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
24 | endif() |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | MACRO(CXX11_CHECK_FEATURE FEATURE_NAME FEATURE_NUMBER RESULT_VAR) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
27 | IF (NOT DEFINED ${RESULT_VAR}) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
28 | SET(_bindir "${CMAKE_CURRENT_BINARY_DIR}/cxx11/cxx11_${FEATURE_NAME}") |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
29 | |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
30 | IF (${FEATURE_NUMBER}) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
31 | SET(_SRCFILE_BASE ${CMAKE_CURRENT_LIST_DIR}/c++11-test-${FEATURE_NAME}-N${FEATURE_NUMBER}) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
32 | SET(_LOG_NAME "\"${FEATURE_NAME}\" (N${FEATURE_NUMBER})") |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
33 | ELSE (${FEATURE_NUMBER}) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
34 | SET(_SRCFILE_BASE ${CMAKE_CURRENT_LIST_DIR}/c++11-test-${FEATURE_NAME}) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
35 | SET(_LOG_NAME "\"${FEATURE_NAME}\"") |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
36 | ENDIF (${FEATURE_NUMBER}) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
37 | MESSAGE(STATUS "Checking C++11 support for ${_LOG_NAME}") |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
38 | |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
39 | SET(_SRCFILE "${_SRCFILE_BASE}.cpp") |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
40 | SET(_SRCFILE_FAIL "${_SRCFILE_BASE}_fail.cpp") |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
41 | SET(_SRCFILE_FAIL_COMPILE "${_SRCFILE_BASE}_fail_compile.cpp") |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
42 | |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
43 | IF (CROSS_COMPILING) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
44 | try_compile(${RESULT_VAR} "${_bindir}" "${_SRCFILE}") |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
45 | IF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL}) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
46 | try_compile(${RESULT_VAR} "${_bindir}_fail" "${_SRCFILE_FAIL}") |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
47 | ENDIF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL}) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
48 | ELSE (CROSS_COMPILING) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
49 | try_run(_RUN_RESULT_VAR _COMPILE_RESULT_VAR |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
50 | "${_bindir}" "${_SRCFILE}") |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
51 | IF (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
52 | SET(${RESULT_VAR} TRUE) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
53 | ELSE (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
54 | SET(${RESULT_VAR} FALSE) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
55 | ENDIF (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
56 | IF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL}) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
57 | try_run(_RUN_RESULT_VAR _COMPILE_RESULT_VAR |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
58 | "${_bindir}_fail" "${_SRCFILE_FAIL}") |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
59 | IF (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
60 | SET(${RESULT_VAR} TRUE) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
61 | ELSE (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
62 | SET(${RESULT_VAR} FALSE) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
63 | ENDIF (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
64 | ENDIF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL}) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
65 | ENDIF (CROSS_COMPILING) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
66 | IF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL_COMPILE}) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
67 | try_compile(_TMP_RESULT "${_bindir}_fail_compile" "${_SRCFILE_FAIL_COMPILE}") |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
68 | IF (_TMP_RESULT) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
69 | SET(${RESULT_VAR} FALSE) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
70 | ELSE (_TMP_RESULT) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
71 | SET(${RESULT_VAR} TRUE) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
72 | ENDIF (_TMP_RESULT) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
73 | ENDIF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL_COMPILE}) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
74 | |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
75 | IF (${RESULT_VAR}) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
76 | MESSAGE(STATUS "Checking C++11 support for ${_LOG_NAME} -- works") |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
77 | LIST(APPEND CXX11_FEATURE_LIST ${RESULT_VAR}) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
78 | ELSE (${RESULT_VAR}) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
79 | MESSAGE(STATUS "Checking C++11 support for ${_LOG_NAME} -- not supported") |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
80 | ENDIF (${RESULT_VAR}) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
81 | SET(${RESULT_VAR} ${${RESULT_VAR}} CACHE INTERNAL "C++11 support for ${_LOG_NAME}") |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
82 | ENDIF (NOT DEFINED ${RESULT_VAR}) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
83 | ENDMACRO(CXX11_CHECK_FEATURE) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
84 | |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
85 | CXX11_CHECK_FEATURE("auto" 2546 HAS_CXX11_AUTO) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
86 | CXX11_CHECK_FEATURE("nullptr" 2431 HAS_CXX11_NULLPTR) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
87 | CXX11_CHECK_FEATURE("lambda" 2927 HAS_CXX11_LAMBDA) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
88 | CXX11_CHECK_FEATURE("static_assert" 1720 HAS_CXX11_STATIC_ASSERT) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
89 | CXX11_CHECK_FEATURE("rvalue_references" 2118 HAS_CXX11_RVALUE_REFERENCES) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
90 | CXX11_CHECK_FEATURE("decltype" 2343 HAS_CXX11_DECLTYPE) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
91 | CXX11_CHECK_FEATURE("cstdint" "" HAS_CXX11_CSTDINT_H) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
92 | CXX11_CHECK_FEATURE("long_long" 1811 HAS_CXX11_LONG_LONG) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
93 | CXX11_CHECK_FEATURE("variadic_templates" 2555 HAS_CXX11_VARIADIC_TEMPLATES) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
94 | CXX11_CHECK_FEATURE("constexpr" 2235 HAS_CXX11_CONSTEXPR) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
95 | CXX11_CHECK_FEATURE("sizeof_member" 2253 HAS_CXX11_SIZEOF_MEMBER) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
96 | CXX11_CHECK_FEATURE("__func__" 2340 HAS_CXX11_FUNC) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
97 | |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
98 | SET(CXX11_FEATURE_LIST ${CXX11_FEATURE_LIST} CACHE STRING "C++11 feature support list") |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
99 | MARK_AS_ADVANCED(FORCE CXX11_FEATURE_LIST) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
100 | |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
101 | SET(CMAKE_CXX_FLAGS ${CHECK_CXX11_OLD_CMAKE_CXX_FLAGS}) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
102 | UNSET(CHECK_CXX11_OLD_CMAKE_CXX_FLAGS) |
2a84149fe642
Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
103 |