diff options
author | Alec Thomas <alec@swapoff.org> | 2013-04-01 11:51:29 -0400 |
---|---|---|
committer | Alec Thomas <alec@swapoff.org> | 2013-04-03 22:45:17 -0400 |
commit | 17725f8f24460ca6189afd106df3ad122a5777c3 (patch) | |
tree | e675b1bd3a7d48163bece5f35f0463ef6388d436 /CheckCXX11SharedPtr.cmake | |
parent | 93d3770b874ad010523f4e6bb675f680de4b9fdf (diff) |
All Manager classes are now managed by smart pointers.
Diffstat (limited to 'CheckCXX11SharedPtr.cmake')
-rw-r--r-- | CheckCXX11SharedPtr.cmake | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/CheckCXX11SharedPtr.cmake b/CheckCXX11SharedPtr.cmake new file mode 100644 index 0000000..24dc871 --- /dev/null +++ b/CheckCXX11SharedPtr.cmake @@ -0,0 +1,60 @@ +cmake_minimum_required(VERSION 2.8.3) + +if (ENTITYX_USE_CPP11_STDLIB) + 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 () +else () + message("-- Using default stdlib (try -DENTITYX_USE_CPP11_STDLIB=1 to use -stdlib=libc++)") +endif () + +check_cxx_source_compiles( +" +#include <memory> + +int main() { std::shared_ptr<int>(); } +" +ENTITYX_HAVE_STD_SHARED_PTR +) + +check_cxx_source_compiles( +" +#include <boost/shared_ptr.hpp> + +int main() { boost::shared_ptr<int>(); } +" +ENTITYX_HAVE_BOOST_SHARED_PTR +) + +if (ENTITYX_HAVE_STD_SHARED_PTR AND ENTITYX_USE_STD_SHARED_PTR) + message("-- Using std::shared_ptr<T>") +else() + if (ENTITYX_USE_STD_SHARED_PTR) + message("-- Using boost::shared_ptr<T> (std::shared_ptr<T> could not be used)") + else() + message("-- Using boost::shared_ptr<T> (try -DENTITYX_USE_STD_SHARED_PTR=1 to use std::shared_ptr<T>)") + endif() +endif() + +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/entityx/config.h.in + ${CMAKE_CURRENT_SOURCE_DIR}/entityx/config.h +) + |