Merge branch 'feature/cmake-cxx11-detect' into develop
This commit is contained in:
commit
b0b0216e67
@ -69,6 +69,8 @@ if(CMAKE_CXX_COMPILER MATCHES "clang")
|
|||||||
ADD_DEFINITIONS(-std=c++0x) #Enable C++0x mode
|
ADD_DEFINITIONS(-std=c++0x) #Enable C++0x mode
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
INCLUDE(cmake/Modules/CheckCXX11Features.cmake)
|
||||||
|
|
||||||
ADD_SUBDIRECTORY(library)
|
ADD_SUBDIRECTORY(library)
|
||||||
|
|
||||||
OPTION(ENABLE_EXAMPLES "Should the examples be built" ON)
|
OPTION(ENABLE_EXAMPLES "Should the examples be built" ON)
|
||||||
|
133
cmake/Modules/CheckCXX11Features.cmake
Normal file
133
cmake/Modules/CheckCXX11Features.cmake
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
# - 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 <eike@sf-mail.de>
|
||||||
|
# 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)
|
||||||
|
cxx11_check_feature("shared_ptr" HAS_CXX11_SHARED_PTR)
|
8
cmake/Modules/CheckCXX11Features/cxx11-test-__func__.cpp
Normal file
8
cmake/Modules/CheckCXX11Features/cxx11-test-__func__.cpp
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
if (!__func__)
|
||||||
|
return 1;
|
||||||
|
if (!(*__func__))
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
12
cmake/Modules/CheckCXX11Features/cxx11-test-auto.cpp
Normal file
12
cmake/Modules/CheckCXX11Features/cxx11-test-auto.cpp
Normal file
@ -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;
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
// must fail because there is no initializer
|
||||||
|
auto i;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
auto foo(int i) -> int {
|
||||||
|
return i - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
return foo(1);
|
||||||
|
}
|
@ -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;
|
||||||
|
}
|
@ -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;
|
||||||
|
}
|
19
cmake/Modules/CheckCXX11Features/cxx11-test-constexpr.cpp
Normal file
19
cmake/Modules/CheckCXX11Features/cxx11-test-constexpr.cpp
Normal file
@ -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;
|
||||||
|
}
|
11
cmake/Modules/CheckCXX11Features/cxx11-test-cstdint.cpp
Normal file
11
cmake/Modules/CheckCXX11Features/cxx11-test-cstdint.cpp
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
bool test =
|
||||||
|
(sizeof(int8_t) == 1) &&
|
||||||
|
(sizeof(int16_t) == 2) &&
|
||||||
|
(sizeof(int32_t) == 4) &&
|
||||||
|
(sizeof(int64_t) == 8);
|
||||||
|
return test ? 0 : 1;
|
||||||
|
}
|
10
cmake/Modules/CheckCXX11Features/cxx11-test-decltype.cpp
Normal file
10
cmake/Modules/CheckCXX11Features/cxx11-test-decltype.cpp
Normal file
@ -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;
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
#include <vector>
|
||||||
|
|
||||||
|
class seq {
|
||||||
|
public:
|
||||||
|
seq(std::initializer_list<int> list);
|
||||||
|
|
||||||
|
int length() const;
|
||||||
|
private:
|
||||||
|
std::vector<int> m_v;
|
||||||
|
};
|
||||||
|
|
||||||
|
seq::seq(std::initializer_list<int> 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;
|
||||||
|
}
|
5
cmake/Modules/CheckCXX11Features/cxx11-test-lambda.cpp
Normal file
5
cmake/Modules/CheckCXX11Features/cxx11-test-lambda.cpp
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
int main()
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
return ([&ret]() -> int { return ret; })();
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
long long l;
|
||||||
|
unsigned long long ul;
|
||||||
|
|
||||||
|
return ((sizeof(l) >= 8) && (sizeof(ul) >= 8)) ? 0 : 1;
|
||||||
|
}
|
6
cmake/Modules/CheckCXX11Features/cxx11-test-nullptr.cpp
Normal file
6
cmake/Modules/CheckCXX11Features/cxx11-test-nullptr.cpp
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
void *v = nullptr;
|
||||||
|
|
||||||
|
return v ? 1 : 0;
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
int i = nullptr;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
26
cmake/Modules/CheckCXX11Features/cxx11-test-regex.cpp
Normal file
26
cmake/Modules/CheckCXX11Features/cxx11-test-regex.cpp
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#include <algorithm>
|
||||||
|
#include <regex>
|
||||||
|
|
||||||
|
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<int>(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;
|
||||||
|
}
|
@ -0,0 +1,57 @@
|
|||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
#include <memory>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
std::shared_ptr<int> test;
|
||||||
|
return 0;
|
||||||
|
}
|
@ -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;
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
struct foo {
|
||||||
|
int baz;
|
||||||
|
double bar;
|
||||||
|
};
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
return (sizeof(foo::bar) == 4) ? 0 : 1;
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
static_assert(0 < 1, "your ordering of integers is screwed");
|
||||||
|
return 0;
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
static_assert(1 < 0, "your ordering of integers is screwed");
|
||||||
|
return 0;
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
int Accumulate()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename... Ts>
|
||||||
|
int Accumulate(T v, Ts... vs)
|
||||||
|
{
|
||||||
|
return v + Accumulate(vs...);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<int... Is>
|
||||||
|
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;
|
||||||
|
}
|
@ -44,7 +44,7 @@ SOURCE_GROUP("Headers" FILES ${INC_FILES})
|
|||||||
FIND_PACKAGE(OpenGL REQUIRED)
|
FIND_PACKAGE(OpenGL REQUIRED)
|
||||||
|
|
||||||
#Tell CMake the paths for OpenGL and for PolyVox (which is just relative to our current location)
|
#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 ${GLEW_SOURCE_DIR})
|
INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${PolyVoxCore_SOURCE_DIR}/include ${PolyVoxCore_BINARY_DIR}/include ${GLEW_SOURCE_DIR})
|
||||||
LINK_DIRECTORIES(${PolyVoxCore_BINARY_DIR})
|
LINK_DIRECTORIES(${PolyVoxCore_BINARY_DIR})
|
||||||
|
|
||||||
#Build
|
#Build
|
||||||
|
@ -52,7 +52,7 @@ SOURCE_GROUP("Headers" FILES ${INC_FILES})
|
|||||||
FIND_PACKAGE(OpenGL REQUIRED)
|
FIND_PACKAGE(OpenGL REQUIRED)
|
||||||
|
|
||||||
#Tell CMake the paths for OpenGL and for PolyVox (which is just relative to our current location)
|
#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 ${GLEW_SOURCE_DIR})
|
INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${PolyVoxCore_SOURCE_DIR}/include ${PolyVoxCore_BINARY_DIR}/include ${GLEW_SOURCE_DIR})
|
||||||
LINK_DIRECTORIES(${PolyVoxCore_BINARY_DIR})
|
LINK_DIRECTORIES(${PolyVoxCore_BINARY_DIR})
|
||||||
|
|
||||||
#Build
|
#Build
|
||||||
|
@ -46,7 +46,7 @@ SOURCE_GROUP("Headers" FILES ${INC_FILES})
|
|||||||
FIND_PACKAGE(OpenGL REQUIRED)
|
FIND_PACKAGE(OpenGL REQUIRED)
|
||||||
|
|
||||||
#Tell CMake the paths for OpenGL and for PolyVox (which is just relative to our current location)
|
#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 ${GLEW_SOURCE_DIR})
|
INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${PolyVoxCore_SOURCE_DIR}/include ${PolyVoxCore_BINARY_DIR}/include ${GLEW_SOURCE_DIR})
|
||||||
LINK_DIRECTORIES(${PolyVoxCore_BINARY_DIR})
|
LINK_DIRECTORIES(${PolyVoxCore_BINARY_DIR})
|
||||||
|
|
||||||
#Build
|
#Build
|
||||||
|
@ -44,7 +44,7 @@ SOURCE_GROUP("Headers" FILES ${INC_FILES})
|
|||||||
FIND_PACKAGE(OpenGL REQUIRED)
|
FIND_PACKAGE(OpenGL REQUIRED)
|
||||||
|
|
||||||
#Tell CMake the paths for OpenGL and for PolyVox (which is just relative to our current location)
|
#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 ${GLEW_SOURCE_DIR})
|
INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${PolyVoxCore_SOURCE_DIR}/include ${PolyVoxCore_BINARY_DIR}/include ${GLEW_SOURCE_DIR})
|
||||||
LINK_DIRECTORIES(${PolyVoxCore_BINARY_DIR})
|
LINK_DIRECTORIES(${PolyVoxCore_BINARY_DIR})
|
||||||
|
|
||||||
#Build
|
#Build
|
||||||
|
@ -24,6 +24,9 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
|
|||||||
|
|
||||||
PROJECT(PolyVoxCore)
|
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
|
#Projects source files
|
||||||
SET(CORE_SRC_FILES
|
SET(CORE_SRC_FILES
|
||||||
source/ArraySizes.cpp
|
source/ArraySizes.cpp
|
||||||
@ -123,7 +126,7 @@ SOURCE_GROUP("Sources\\Impl" FILES ${IMPL_SRC_FILES})
|
|||||||
SOURCE_GROUP("Headers\\Impl" FILES ${IMPL_INC_FILES})
|
SOURCE_GROUP("Headers\\Impl" FILES ${IMPL_INC_FILES})
|
||||||
|
|
||||||
#Tell CMake the paths
|
#Tell CMake the paths
|
||||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
|
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_BINARY_DIR}/include)
|
||||||
|
|
||||||
#Core
|
#Core
|
||||||
#Build
|
#Build
|
||||||
|
@ -0,0 +1,12 @@
|
|||||||
|
#ifndef __PolyVox_CompilerCapabilities_H__
|
||||||
|
#define __PolyVox_CompilerCapabilities_H__
|
||||||
|
|
||||||
|
#cmakedefine HAS_CXX11_CONSTEXPR
|
||||||
|
|
||||||
|
#cmakedefine HAS_CXX11_STATIC_ASSERT
|
||||||
|
|
||||||
|
#cmakedefine HAS_CXX11_CSTDINT_H
|
||||||
|
|
||||||
|
#cmakedefine HAS_CXX11_SHARED_PTR
|
||||||
|
|
||||||
|
#endif
|
@ -24,6 +24,8 @@ freely, subject to the following restrictions:
|
|||||||
#ifndef __PolyVox_TypeDef_H__
|
#ifndef __PolyVox_TypeDef_H__
|
||||||
#define __PolyVox_TypeDef_H__
|
#define __PolyVox_TypeDef_H__
|
||||||
|
|
||||||
|
#include "PolyVoxCore/Impl/CompilerCapabilities.h"
|
||||||
|
|
||||||
//Definitions needed to make library functions accessable
|
//Definitions needed to make library functions accessable
|
||||||
// See http://gcc.gnu.org/wiki/Visibility for more info.
|
// See http://gcc.gnu.org/wiki/Visibility for more info.
|
||||||
#if defined _WIN32 || defined __CYGWIN__
|
#if defined _WIN32 || defined __CYGWIN__
|
||||||
@ -72,9 +74,6 @@ freely, subject to the following restrictions:
|
|||||||
//To support old (pre-vc2010) Microsoft compilers we use boost to replace the
|
//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
|
//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.
|
//will need to make sure you have boost installed on your system.
|
||||||
#include <boost/smart_ptr.hpp>
|
|
||||||
#define polyvox_shared_ptr boost::shared_ptr
|
|
||||||
|
|
||||||
#include <boost/function.hpp>
|
#include <boost/function.hpp>
|
||||||
#define polyvox_function boost::function
|
#define polyvox_function boost::function
|
||||||
|
|
||||||
@ -82,13 +81,33 @@ freely, subject to the following restrictions:
|
|||||||
#define polyvox_bind boost::bind
|
#define polyvox_bind boost::bind
|
||||||
#define polyvox_placeholder_1 _1
|
#define polyvox_placeholder_1 _1
|
||||||
#define polyvox_placeholder_2 _2
|
#define polyvox_placeholder_2 _2
|
||||||
|
#else
|
||||||
|
//We have a decent compiler - use real C++0x features
|
||||||
|
#include <functional>
|
||||||
|
#define polyvox_function std::function
|
||||||
|
#define polyvox_bind std::bind
|
||||||
|
#define polyvox_placeholder_1 std::placeholders::_1
|
||||||
|
#define polyvox_placeholder_2 std::placeholders::_2
|
||||||
|
#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
|
||||||
|
|
||||||
|
#if defined(HAS_CXX11_STATIC_ASSERT)
|
||||||
|
//In this case we can just use static_assert
|
||||||
|
#else
|
||||||
#include <boost/static_assert.hpp>
|
#include <boost/static_assert.hpp>
|
||||||
#define static_assert(condition, message) BOOST_STATIC_ASSERT(condition)
|
#define static_assert(condition, message) BOOST_STATIC_ASSERT(condition)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAS_CXX11_CSTDINT_H)
|
||||||
//As long as we're requiring boost, we'll use it to compensate
|
#include <cstdint>
|
||||||
//for the missing cstdint header too.
|
#else
|
||||||
#include <boost/cstdint.hpp>
|
#include <boost/cstdint.hpp>
|
||||||
using boost::int8_t;
|
using boost::int8_t;
|
||||||
using boost::int16_t;
|
using boost::int16_t;
|
||||||
@ -96,17 +115,14 @@ freely, subject to the following restrictions:
|
|||||||
using boost::uint8_t;
|
using boost::uint8_t;
|
||||||
using boost::uint16_t;
|
using boost::uint16_t;
|
||||||
using boost::uint32_t;
|
using boost::uint32_t;
|
||||||
#else
|
#endif
|
||||||
//We have a decent compiler - use real C++0x features
|
|
||||||
#include <cstdint>
|
#if defined(HAS_CXX11_SHARED_PTR)
|
||||||
#include <functional>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#define polyvox_shared_ptr std::shared_ptr
|
#define polyvox_shared_ptr std::shared_ptr
|
||||||
#define polyvox_function std::function
|
#else
|
||||||
#define polyvox_bind std::bind
|
#include <boost/smart_ptr.hpp>
|
||||||
#define polyvox_placeholder_1 std::placeholders::_1
|
#define polyvox_shared_ptr boost::shared_ptr
|
||||||
#define polyvox_placeholder_2 std::placeholders::_2
|
|
||||||
//#define static_assert static_assert //we can use this
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -42,7 +42,7 @@ SOURCE_GROUP("Sources" FILES ${UTIL_SRC_FILES})
|
|||||||
SOURCE_GROUP("Headers" FILES ${UTIL_INC_FILES})
|
SOURCE_GROUP("Headers" FILES ${UTIL_INC_FILES})
|
||||||
|
|
||||||
#Tell CMake the paths
|
#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!
|
#There has to be a better way!
|
||||||
LINK_DIRECTORIES(${PolyVoxCore_BINARY_DIR}/debug ${PolyVoxCore_BINARY_DIR}/release ${PolyVoxCore_BINARY_DIR})
|
LINK_DIRECTORIES(${PolyVoxCore_BINARY_DIR}/debug ${PolyVoxCore_BINARY_DIR}/release ${PolyVoxCore_BINARY_DIR})
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ if(ENABLE_BINDINGS)
|
|||||||
include(${SWIG_USE_FILE})
|
include(${SWIG_USE_FILE})
|
||||||
|
|
||||||
include_directories(${PYTHON_INCLUDE_PATH})
|
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})
|
link_directories(${PolyVoxCore_BINARY_DIR})
|
||||||
|
|
||||||
set(CMAKE_SWIG_FLAGS "")
|
set(CMAKE_SWIG_FLAGS "")
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
%module PolyVoxCore
|
%module PolyVoxCore
|
||||||
|
|
||||||
#define POLYVOX_API
|
#define POLYVOX_API
|
||||||
|
%include "PolyVoxCore/Impl/CompilerCapabilities.h"
|
||||||
%include "Impl/TypeDef.h"
|
%include "Impl/TypeDef.h"
|
||||||
#define __attribute__(x) //Silence DEPRECATED errors
|
#define __attribute__(x) //Silence DEPRECATED errors
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ MACRO(CREATE_TEST headerfile sourcefile executablename)
|
|||||||
SET_PROPERTY(TARGET ${executablename} PROPERTY FOLDER "Tests")
|
SET_PROPERTY(TARGET ${executablename} PROPERTY FOLDER "Tests")
|
||||||
ENDMACRO(CREATE_TEST)
|
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
|
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.
|
# Test Template. Copy and paste this template for consistant naming.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user