set(ENTITYX_BUILD_TESTING false CACHE BOOL "Enable building of tests.")
set(ENTITYX_RUN_BENCHMARKS false CACHE BOOL "Run benchmarks (in conjunction with -DENTITYX_BUILD_TESTING=1).")
set(ENTITYX_MAX_COMPONENTS 64 CACHE STRING "Set the maximum number of components.")
-set(ENTITYX_USE_CPP11_STDLIB false CACHE BOOL "For Clang, specify whether to use libc++ (-stdlib=libc++).")
-# Check for which shared_ptr implementation to use.
+set(ENTITYX_USE_CPP11_STDLIB true CACHE BOOL "For Clang, specify whether to use libc++ (-stdlib=libc++).")
set(ENTITYX_BUILD_SHARED false CACHE BOOL "Build shared libraries?")
set(ENTITYX_BUILD_PYTHON false CACHE BOOL "Build entityx::python?")
# C++11 feature checks
include(CheckCXX11Features.cmake)
+add_definitions(-DGTEST_USE_OWN_TR1_TUPLE=1)
+set(OLD_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
+check_cxx_source_compiles(
+"
+#include <memory>
+
+int main() {
+ std::shared_ptr<int>();
+}
+"
+ENTITYX_HAVE_CXX11_STDLIB
+)
+
+if (NOT ENTITYX_HAVE_CXX11_STDLIB)
+ message("-- Not using -stdlib=libc++ (test failed to build)")
+ set(CMAKE_CXX_FLAGS "${OLD_CMAKE_CXX_FLAGS}")
+else ()
+ message("-- Using -stdlib=libc++")
+endif ()
+
+
# Misc features
check_include_file("stdint.h" HAVE_STDINT_H)
On OSX you must use Clang as the GCC version is practically prehistoric.
-EntityX can build against libstdc++ (GCC with no C++11 library support) or libc++ (Clang with C++11 library support), though you will need to ensure that Boost is built with the same standard library.
-
I use Homebrew, and the following works for me:
For libstdc++:
```bash
-cmake -DENTITYX_BUILD_SHARED=0 -DENTITYX_BUILD_TESTING=1 -DENTITYX_USE_CPP11_STDLIB=0 ..
-```
-
-For libc++ (with C++11 support):
-
-```bash
-cmake -DENTITYX_BUILD_SHARED=0 -DENTITYX_BUILD_TESTING=1 -DENTITYX_USE_CPP11_STDLIB=1 ..
+cmake -DENTITYX_BUILD_SHARED=0 -DENTITYX_BUILD_TESTING=1 ..
```
### Installing on Ubuntu 12.04
- `-DENTITYX_BUILD_PYTHON=1` - Build Python scripting integration.
- `-DENTITYX_BUILD_TESTING=1` - Build tests (run with `make test`).
- `-DENTITYX_RUN_BENCHMARKS=1` - In conjunction with `-DENTITYX_BUILD_TESTING=1`, also build benchmarks.
-- `-DENTITYX_USE_CPP11_STDLIB=1` - For Clang, specify whether to use `-stdlib=libc++`.
- `-DENTITYX_MAX_COMPONENTS=64` - Override the maximum number of components that can be assigned to each entity.
- `-DENTITYX_BUILD_SHARED=1` - Whether to build shared libraries (defaults to 1).
- `-DENTITYX_BUILD_TESTING=0` - Whether to build tests (defaults to 0). Run with "make && make test".