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 /CMakeLists.txt | |
parent | 93d3770b874ad010523f4e6bb675f680de4b9fdf (diff) |
All Manager classes are now managed by smart pointers.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 88 |
1 files changed, 15 insertions, 73 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b6c527..3d9b999 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,12 @@ cmake_minimum_required(VERSION 2.8) project(EntityX) include_directories(${CMAKE_CURRENT_LIST_DIR}) -set(RUN_BENCHMARKS false CACHE BOOL "Run benchmarks") +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 "Use the C++11 stdlib (-stdlib=libc++).") +# Check for which shared_ptr implementation to use. +set(ENTITYX_USE_STD_SHARED_PTR false CACHE BOOL "Use std::shared_ptr<T> rather than boost::shared_ptr<T>?") include(${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake) include(CheckCXXSourceCompiles) @@ -20,68 +25,6 @@ include(CheckCXX11Features.cmake) # Misc features check_include_file("stdint.h" HAVE_STDINT_H) -set(USE_CPP11_STDLIB false CACHE BOOL "Use the C++11 stdlib (-stdlib=libc++).") - -if (USE_CPP11_STDLIB) - 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>(); - } - " - HAVE_CXX11_STDLIB - ) - - if (NOT 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 -DUSE_CPP11_STDLIB=1 to use -stdlib=libc++)") -endif () - -# Check for which shared_ptr implementation to use. -set(USE_STD_SHARED_PTR false CACHE BOOL "Use std::shared_ptr<T> rather than boost::shared_ptr<T>?") - -check_cxx_source_compiles( -" -#include <memory> - -int main() { std::shared_ptr<int>(); } -" -HAVE_STD_SHARED_PTR -) - -check_cxx_source_compiles( -" -#include <boost/shared_ptr.hpp> - -int main() { boost::shared_ptr<int>(); } -" -HAVE_BOOST_SHARED_PTR -) - -if (HAVE_STD_SHARED_PTR AND USE_STD_SHARED_PTR) - message("-- Using std::shared_ptr<T>") -else() - if (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 -DUSE_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 -) - macro(require FEATURE_NAME MESSAGE_STRING) if (NOT ${${FEATURE_NAME}}) message(FATAL_ERROR "${MESSAGE_STRING} required -- ${${FEATURE_NAME}}") @@ -126,6 +69,9 @@ set(Boost_USE_STATIC_LIBS OFF) set(Boost_USE_MULTITHREADED ON) set(Boost_USE_STATIC_RUNTIME OFF) find_package(Boost 1.48.0 REQUIRED COMPONENTS signals) +include_directories(${Boost_INCLUDE_DIR}) + +include(CheckCXX11SharedPtr.cmake) set(sources entityx/System.cc entityx/Event.cc entityx/Entity.cc entityx/Manager.cc) add_library(entityx STATIC ${sources}) @@ -134,15 +80,10 @@ target_link_libraries( entityx_shared ${Boost_SIGNALS_LIBRARY} ) -set_target_properties(entityx_shared PROPERTIES OUTPUT_NAME entityx) -include_directories( - ${Boost_INCLUDE_DIR} - ${GTest_INCLUDE_DIR} - ) +set_target_properties(entityx_shared PROPERTIES OUTPUT_NAME entityx) -set(BUILD_TESTING false CACHE BOOL "Enable building of tests") -if (BUILD_TESTING) +if (ENTITYX_BUILD_TESTING) find_package(Boost 1.48.0 REQUIRED COMPONENTS signals timer system) add_subdirectory(gtest-1.6.0) include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR}) @@ -151,13 +92,14 @@ if (BUILD_TESTING) create_test(event_test entityx/Event_test.cc) create_test(system_test entityx/System_test.cc) create_test(tags_component_test entityx/tags/TagsComponent_test.cc) - if (RUN_BENCHMARKS) + if (ENTITYX_RUN_BENCHMARKS) message("-- Running benchmarks") + add_definitions(-DGTEST_USE_OWN_TR1_TUPLE=1 -DBOOST_NO_CXX11_NUMERIC_LIMITS=1) create_test(benchmarks_test entityx/Benchmarks_test.cc) else () - message("-- Not running benchmarks (use -DRUN_BENCHMARKS=1 to enable)") + message("-- Not running benchmarks (use -DENTITYX_RUN_BENCHMARKS=1 to enable)") endif () -endif (BUILD_TESTING) +endif (ENTITYX_BUILD_TESTING) file(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/entityx/*.h") |