From a24fcc0c036f69ed7e40b8d558cf1d991433ebc3 Mon Sep 17 00:00:00 2001 From: Matt Williams Date: Fri, 23 Nov 2012 11:34:25 +0000 Subject: [PATCH 1/9] Add C++11 compiler support detection feature This is currently copied from http://quickgit.kde.org/index.php?p=scratch%2Fdakon%2Fcmake-cxx11.git but there is a chance that in future it will be merged into CMake proper. --- cmake/Modules/CheckCXX11Features.cmake | 132 ++++++++++++++++++ .../cxx11-test-__func__.cpp | 8 ++ .../CheckCXX11Features/cxx11-test-auto.cpp | 12 ++ .../cxx11-test-auto_fail_compile.cpp | 7 + .../cxx11-test-auto_ret_type.cpp | 8 ++ .../cxx11-test-class_override_final.cpp | 21 +++ ...test-class_override_final_fail_compile.cpp | 25 ++++ .../cxx11-test-constexpr.cpp | 19 +++ .../CheckCXX11Features/cxx11-test-cstdint.cpp | 11 ++ .../cxx11-test-decltype.cpp | 10 ++ .../cxx11-test-initializer_list.cpp | 27 ++++ .../CheckCXX11Features/cxx11-test-lambda.cpp | 5 + .../cxx11-test-long_long.cpp | 7 + .../CheckCXX11Features/cxx11-test-nullptr.cpp | 6 + .../cxx11-test-nullptr_fail_compile.cpp | 6 + .../CheckCXX11Features/cxx11-test-regex.cpp | 26 ++++ .../cxx11-test-rvalue-references.cpp | 57 ++++++++ .../cxx11-test-sizeof_member.cpp | 14 ++ .../cxx11-test-sizeof_member_fail.cpp | 9 ++ .../cxx11-test-static_assert.cpp | 5 + .../cxx11-test-static_assert_fail_compile.cpp | 5 + .../cxx11-test-variadic_templates.cpp | 23 +++ 22 files changed, 443 insertions(+) create mode 100644 cmake/Modules/CheckCXX11Features.cmake create mode 100644 cmake/Modules/CheckCXX11Features/cxx11-test-__func__.cpp create mode 100644 cmake/Modules/CheckCXX11Features/cxx11-test-auto.cpp create mode 100644 cmake/Modules/CheckCXX11Features/cxx11-test-auto_fail_compile.cpp create mode 100644 cmake/Modules/CheckCXX11Features/cxx11-test-auto_ret_type.cpp create mode 100644 cmake/Modules/CheckCXX11Features/cxx11-test-class_override_final.cpp create mode 100644 cmake/Modules/CheckCXX11Features/cxx11-test-class_override_final_fail_compile.cpp create mode 100644 cmake/Modules/CheckCXX11Features/cxx11-test-constexpr.cpp create mode 100644 cmake/Modules/CheckCXX11Features/cxx11-test-cstdint.cpp create mode 100644 cmake/Modules/CheckCXX11Features/cxx11-test-decltype.cpp create mode 100644 cmake/Modules/CheckCXX11Features/cxx11-test-initializer_list.cpp create mode 100644 cmake/Modules/CheckCXX11Features/cxx11-test-lambda.cpp create mode 100644 cmake/Modules/CheckCXX11Features/cxx11-test-long_long.cpp create mode 100644 cmake/Modules/CheckCXX11Features/cxx11-test-nullptr.cpp create mode 100644 cmake/Modules/CheckCXX11Features/cxx11-test-nullptr_fail_compile.cpp create mode 100644 cmake/Modules/CheckCXX11Features/cxx11-test-regex.cpp create mode 100644 cmake/Modules/CheckCXX11Features/cxx11-test-rvalue-references.cpp create mode 100644 cmake/Modules/CheckCXX11Features/cxx11-test-sizeof_member.cpp create mode 100644 cmake/Modules/CheckCXX11Features/cxx11-test-sizeof_member_fail.cpp create mode 100644 cmake/Modules/CheckCXX11Features/cxx11-test-static_assert.cpp create mode 100644 cmake/Modules/CheckCXX11Features/cxx11-test-static_assert_fail_compile.cpp create mode 100644 cmake/Modules/CheckCXX11Features/cxx11-test-variadic_templates.cpp diff --git a/cmake/Modules/CheckCXX11Features.cmake b/cmake/Modules/CheckCXX11Features.cmake new file mode 100644 index 00000000..0699f48e --- /dev/null +++ b/cmake/Modules/CheckCXX11Features.cmake @@ -0,0 +1,132 @@ +# - Check which parts of the C++11 standard the compiler supports +# +# When found it will set the following variables +# +# CXX11_COMPILER_FLAGS - the compiler flags needed to get C++11 features +# +# HAS_CXX11_AUTO - auto keyword +# HAS_CXX11_AUTO_RET_TYPE - function declaration with deduced return types +# HAS_CXX11_CLASS_OVERRIDE - override and final keywords for classes and methods +# HAS_CXX11_CONSTEXPR - constexpr keyword +# HAS_CXX11_CSTDINT_H - cstdint header +# HAS_CXX11_DECLTYPE - decltype keyword +# HAS_CXX11_FUNC - __func__ preprocessor constant +# HAS_CXX11_INITIALIZER_LIST - initializer list +# HAS_CXX11_LAMBDA - lambdas +# HAS_CXX11_LIB_REGEX - regex library +# HAS_CXX11_LONG_LONG - long long signed & unsigned types +# HAS_CXX11_NULLPTR - nullptr +# HAS_CXX11_RVALUE_REFERENCES - rvalue references +# HAS_CXX11_SIZEOF_MEMBER - sizeof() non-static members +# HAS_CXX11_STATIC_ASSERT - static_assert() +# HAS_CXX11_VARIADIC_TEMPLATES - variadic templates + +#============================================================================= +# Copyright 2011,2012 Rolf Eike Beer +# Copyright 2012 Andreas Weis +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +if (NOT CMAKE_CXX_COMPILER_LOADED) + message(FATAL_ERROR "CheckCXX11Features modules only works if language CXX is enabled") +endif () + +cmake_minimum_required(VERSION 2.8.3) + +# +### Check for needed compiler flags +# +include(CheckCXXCompilerFlag) +check_cxx_compiler_flag("-std=c++11" _HAS_CXX11_FLAG) +if (NOT _HAS_CXX11_FLAG) + check_cxx_compiler_flag("-std=c++0x" _HAS_CXX0X_FLAG) +endif () + +if (_HAS_CXX11_FLAG) + set(CXX11_COMPILER_FLAGS "-std=c++11") +elseif (_HAS_CXX0X_FLAG) + set(CXX11_COMPILER_FLAGS "-std=c++0x") +endif () + +function(cxx11_check_feature FEATURE_NAME RESULT_VAR) + if (NOT DEFINED ${RESULT_VAR}) + set(_bindir "${CMAKE_CURRENT_BINARY_DIR}/cxx11_${FEATURE_NAME}") + + set(_SRCFILE_BASE ${CMAKE_CURRENT_LIST_DIR}/CheckCXX11Features/cxx11-test-${FEATURE_NAME}) + set(_LOG_NAME "\"${FEATURE_NAME}\"") + message(STATUS "Checking C++11 support for ${_LOG_NAME}") + + set(_SRCFILE "${_SRCFILE_BASE}.cpp") + set(_SRCFILE_FAIL "${_SRCFILE_BASE}_fail.cpp") + set(_SRCFILE_FAIL_COMPILE "${_SRCFILE_BASE}_fail_compile.cpp") + + if (CROSS_COMPILING) + try_compile(${RESULT_VAR} "${_bindir}" "${_SRCFILE}" + COMPILE_DEFINITIONS "${CXX11_COMPILER_FLAGS}") + if (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL}) + try_compile(${RESULT_VAR} "${_bindir}_fail" "${_SRCFILE_FAIL}" + COMPILE_DEFINITIONS "${CXX11_COMPILER_FLAGS}") + endif (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL}) + else (CROSS_COMPILING) + try_run(_RUN_RESULT_VAR _COMPILE_RESULT_VAR + "${_bindir}" "${_SRCFILE}" + COMPILE_DEFINITIONS "${CXX11_COMPILER_FLAGS}") + if (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR) + set(${RESULT_VAR} TRUE) + else (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR) + set(${RESULT_VAR} FALSE) + endif (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR) + if (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL}) + try_run(_RUN_RESULT_VAR _COMPILE_RESULT_VAR + "${_bindir}_fail" "${_SRCFILE_FAIL}" + COMPILE_DEFINITIONS "${CXX11_COMPILER_FLAGS}") + if (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR) + set(${RESULT_VAR} TRUE) + else (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR) + set(${RESULT_VAR} FALSE) + endif (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR) + endif (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL}) + endif (CROSS_COMPILING) + if (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL_COMPILE}) + try_compile(_TMP_RESULT "${_bindir}_fail_compile" "${_SRCFILE_FAIL_COMPILE}" + COMPILE_DEFINITIONS "${CXX11_COMPILER_FLAGS}") + if (_TMP_RESULT) + set(${RESULT_VAR} FALSE) + else (_TMP_RESULT) + set(${RESULT_VAR} TRUE) + endif (_TMP_RESULT) + endif (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL_COMPILE}) + + if (${RESULT_VAR}) + message(STATUS "Checking C++11 support for ${_LOG_NAME}: works") + else (${RESULT_VAR}) + message(STATUS "Checking C++11 support for ${_LOG_NAME}: not supported") + endif (${RESULT_VAR}) + set(${RESULT_VAR} ${${RESULT_VAR}} CACHE INTERNAL "C++11 support for ${_LOG_NAME}") + endif (NOT DEFINED ${RESULT_VAR}) +endfunction(cxx11_check_feature) + +cxx11_check_feature("__func__" HAS_CXX11_FUNC) +cxx11_check_feature("auto" HAS_CXX11_AUTO) +cxx11_check_feature("auto_ret_type" HAS_CXX11_AUTO_RET_TYPE) +cxx11_check_feature("class_override_final" HAS_CXX11_CLASS_OVERRIDE) +cxx11_check_feature("constexpr" HAS_CXX11_CONSTEXPR) +cxx11_check_feature("cstdint" HAS_CXX11_CSTDINT_H) +cxx11_check_feature("decltype" HAS_CXX11_DECLTYPE) +cxx11_check_feature("initializer_list" HAS_CXX11_INITIALIZER_LIST) +cxx11_check_feature("lambda" HAS_CXX11_LAMBDA) +cxx11_check_feature("long_long" HAS_CXX11_LONG_LONG) +cxx11_check_feature("nullptr" HAS_CXX11_NULLPTR) +cxx11_check_feature("regex" HAS_CXX11_LIB_REGEX) +cxx11_check_feature("rvalue-references" HAS_CXX11_RVALUE_REFERENCES) +cxx11_check_feature("sizeof_member" HAS_CXX11_SIZEOF_MEMBER) +cxx11_check_feature("static_assert" HAS_CXX11_STATIC_ASSERT) +cxx11_check_feature("variadic_templates" HAS_CXX11_VARIADIC_TEMPLATES) diff --git a/cmake/Modules/CheckCXX11Features/cxx11-test-__func__.cpp b/cmake/Modules/CheckCXX11Features/cxx11-test-__func__.cpp new file mode 100644 index 00000000..3bfd8a89 --- /dev/null +++ b/cmake/Modules/CheckCXX11Features/cxx11-test-__func__.cpp @@ -0,0 +1,8 @@ +int main(void) +{ + if (!__func__) + return 1; + if (!(*__func__)) + return 1; + return 0; +} diff --git a/cmake/Modules/CheckCXX11Features/cxx11-test-auto.cpp b/cmake/Modules/CheckCXX11Features/cxx11-test-auto.cpp new file mode 100644 index 00000000..948648e9 --- /dev/null +++ b/cmake/Modules/CheckCXX11Features/cxx11-test-auto.cpp @@ -0,0 +1,12 @@ + +int main() +{ + auto i = 5; + auto f = 3.14159f; + auto d = 3.14159; + bool ret = ( + (sizeof(f) < sizeof(d)) && + (sizeof(i) == sizeof(int)) + ); + return ret ? 0 : 1; +} diff --git a/cmake/Modules/CheckCXX11Features/cxx11-test-auto_fail_compile.cpp b/cmake/Modules/CheckCXX11Features/cxx11-test-auto_fail_compile.cpp new file mode 100644 index 00000000..3c0e3f2e --- /dev/null +++ b/cmake/Modules/CheckCXX11Features/cxx11-test-auto_fail_compile.cpp @@ -0,0 +1,7 @@ +int main(void) +{ + // must fail because there is no initializer + auto i; + + return 0; +} diff --git a/cmake/Modules/CheckCXX11Features/cxx11-test-auto_ret_type.cpp b/cmake/Modules/CheckCXX11Features/cxx11-test-auto_ret_type.cpp new file mode 100644 index 00000000..937b6835 --- /dev/null +++ b/cmake/Modules/CheckCXX11Features/cxx11-test-auto_ret_type.cpp @@ -0,0 +1,8 @@ +auto foo(int i) -> int { + return i - 1; +} + +int main() +{ + return foo(1); +} diff --git a/cmake/Modules/CheckCXX11Features/cxx11-test-class_override_final.cpp b/cmake/Modules/CheckCXX11Features/cxx11-test-class_override_final.cpp new file mode 100644 index 00000000..f5870b19 --- /dev/null +++ b/cmake/Modules/CheckCXX11Features/cxx11-test-class_override_final.cpp @@ -0,0 +1,21 @@ +class base { +public: + virtual int foo(int a) + { return 4 + a; } + int bar(int a) final + { return a - 2; } +}; + +class sub final : public base { +public: + virtual int foo(int a) override + { return 8 + 2 * a; }; +}; + +int main(void) +{ + base b; + sub s; + + return (b.foo(2) * 2 == s.foo(2)) ? 0 : 1; +} diff --git a/cmake/Modules/CheckCXX11Features/cxx11-test-class_override_final_fail_compile.cpp b/cmake/Modules/CheckCXX11Features/cxx11-test-class_override_final_fail_compile.cpp new file mode 100644 index 00000000..bc00b278 --- /dev/null +++ b/cmake/Modules/CheckCXX11Features/cxx11-test-class_override_final_fail_compile.cpp @@ -0,0 +1,25 @@ +class base { +public: + virtual int foo(int a) + { return 4 + a; } + virtual int bar(int a) final + { return a - 2; } +}; + +class sub final : public base { +public: + virtual int foo(int a) override + { return 8 + 2 * a; }; + virtual int bar(int a) + { return a; } +}; + +class impossible : public sub { }; + +int main(void) +{ + base b; + sub s; + + return 1; +} diff --git a/cmake/Modules/CheckCXX11Features/cxx11-test-constexpr.cpp b/cmake/Modules/CheckCXX11Features/cxx11-test-constexpr.cpp new file mode 100644 index 00000000..ed624512 --- /dev/null +++ b/cmake/Modules/CheckCXX11Features/cxx11-test-constexpr.cpp @@ -0,0 +1,19 @@ +constexpr int square(int x) +{ + return x*x; +} + +constexpr int the_answer() +{ + return 42; +} + +int main() +{ + int test_arr[square(3)]; + bool ret = ( + (square(the_answer()) == 1764) && + (sizeof(test_arr)/sizeof(test_arr[0]) == 9) + ); + return ret ? 0 : 1; +} diff --git a/cmake/Modules/CheckCXX11Features/cxx11-test-cstdint.cpp b/cmake/Modules/CheckCXX11Features/cxx11-test-cstdint.cpp new file mode 100644 index 00000000..ca2c72dd --- /dev/null +++ b/cmake/Modules/CheckCXX11Features/cxx11-test-cstdint.cpp @@ -0,0 +1,11 @@ +#include + +int main() +{ + bool test = + (sizeof(int8_t) == 1) && + (sizeof(int16_t) == 2) && + (sizeof(int32_t) == 4) && + (sizeof(int64_t) == 8); + return test ? 0 : 1; +} diff --git a/cmake/Modules/CheckCXX11Features/cxx11-test-decltype.cpp b/cmake/Modules/CheckCXX11Features/cxx11-test-decltype.cpp new file mode 100644 index 00000000..0dbb1cc5 --- /dev/null +++ b/cmake/Modules/CheckCXX11Features/cxx11-test-decltype.cpp @@ -0,0 +1,10 @@ +bool check_size(int i) +{ + return sizeof(int) == sizeof(decltype(i)); +} + +int main() +{ + bool ret = check_size(42); + return ret ? 0 : 1; +} diff --git a/cmake/Modules/CheckCXX11Features/cxx11-test-initializer_list.cpp b/cmake/Modules/CheckCXX11Features/cxx11-test-initializer_list.cpp new file mode 100644 index 00000000..35e6c384 --- /dev/null +++ b/cmake/Modules/CheckCXX11Features/cxx11-test-initializer_list.cpp @@ -0,0 +1,27 @@ +#include + +class seq { +public: + seq(std::initializer_list list); + + int length() const; +private: + std::vector m_v; +}; + +seq::seq(std::initializer_list list) + : m_v(list) +{ +} + +int seq::length() const +{ + return m_v.size(); +} + +int main(void) +{ + seq a = {18, 20, 2, 0, 4, 7}; + + return (a.length() == 6) ? 0 : 1; +} diff --git a/cmake/Modules/CheckCXX11Features/cxx11-test-lambda.cpp b/cmake/Modules/CheckCXX11Features/cxx11-test-lambda.cpp new file mode 100644 index 00000000..4c33ed58 --- /dev/null +++ b/cmake/Modules/CheckCXX11Features/cxx11-test-lambda.cpp @@ -0,0 +1,5 @@ +int main() +{ + int ret = 0; + return ([&ret]() -> int { return ret; })(); +} diff --git a/cmake/Modules/CheckCXX11Features/cxx11-test-long_long.cpp b/cmake/Modules/CheckCXX11Features/cxx11-test-long_long.cpp new file mode 100644 index 00000000..09111275 --- /dev/null +++ b/cmake/Modules/CheckCXX11Features/cxx11-test-long_long.cpp @@ -0,0 +1,7 @@ +int main(void) +{ + long long l; + unsigned long long ul; + + return ((sizeof(l) >= 8) && (sizeof(ul) >= 8)) ? 0 : 1; +} diff --git a/cmake/Modules/CheckCXX11Features/cxx11-test-nullptr.cpp b/cmake/Modules/CheckCXX11Features/cxx11-test-nullptr.cpp new file mode 100644 index 00000000..9f410715 --- /dev/null +++ b/cmake/Modules/CheckCXX11Features/cxx11-test-nullptr.cpp @@ -0,0 +1,6 @@ +int main(void) +{ + void *v = nullptr; + + return v ? 1 : 0; +} diff --git a/cmake/Modules/CheckCXX11Features/cxx11-test-nullptr_fail_compile.cpp b/cmake/Modules/CheckCXX11Features/cxx11-test-nullptr_fail_compile.cpp new file mode 100644 index 00000000..6a002bcb --- /dev/null +++ b/cmake/Modules/CheckCXX11Features/cxx11-test-nullptr_fail_compile.cpp @@ -0,0 +1,6 @@ +int main(void) +{ + int i = nullptr; + + return 1; +} diff --git a/cmake/Modules/CheckCXX11Features/cxx11-test-regex.cpp b/cmake/Modules/CheckCXX11Features/cxx11-test-regex.cpp new file mode 100644 index 00000000..2fe01c4f --- /dev/null +++ b/cmake/Modules/CheckCXX11Features/cxx11-test-regex.cpp @@ -0,0 +1,26 @@ +#include +#include + +int parse_line(std::string const& line) +{ + std::string tmp; + if(std::regex_search(line, std::regex("(\\s)+(-)?(\\d)+//(-)?(\\d)+(\\s)+"))) { + tmp = std::regex_replace(line, std::regex("(-)?(\\d)+//(-)?(\\d)+"), std::string("V")); + } else if(std::regex_search(line, std::regex("(\\s)+(-)?(\\d)+/(-)?(\\d)+(\\s)+"))) { + tmp = std::regex_replace(line, std::regex("(-)?(\\d)+/(-)?(\\d)+"), std::string("V")); + } else if(std::regex_search(line, std::regex("(\\s)+(-)?(\\d)+/(-)?(\\d)+/(-)?(\\d)+(\\s)+"))) { + tmp = std::regex_replace(line, std::regex("(-)?(\\d)+/(-)?(\\d)+/(-)?(\\d)+"), std::string("V")); + } else { + tmp = std::regex_replace(line, std::regex("(-)?(\\d)+"), std::string("V")); + } + return static_cast(std::count(tmp.begin(), tmp.end(), 'V')); +} + +int main() +{ + bool test = (parse_line("f 7/7/7 -3/3/-3 2/-2/2") == 3) && + (parse_line("f 7//7 3//-3 -2//2") == 3) && + (parse_line("f 7/7 3/-3 -2/2") == 3) && + (parse_line("f 7 3 -2") == 3); + return test ? 0 : 1; +} diff --git a/cmake/Modules/CheckCXX11Features/cxx11-test-rvalue-references.cpp b/cmake/Modules/CheckCXX11Features/cxx11-test-rvalue-references.cpp new file mode 100644 index 00000000..e6e7e5a9 --- /dev/null +++ b/cmake/Modules/CheckCXX11Features/cxx11-test-rvalue-references.cpp @@ -0,0 +1,57 @@ +#include + +class rvmove { +public: + void *ptr; + char *array; + + rvmove() + : ptr(0), + array(new char[10]) + { + ptr = this; + } + + rvmove(rvmove &&other) + : ptr(other.ptr), + array(other.array) + { + other.array = 0; + other.ptr = 0; + } + + ~rvmove() + { + assert(((ptr != 0) && (array != 0)) || ((ptr == 0) && (array == 0))); + delete[] array; + } + + rvmove &operator=(rvmove &&other) + { + delete[] array; + ptr = other.ptr; + array = other.array; + other.array = 0; + other.ptr = 0; + return *this; + } + + static rvmove create() + { + return rvmove(); + } +private: + rvmove(const rvmove &); + rvmove &operator=(const rvmove &); +}; + +int main() +{ + rvmove mine; + if (mine.ptr != &mine) + return 1; + mine = rvmove::create(); + if (mine.ptr == &mine) + return 1; + return 0; +} diff --git a/cmake/Modules/CheckCXX11Features/cxx11-test-sizeof_member.cpp b/cmake/Modules/CheckCXX11Features/cxx11-test-sizeof_member.cpp new file mode 100644 index 00000000..4902fc73 --- /dev/null +++ b/cmake/Modules/CheckCXX11Features/cxx11-test-sizeof_member.cpp @@ -0,0 +1,14 @@ +struct foo { + char bar; + int baz; +}; + +int main(void) +{ + bool ret = ( + (sizeof(foo::bar) == 1) && + (sizeof(foo::baz) >= sizeof(foo::bar)) && + (sizeof(foo) >= sizeof(foo::bar) + sizeof(foo::baz)) + ); + return ret ? 0 : 1; +} diff --git a/cmake/Modules/CheckCXX11Features/cxx11-test-sizeof_member_fail.cpp b/cmake/Modules/CheckCXX11Features/cxx11-test-sizeof_member_fail.cpp new file mode 100644 index 00000000..0348c2ce --- /dev/null +++ b/cmake/Modules/CheckCXX11Features/cxx11-test-sizeof_member_fail.cpp @@ -0,0 +1,9 @@ +struct foo { + int baz; + double bar; +}; + +int main(void) +{ + return (sizeof(foo::bar) == 4) ? 0 : 1; +} diff --git a/cmake/Modules/CheckCXX11Features/cxx11-test-static_assert.cpp b/cmake/Modules/CheckCXX11Features/cxx11-test-static_assert.cpp new file mode 100644 index 00000000..47c2fefb --- /dev/null +++ b/cmake/Modules/CheckCXX11Features/cxx11-test-static_assert.cpp @@ -0,0 +1,5 @@ +int main(void) +{ + static_assert(0 < 1, "your ordering of integers is screwed"); + return 0; +} diff --git a/cmake/Modules/CheckCXX11Features/cxx11-test-static_assert_fail_compile.cpp b/cmake/Modules/CheckCXX11Features/cxx11-test-static_assert_fail_compile.cpp new file mode 100644 index 00000000..362fcdde --- /dev/null +++ b/cmake/Modules/CheckCXX11Features/cxx11-test-static_assert_fail_compile.cpp @@ -0,0 +1,5 @@ +int main(void) +{ + static_assert(1 < 0, "your ordering of integers is screwed"); + return 0; +} diff --git a/cmake/Modules/CheckCXX11Features/cxx11-test-variadic_templates.cpp b/cmake/Modules/CheckCXX11Features/cxx11-test-variadic_templates.cpp new file mode 100644 index 00000000..4518e886 --- /dev/null +++ b/cmake/Modules/CheckCXX11Features/cxx11-test-variadic_templates.cpp @@ -0,0 +1,23 @@ +int Accumulate() +{ + return 0; +} + +template +int Accumulate(T v, Ts... vs) +{ + return v + Accumulate(vs...); +} + +template +int CountElements() +{ + return sizeof...(Is); +} + +int main() +{ + int acc = Accumulate(1, 2, 3, 4, -5); + int count = CountElements<1,2,3,4,5>(); + return ((acc == 5) && (count == 5)) ? 0 : 1; +} From 596bf12877caae5bef908603904a4801a2f68d31 Mon Sep 17 00:00:00 2001 From: Matt Williams Date: Fri, 23 Nov 2012 11:40:56 +0000 Subject: [PATCH 2/9] Run the feature detection at CMake time --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e8bbf35..a1004858 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,6 +69,8 @@ if(CMAKE_CXX_COMPILER MATCHES "clang") ADD_DEFINITIONS(-std=c++0x) #Enable C++0x mode endif() +INCLUDE(cmake/Modules/CheckCXX11Features.cmake) + ADD_SUBDIRECTORY(library) OPTION(ENABLE_EXAMPLES "Should the examples be built" ON) From 3902e00a0f6a27a6e01d81386fd017ca4e4bdee2 Mon Sep 17 00:00:00 2001 From: Matt Williams Date: Fri, 23 Nov 2012 11:45:13 +0000 Subject: [PATCH 3/9] Add a CompilerCapabilities.h.in file which is filled in by CMake It will #define a each of the basic features detected by CMake which can then be used by other headers (like TypeDef.h) to set things up for PolyVox. It is this file which you will have to manually edit and rename if you want to skip using CMake. --- examples/Basic/CMakeLists.txt | 2 +- examples/OpenGL/CMakeLists.txt | 2 +- examples/Paging/CMakeLists.txt | 2 +- examples/SmoothLOD/CMakeLists.txt | 2 +- library/PolyVoxCore/CMakeLists.txt | 5 ++++- .../include/PolyVoxCore/Impl/CompilerCapabilities.h.in | 6 ++++++ library/PolyVoxCore/include/PolyVoxCore/Impl/TypeDef.h | 2 ++ library/PolyVoxUtil/CMakeLists.txt | 2 +- library/bindings/CMakeLists.txt | 2 +- tests/CMakeLists.txt | 2 +- 10 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 library/PolyVoxCore/include/PolyVoxCore/Impl/CompilerCapabilities.h.in diff --git a/examples/Basic/CMakeLists.txt b/examples/Basic/CMakeLists.txt index a17c1eeb..741aa5a0 100644 --- a/examples/Basic/CMakeLists.txt +++ b/examples/Basic/CMakeLists.txt @@ -50,7 +50,7 @@ SOURCE_GROUP("Headers" FILES ${INC_FILES}) FIND_PACKAGE(OpenGL REQUIRED) #Tell CMake the paths for OpenGL and for PolyVox (which is just relative to our current location) -INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${PolyVoxCore_SOURCE_DIR}/include) +INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${PolyVoxCore_SOURCE_DIR}/include ${PolyVoxCore_BINARY_DIR}/include) LINK_DIRECTORIES(${PolyVoxCore_BINARY_DIR}) #Build diff --git a/examples/OpenGL/CMakeLists.txt b/examples/OpenGL/CMakeLists.txt index 5b61f759..e90fc80a 100644 --- a/examples/OpenGL/CMakeLists.txt +++ b/examples/OpenGL/CMakeLists.txt @@ -56,7 +56,7 @@ SOURCE_GROUP("Headers" FILES ${INC_FILES}) FIND_PACKAGE(OpenGL REQUIRED) #Tell CMake the paths for OpenGL and for PolyVox (which is just relative to our current location) -INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${PolyVoxCore_SOURCE_DIR}/include) +INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${PolyVoxCore_SOURCE_DIR}/include ${PolyVoxCore_BINARY_DIR}/include) LINK_DIRECTORIES(${PolyVoxCore_BINARY_DIR}) #Build diff --git a/examples/Paging/CMakeLists.txt b/examples/Paging/CMakeLists.txt index 88fb5b6f..7b07b742 100644 --- a/examples/Paging/CMakeLists.txt +++ b/examples/Paging/CMakeLists.txt @@ -52,7 +52,7 @@ SOURCE_GROUP("Headers" FILES ${INC_FILES}) FIND_PACKAGE(OpenGL REQUIRED) #Tell CMake the paths for OpenGL and for PolyVox (which is just relative to our current location) -INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${PolyVoxCore_SOURCE_DIR}/include) +INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${PolyVoxCore_SOURCE_DIR}/include ${PolyVoxCore_BINARY_DIR}/include) LINK_DIRECTORIES(${PolyVoxCore_BINARY_DIR}) #Build diff --git a/examples/SmoothLOD/CMakeLists.txt b/examples/SmoothLOD/CMakeLists.txt index 86923a0a..c911c6a1 100644 --- a/examples/SmoothLOD/CMakeLists.txt +++ b/examples/SmoothLOD/CMakeLists.txt @@ -50,7 +50,7 @@ SOURCE_GROUP("Headers" FILES ${INC_FILES}) FIND_PACKAGE(OpenGL REQUIRED) #Tell CMake the paths for OpenGL and for PolyVox (which is just relative to our current location) -INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${PolyVoxCore_SOURCE_DIR}/include) +INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${PolyVoxCore_SOURCE_DIR}/include ${PolyVoxCore_BINARY_DIR}/include) LINK_DIRECTORIES(${PolyVoxCore_BINARY_DIR}) #Build diff --git a/library/PolyVoxCore/CMakeLists.txt b/library/PolyVoxCore/CMakeLists.txt index e4b4f443..8fc62c0a 100644 --- a/library/PolyVoxCore/CMakeLists.txt +++ b/library/PolyVoxCore/CMakeLists.txt @@ -24,6 +24,9 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(PolyVoxCore) +#Set up the C++11 feature header file based on the CheckCXX11Features script +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/include/PolyVoxCore/Impl/CompilerCapabilities.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/PolyVoxCore/Impl/CompilerCapabilities.h) + #Projects source files SET(CORE_SRC_FILES source/ArraySizes.cpp @@ -128,7 +131,7 @@ SOURCE_GROUP("Sources\\Impl" FILES ${IMPL_SRC_FILES}) SOURCE_GROUP("Headers\\Impl" FILES ${IMPL_INC_FILES}) #Tell CMake the paths -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_BINARY_DIR}/include) #Core #Build diff --git a/library/PolyVoxCore/include/PolyVoxCore/Impl/CompilerCapabilities.h.in b/library/PolyVoxCore/include/PolyVoxCore/Impl/CompilerCapabilities.h.in new file mode 100644 index 00000000..6876d1a7 --- /dev/null +++ b/library/PolyVoxCore/include/PolyVoxCore/Impl/CompilerCapabilities.h.in @@ -0,0 +1,6 @@ +#ifndef __PolyVox_CompilerCapabilities_H__ +#define __PolyVox_CompilerCapabilities_H__ + +#cmakedefine HAS_CXX11_CONSTEXPR + +#endif diff --git a/library/PolyVoxCore/include/PolyVoxCore/Impl/TypeDef.h b/library/PolyVoxCore/include/PolyVoxCore/Impl/TypeDef.h index 8feb34bd..113ccfd8 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Impl/TypeDef.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Impl/TypeDef.h @@ -24,6 +24,8 @@ freely, subject to the following restrictions: #ifndef __PolyVox_TypeDef_H__ #define __PolyVox_TypeDef_H__ +#include "PolyVoxCore/Impl/CompilerCapabilities.h" + //Definitions needed to make library functions accessable // See http://gcc.gnu.org/wiki/Visibility for more info. #if defined _WIN32 || defined __CYGWIN__ diff --git a/library/PolyVoxUtil/CMakeLists.txt b/library/PolyVoxUtil/CMakeLists.txt index 97dbb8da..38425346 100644 --- a/library/PolyVoxUtil/CMakeLists.txt +++ b/library/PolyVoxUtil/CMakeLists.txt @@ -45,7 +45,7 @@ SOURCE_GROUP("Sources" FILES ${UTIL_SRC_FILES}) SOURCE_GROUP("Headers" FILES ${UTIL_INC_FILES}) #Tell CMake the paths -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include ${PolyVoxCore_SOURCE_DIR}/include) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include ${PolyVoxCore_SOURCE_DIR}/include ${PolyVoxCore_BINARY_DIR}/include) #There has to be a better way! LINK_DIRECTORIES(${PolyVoxCore_BINARY_DIR}/debug ${PolyVoxCore_BINARY_DIR}/release ${PolyVoxCore_BINARY_DIR}) diff --git a/library/bindings/CMakeLists.txt b/library/bindings/CMakeLists.txt index e976c015..33172fdb 100644 --- a/library/bindings/CMakeLists.txt +++ b/library/bindings/CMakeLists.txt @@ -36,7 +36,7 @@ if(ENABLE_BINDINGS) include(${SWIG_USE_FILE}) include_directories(${PYTHON_INCLUDE_PATH}) - include_directories(${PolyVoxCore_SOURCE_DIR}/include ${PolyVoxCore_SOURCE_DIR}/include/PolyVoxCore) + include_directories(${PolyVoxCore_SOURCE_DIR}/include ${PolyVoxCore_SOURCE_DIR}/include/PolyVoxCore ${PolyVoxCore_BINARY_DIR}/include) link_directories(${PolyVoxCore_BINARY_DIR}) set(CMAKE_SWIG_FLAGS "") diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 6c6fe163..693a7026 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -39,7 +39,7 @@ MACRO(CREATE_TEST headerfile sourcefile executablename) SET_PROPERTY(TARGET ${executablename} PROPERTY FOLDER "Tests") ENDMACRO(CREATE_TEST) -INCLUDE_DIRECTORIES(${PolyVox_SOURCE_DIR}/PolyVoxCore/include ${CMAKE_CURRENT_BINARY_DIR}) +INCLUDE_DIRECTORIES(${PolyVox_SOURCE_DIR}/PolyVoxCore/include ${PolyVoxCore_BINARY_DIR}/include ${CMAKE_CURRENT_BINARY_DIR}) REMOVE_DEFINITIONS(-DQT_GUI_LIB) #Make sure the tests don't link to the QtGui # Test Template. Copy and paste this template for consistant naming. From c8657943c8155ff37deca951346e391861a398ad Mon Sep 17 00:00:00 2001 From: Matt Williams Date: Fri, 23 Nov 2012 11:51:55 +0000 Subject: [PATCH 4/9] Create polyvox_constexpr macros based on the detected features We now have a two new polyvox_ macros: * polyvox_constexpr which is 'constexpr' is supported and '' otherwise * polyvox_constexpr_const constexpr which is also 'constexpr' is supported but falls back to 'const' otherwise. These macros should be safe to use liberally without worrying about which compiler you're on. --- library/PolyVoxCore/include/PolyVoxCore/Impl/TypeDef.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/library/PolyVoxCore/include/PolyVoxCore/Impl/TypeDef.h b/library/PolyVoxCore/include/PolyVoxCore/Impl/TypeDef.h index 113ccfd8..20866217 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Impl/TypeDef.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Impl/TypeDef.h @@ -104,4 +104,12 @@ freely, subject to the following restrictions: //#define static_assert static_assert //we can use this #endif +#if defined(HAS_CXX11_CONSTEXPR) + #define polyvox_constexpr_const constexpr //constexpr which falls back to const + #define polyvox_constexpr constexpr //constexpr which falls back to nothing +#else + #define polyvox_constexpr_const const + #define polyvox_constexpr +#endif + #endif From 4b2c899dc6244c92e4dd913d760a3408e79eda48 Mon Sep 17 00:00:00 2001 From: Matt Williams Date: Fri, 23 Nov 2012 12:02:57 +0000 Subject: [PATCH 5/9] Define static_assert in the same way Hopefully this won't change anything as we already had a check for it. However, it is now based compiler checks rather than version numbers. We haven't use static_assert anywhere in code yet anyway. --- .../PolyVoxCore/Impl/CompilerCapabilities.h.in | 2 ++ .../PolyVoxCore/include/PolyVoxCore/Impl/TypeDef.h | 11 +++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/library/PolyVoxCore/include/PolyVoxCore/Impl/CompilerCapabilities.h.in b/library/PolyVoxCore/include/PolyVoxCore/Impl/CompilerCapabilities.h.in index 6876d1a7..8c1638c3 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Impl/CompilerCapabilities.h.in +++ b/library/PolyVoxCore/include/PolyVoxCore/Impl/CompilerCapabilities.h.in @@ -3,4 +3,6 @@ #cmakedefine HAS_CXX11_CONSTEXPR +#cmakedefine HAS_CXX11_STATIC_ASSERT + #endif diff --git a/library/PolyVoxCore/include/PolyVoxCore/Impl/TypeDef.h b/library/PolyVoxCore/include/PolyVoxCore/Impl/TypeDef.h index 20866217..e16b3b5a 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Impl/TypeDef.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Impl/TypeDef.h @@ -77,9 +77,6 @@ freely, subject to the following restrictions: #define polyvox_bind boost::bind #define polyvox_placeholder_1 _1 #define polyvox_placeholder_2 _2 - - #include - #define static_assert BOOST_STATIC_ASSERT //As long as we're requiring boost, we'll use it to compensate @@ -101,7 +98,6 @@ freely, subject to the following restrictions: #define polyvox_bind std::bind #define polyvox_placeholder_1 std::placeholders::_1 #define polyvox_placeholder_2 std::placeholders::_2 - //#define static_assert static_assert //we can use this #endif #if defined(HAS_CXX11_CONSTEXPR) @@ -112,4 +108,11 @@ freely, subject to the following restrictions: #define polyvox_constexpr #endif +#if defined(HAS_CXX11_STATIC_ASSERT) + //In this case we can just use static_assert +#else + #include + #define static_assert BOOST_STATIC_ASSERT +#endif + #endif From dbb5832d52aa2d7d006fc727181ab1bb09a4dc15 Mon Sep 17 00:00:00 2001 From: Matt Williams Date: Fri, 23 Nov 2012 12:59:16 +0000 Subject: [PATCH 6/9] Move the cstdint detection to the new framework Again, hopefully nothing will change but a test on MSVC 2008/2005 might be needed. --- .../Impl/CompilerCapabilities.h.in | 2 ++ .../include/PolyVoxCore/Impl/TypeDef.h | 24 +++++++++---------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/library/PolyVoxCore/include/PolyVoxCore/Impl/CompilerCapabilities.h.in b/library/PolyVoxCore/include/PolyVoxCore/Impl/CompilerCapabilities.h.in index 8c1638c3..0a5cfed1 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Impl/CompilerCapabilities.h.in +++ b/library/PolyVoxCore/include/PolyVoxCore/Impl/CompilerCapabilities.h.in @@ -5,4 +5,6 @@ #cmakedefine HAS_CXX11_STATIC_ASSERT +#cmakedefine HAS_CXX11_CSTDINT_H + #endif diff --git a/library/PolyVoxCore/include/PolyVoxCore/Impl/TypeDef.h b/library/PolyVoxCore/include/PolyVoxCore/Impl/TypeDef.h index e16b3b5a..0f9c832e 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Impl/TypeDef.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Impl/TypeDef.h @@ -77,20 +77,8 @@ freely, subject to the following restrictions: #define polyvox_bind boost::bind #define polyvox_placeholder_1 _1 #define polyvox_placeholder_2 _2 - - - //As long as we're requiring boost, we'll use it to compensate - //for the missing cstdint header too. - #include - using boost::int8_t; - using boost::int16_t; - using boost::int32_t; - using boost::uint8_t; - using boost::uint16_t; - using boost::uint32_t; #else //We have a decent compiler - use real C++0x features - #include #include #include #define polyvox_shared_ptr std::shared_ptr @@ -115,4 +103,16 @@ freely, subject to the following restrictions: #define static_assert BOOST_STATIC_ASSERT #endif +#if defined(HAS_CXX11_CSTDINT_H) + #include +#else + #include + using boost::int8_t; + using boost::int16_t; + using boost::int32_t; + using boost::uint8_t; + using boost::uint16_t; + using boost::uint32_t; +#endif + #endif From 989e6ea5894f65d08ef015360bbfbf77d8bb889a Mon Sep 17 00:00:00 2001 From: Matt Williams Date: Fri, 23 Nov 2012 14:04:14 +0000 Subject: [PATCH 7/9] Fix SWIG complaining about redefining uint8_t etc. --- library/bindings/PolyVoxCore.i | 1 + 1 file changed, 1 insertion(+) diff --git a/library/bindings/PolyVoxCore.i b/library/bindings/PolyVoxCore.i index 09fa805e..370f0b6b 100644 --- a/library/bindings/PolyVoxCore.i +++ b/library/bindings/PolyVoxCore.i @@ -1,6 +1,7 @@ %module PolyVoxCore #define POLYVOX_API +%include "PolyVoxCore/Impl/CompilerCapabilities.h" %include "Impl/TypeDef.h" #define __attribute__(x) //Silence DEPRECATED errors From 9f5fe452c9b66fb8e5d66f8d939d975c8393e81d Mon Sep 17 00:00:00 2001 From: Matt Williams Date: Fri, 23 Nov 2012 14:16:23 +0000 Subject: [PATCH 8/9] Give shared_ptr the same treatment. Here I have defined my own test for the feature. It's not an extensive test but it checks for the presence of the class. --- cmake/Modules/CheckCXX11Features.cmake | 1 + .../CheckCXX11Features/cxx11-test-shared_ptr.cpp | 7 +++++++ .../PolyVoxCore/Impl/CompilerCapabilities.h.in | 2 ++ .../PolyVoxCore/include/PolyVoxCore/Impl/TypeDef.h | 13 ++++++++----- 4 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 cmake/Modules/CheckCXX11Features/cxx11-test-shared_ptr.cpp diff --git a/cmake/Modules/CheckCXX11Features.cmake b/cmake/Modules/CheckCXX11Features.cmake index 0699f48e..5373ba6a 100644 --- a/cmake/Modules/CheckCXX11Features.cmake +++ b/cmake/Modules/CheckCXX11Features.cmake @@ -130,3 +130,4 @@ cxx11_check_feature("rvalue-references" HAS_CXX11_RVALUE_REFERENCES) cxx11_check_feature("sizeof_member" HAS_CXX11_SIZEOF_MEMBER) cxx11_check_feature("static_assert" HAS_CXX11_STATIC_ASSERT) cxx11_check_feature("variadic_templates" HAS_CXX11_VARIADIC_TEMPLATES) +cxx11_check_feature("shared_ptr" HAS_CXX11_SHARED_PTR) diff --git a/cmake/Modules/CheckCXX11Features/cxx11-test-shared_ptr.cpp b/cmake/Modules/CheckCXX11Features/cxx11-test-shared_ptr.cpp new file mode 100644 index 00000000..2d9c6bd1 --- /dev/null +++ b/cmake/Modules/CheckCXX11Features/cxx11-test-shared_ptr.cpp @@ -0,0 +1,7 @@ +#include + +int main() +{ + std::shared_ptr test; + return 0; +} diff --git a/library/PolyVoxCore/include/PolyVoxCore/Impl/CompilerCapabilities.h.in b/library/PolyVoxCore/include/PolyVoxCore/Impl/CompilerCapabilities.h.in index 0a5cfed1..5518dfb2 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Impl/CompilerCapabilities.h.in +++ b/library/PolyVoxCore/include/PolyVoxCore/Impl/CompilerCapabilities.h.in @@ -7,4 +7,6 @@ #cmakedefine HAS_CXX11_CSTDINT_H +#cmakedefine HAS_CXX11_SHARED_PTR + #endif diff --git a/library/PolyVoxCore/include/PolyVoxCore/Impl/TypeDef.h b/library/PolyVoxCore/include/PolyVoxCore/Impl/TypeDef.h index 0f9c832e..996414ca 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Impl/TypeDef.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Impl/TypeDef.h @@ -67,9 +67,6 @@ freely, subject to the following restrictions: //To support old (pre-vc2010) Microsoft compilers we use boost to replace the //std::shared_ptr and potentially other C++0x features. To use this capability you //will need to make sure you have boost installed on your system. - #include - #define polyvox_shared_ptr boost::shared_ptr - #include #define polyvox_function boost::function @@ -80,8 +77,6 @@ freely, subject to the following restrictions: #else //We have a decent compiler - use real C++0x features #include - #include - #define polyvox_shared_ptr std::shared_ptr #define polyvox_function std::function #define polyvox_bind std::bind #define polyvox_placeholder_1 std::placeholders::_1 @@ -115,4 +110,12 @@ freely, subject to the following restrictions: using boost::uint32_t; #endif +#if defined(HAS_CXX11_SHARED_PTR) + #include + #define polyvox_shared_ptr std::shared_ptr +#else + #include + #define polyvox_shared_ptr boost::shared_ptr +#endif + #endif From a8bc3081fb12ee36d83fbae08166cab4d2b1dce3 Mon Sep 17 00:00:00 2001 From: Matt Williams Date: Wed, 12 Dec 2012 14:48:10 +0000 Subject: [PATCH 9/9] Disable checks for a few C++11 features We don't use a lot of these features so don't bother checking for them just yet. --- cmake/Modules/CheckCXX11Features.cmake | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/cmake/Modules/CheckCXX11Features.cmake b/cmake/Modules/CheckCXX11Features.cmake index 5373ba6a..b3158f4c 100644 --- a/cmake/Modules/CheckCXX11Features.cmake +++ b/cmake/Modules/CheckCXX11Features.cmake @@ -114,20 +114,20 @@ function(cxx11_check_feature FEATURE_NAME RESULT_VAR) endif (NOT DEFINED ${RESULT_VAR}) endfunction(cxx11_check_feature) -cxx11_check_feature("__func__" HAS_CXX11_FUNC) -cxx11_check_feature("auto" HAS_CXX11_AUTO) -cxx11_check_feature("auto_ret_type" HAS_CXX11_AUTO_RET_TYPE) -cxx11_check_feature("class_override_final" HAS_CXX11_CLASS_OVERRIDE) +#cxx11_check_feature("__func__" HAS_CXX11_FUNC) +#cxx11_check_feature("auto" HAS_CXX11_AUTO) +#cxx11_check_feature("auto_ret_type" HAS_CXX11_AUTO_RET_TYPE) +#cxx11_check_feature("class_override_final" HAS_CXX11_CLASS_OVERRIDE) cxx11_check_feature("constexpr" HAS_CXX11_CONSTEXPR) cxx11_check_feature("cstdint" HAS_CXX11_CSTDINT_H) -cxx11_check_feature("decltype" HAS_CXX11_DECLTYPE) -cxx11_check_feature("initializer_list" HAS_CXX11_INITIALIZER_LIST) -cxx11_check_feature("lambda" HAS_CXX11_LAMBDA) -cxx11_check_feature("long_long" HAS_CXX11_LONG_LONG) -cxx11_check_feature("nullptr" HAS_CXX11_NULLPTR) -cxx11_check_feature("regex" HAS_CXX11_LIB_REGEX) -cxx11_check_feature("rvalue-references" HAS_CXX11_RVALUE_REFERENCES) -cxx11_check_feature("sizeof_member" HAS_CXX11_SIZEOF_MEMBER) +#cxx11_check_feature("decltype" HAS_CXX11_DECLTYPE) +#cxx11_check_feature("initializer_list" HAS_CXX11_INITIALIZER_LIST) +#cxx11_check_feature("lambda" HAS_CXX11_LAMBDA) +#cxx11_check_feature("long_long" HAS_CXX11_LONG_LONG) +#cxx11_check_feature("nullptr" HAS_CXX11_NULLPTR) +#cxx11_check_feature("regex" HAS_CXX11_LIB_REGEX) +#cxx11_check_feature("rvalue-references" HAS_CXX11_RVALUE_REFERENCES) +#cxx11_check_feature("sizeof_member" HAS_CXX11_SIZEOF_MEMBER) cxx11_check_feature("static_assert" HAS_CXX11_STATIC_ASSERT) -cxx11_check_feature("variadic_templates" HAS_CXX11_VARIADIC_TEMPLATES) +#cxx11_check_feature("variadic_templates" HAS_CXX11_VARIADIC_TEMPLATES) cxx11_check_feature("shared_ptr" HAS_CXX11_SHARED_PTR)