cmake_minimum_required(VERSION 2.8)
project(EntityX)
-include_directories(.)
+include_directories(. ./c++11)
+
+# C++11 feature checks
+include(CheckCXX11Features.cmake)
+
+MACRO(REQUIRE FEATURE_NAME MESSAGE_STRING)
+ if (NOT DEFINED ${FEATURE_NAME})
+ message(FATAL_ERROR ${MESSAGE_STRING})
+ endif()
+ENDMACRO(REQUIRE)
+
+require(HAS_CXX11_AUTO "C++11 auto support is required")
+require(HAS_CXX11_NULLPTR "C++11 nullptr support is required")
+require(HAS_CXX11_RVALUE_REFERENCES "C++11 rvalue reference support is required")
+require(HAS_CXX11_CSTDINT_H "C++11 stdint support is required")
+require(HAS_CXX11_VARIADIC_TEMPLATES "C++11 variadic templates required")
+
enable_testing()
find_package(GTest REQUIRED)
set(Boost_USE_STATIC_LIBS OFF)
#find_package(Boost REQUIRED COMPONENTS)
find_package(Boost 1.36.0 REQUIRED COMPONENTS signals)
+set(CMAKE_CXX_FLAGS "-ansi -pedantic -Werror -Wall -Wextra -Wno-unused-parameter -Wno-error=unused-variable -std=c++11")
+set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
+set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
+set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
+set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
+
+
include_directories(
${Boost_INCLUDE_DIR}
${GTest_INCLUDE_DIR}
)
-add_definitions(
- -ansi -pedantic -Werror -Wall -Wextra -Wno-unused-parameter -Wno-error=unused-variable -std=c++11
- )
add_executable(
entityx_test
entityx/Components_test.cc
--- /dev/null
+# Checks for C++11 features\r
+# CXX11_FEATURE_LIST - a list containing all supported features\r
+# HAS_CXX11_AUTO - auto keyword\r
+# HAS_CXX11_NULLPTR - nullptr\r
+# HAS_CXX11_LAMBDA - lambdas\r
+# HAS_CXX11_STATIC_ASSERT - static_assert()\r
+# HAS_CXX11_RVALUE_REFERENCES - rvalue references\r
+# HAS_CXX11_DECLTYPE - decltype keyword\r
+# HAS_CXX11_CSTDINT_H - cstdint header\r
+# HAS_CXX11_LONG_LONG - long long signed & unsigned types\r
+# HAS_CXX11_VARIADIC_TEMPLATES - variadic templates\r
+# HAS_CXX11_CONSTEXPR - constexpr keyword\r
+# HAS_CXX11_SIZEOF_MEMBER - sizeof() non-static members\r
+# HAS_CXX11_FUNC - __func__ preprocessor constant\r
+#\r
+# Original script by Rolf Eike Beer\r
+# Modifications by Andreas Weis\r
+#\r
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8.3)\r
+\r
+SET(CHECK_CXX11_OLD_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})\r
+IF(CMAKE_COMPILER_IS_GNUCXX)\r
+ SET(CMAKE_CXX_FLAGS "-std=c++0x")\r
+endif()\r
+\r
+MACRO(CXX11_CHECK_FEATURE FEATURE_NAME FEATURE_NUMBER RESULT_VAR)\r
+ IF (NOT DEFINED ${RESULT_VAR})\r
+ SET(_bindir "${CMAKE_CURRENT_BINARY_DIR}/cxx11/cxx11_${FEATURE_NAME}")\r
+\r
+ IF (${FEATURE_NUMBER})\r
+ SET(_SRCFILE_BASE ${CMAKE_CURRENT_LIST_DIR}/c++11-test-${FEATURE_NAME}-N${FEATURE_NUMBER})\r
+ SET(_LOG_NAME "\"${FEATURE_NAME}\" (N${FEATURE_NUMBER})")\r
+ ELSE (${FEATURE_NUMBER})\r
+ SET(_SRCFILE_BASE ${CMAKE_CURRENT_LIST_DIR}/c++11-test-${FEATURE_NAME})\r
+ SET(_LOG_NAME "\"${FEATURE_NAME}\"")\r
+ ENDIF (${FEATURE_NUMBER})\r
+ MESSAGE(STATUS "Checking C++11 support for ${_LOG_NAME}")\r
+\r
+ SET(_SRCFILE "${_SRCFILE_BASE}.cpp")\r
+ SET(_SRCFILE_FAIL "${_SRCFILE_BASE}_fail.cpp")\r
+ SET(_SRCFILE_FAIL_COMPILE "${_SRCFILE_BASE}_fail_compile.cpp")\r
+\r
+ IF (CROSS_COMPILING)\r
+ try_compile(${RESULT_VAR} "${_bindir}" "${_SRCFILE}")\r
+ IF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})\r
+ try_compile(${RESULT_VAR} "${_bindir}_fail" "${_SRCFILE_FAIL}")\r
+ ENDIF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})\r
+ ELSE (CROSS_COMPILING)\r
+ try_run(_RUN_RESULT_VAR _COMPILE_RESULT_VAR\r
+ "${_bindir}" "${_SRCFILE}")\r
+ IF (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR)\r
+ SET(${RESULT_VAR} TRUE)\r
+ ELSE (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR)\r
+ SET(${RESULT_VAR} FALSE)\r
+ ENDIF (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR)\r
+ IF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})\r
+ try_run(_RUN_RESULT_VAR _COMPILE_RESULT_VAR\r
+ "${_bindir}_fail" "${_SRCFILE_FAIL}")\r
+ IF (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR)\r
+ SET(${RESULT_VAR} TRUE)\r
+ ELSE (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR)\r
+ SET(${RESULT_VAR} FALSE)\r
+ ENDIF (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR)\r
+ ENDIF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})\r
+ ENDIF (CROSS_COMPILING)\r
+ IF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL_COMPILE})\r
+ try_compile(_TMP_RESULT "${_bindir}_fail_compile" "${_SRCFILE_FAIL_COMPILE}")\r
+ IF (_TMP_RESULT)\r
+ SET(${RESULT_VAR} FALSE)\r
+ ELSE (_TMP_RESULT)\r
+ SET(${RESULT_VAR} TRUE)\r
+ ENDIF (_TMP_RESULT)\r
+ ENDIF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL_COMPILE})\r
+\r
+ IF (${RESULT_VAR})\r
+ MESSAGE(STATUS "Checking C++11 support for ${_LOG_NAME} -- works")\r
+ LIST(APPEND CXX11_FEATURE_LIST ${RESULT_VAR})\r
+ ELSE (${RESULT_VAR})\r
+ MESSAGE(STATUS "Checking C++11 support for ${_LOG_NAME} -- not supported")\r
+ ENDIF (${RESULT_VAR})\r
+ SET(${RESULT_VAR} ${${RESULT_VAR}} CACHE INTERNAL "C++11 support for ${_LOG_NAME}")\r
+ ENDIF (NOT DEFINED ${RESULT_VAR})\r
+ENDMACRO(CXX11_CHECK_FEATURE)\r
+\r
+CXX11_CHECK_FEATURE("auto" 2546 HAS_CXX11_AUTO)\r
+CXX11_CHECK_FEATURE("nullptr" 2431 HAS_CXX11_NULLPTR)\r
+CXX11_CHECK_FEATURE("lambda" 2927 HAS_CXX11_LAMBDA)\r
+CXX11_CHECK_FEATURE("static_assert" 1720 HAS_CXX11_STATIC_ASSERT)\r
+CXX11_CHECK_FEATURE("rvalue_references" 2118 HAS_CXX11_RVALUE_REFERENCES)\r
+CXX11_CHECK_FEATURE("decltype" 2343 HAS_CXX11_DECLTYPE)\r
+CXX11_CHECK_FEATURE("cstdint" "" HAS_CXX11_CSTDINT_H)\r
+CXX11_CHECK_FEATURE("long_long" 1811 HAS_CXX11_LONG_LONG)\r
+CXX11_CHECK_FEATURE("variadic_templates" 2555 HAS_CXX11_VARIADIC_TEMPLATES)\r
+CXX11_CHECK_FEATURE("constexpr" 2235 HAS_CXX11_CONSTEXPR)\r
+CXX11_CHECK_FEATURE("sizeof_member" 2253 HAS_CXX11_SIZEOF_MEMBER)\r
+CXX11_CHECK_FEATURE("__func__" 2340 HAS_CXX11_FUNC)\r
+\r
+SET(CXX11_FEATURE_LIST ${CXX11_FEATURE_LIST} CACHE STRING "C++11 feature support list")\r
+MARK_AS_ADVANCED(FORCE CXX11_FEATURE_LIST)\r
+\r
+SET(CMAKE_CXX_FLAGS ${CHECK_CXX11_OLD_CMAKE_CXX_FLAGS})\r
+UNSET(CHECK_CXX11_OLD_CMAKE_CXX_FLAGS)\r
+\r