aboutsummaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt78
1 files changed, 66 insertions, 12 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3d9b999..fce2a50 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,6 +8,7 @@ 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>?")
+set(ENTITYX_BUILD_SHARED true CACHE BOOL "Build shared libraries?")
include(${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
include(CheckCXXSourceCompiles)
@@ -40,9 +41,10 @@ macro(create_test TARGET_NAME SOURCE)
entityx
gtest
gtest_main
- ${Boost_LIBRARIES}
+ ${Boost_SYSTEM_LIBRARY}
${Boost_TIMER_LIBRARY}
${Boost_SIGNALS_LIBRARY}
+ ${ARGN}
)
add_test(${TARGET_NAME} ${TARGET_NAME})
endmacro()
@@ -69,19 +71,62 @@ 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)
+find_package(Boost 1.48.0 COMPONENTS python)
+
include_directories(${Boost_INCLUDE_DIR})
+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")
+
+# Things to install
+set(install_libs entityx)
include(CheckCXX11SharedPtr.cmake)
-set(sources entityx/System.cc entityx/Event.cc entityx/Entity.cc entityx/Manager.cc)
+set(sources entityx/tags/TagsComponent.cc entityx/System.cc entityx/Event.cc entityx/Entity.cc entityx/Manager.cc)
add_library(entityx STATIC ${sources})
-add_library(entityx_shared SHARED ${sources})
-target_link_libraries(
- entityx_shared
- ${Boost_SIGNALS_LIBRARY}
-)
-set_target_properties(entityx_shared PROPERTIES OUTPUT_NAME entityx)
+if (ENTITYX_BUILD_SHARED)
+ message("-- Building shared libraries (-DENTITYX_BUILD_SHARED=0 to only build static librarires)")
+ add_library(entityx_shared SHARED ${sources})
+ target_link_libraries(
+ entityx_shared
+ ${Boost_SIGNALS_LIBRARY}
+ )
+ set_target_properties(entityx_shared PROPERTIES OUTPUT_NAME entityx)
+ list(APPEND install_libs entityx_shared)
+endif (ENTITYX_BUILD_SHARED)
+
+include_directories(${Boost_INCLUDE_DIR})
+
+if (Boost_PYTHON_LIBRARY)
+ message("-- Found boost::python, building entityx/python")
+ find_package(PythonLibs REQUIRED)
+ include_directories(${PYTHON_INCLUDE_DIRS})
+ set(ENTITYX_HAVE_BOOST_PYTHON 1)
+ set(python_sources entityx/python/PythonSystem.cc)
+ add_library(entityx_python STATIC ${python_sources})
+ list(APPEND install_libs entityx_python)
+ install(
+ FILES ${CMAKE_CURRENT_SOURCE_DIR}/entityx/python/entityx/__init__.py
+ DESTINATION share/entityx/python/
+ RENAME entityx.py
+ )
+ message("-- Installing entityx Python package to ${CMAKE_INSTALL_PREFIX}/share/entityx/python")
+ set(ENTITYX_INSTALLED_PYTHON_PACKAGE_DIR ${CMAKE_INSTALL_PREFIX}/share/entityx/python/)
+ if (ENTITYX_BUILD_SHARED)
+ add_library(entityx_python_shared SHARED ${python_sources})
+ target_link_libraries(
+ entityx_python_shared
+ entityx_shared
+ ${Boost_PYTHON_LIBRARY}
+ ${PYTHON_LIBRARIES}
+ )
+ set_target_properties(entityx_python_shared PROPERTIES OUTPUT_NAME entityx_python)
+ list(APPEND install_libs entityx_python_shared)
+ endif (ENTITYX_BUILD_SHARED)
+endif (Boost_PYTHON_LIBRARY)
if (ENTITYX_BUILD_TESTING)
find_package(Boost 1.48.0 REQUIRED COMPONENTS signals timer system)
@@ -92,6 +137,10 @@ if (ENTITYX_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 (Boost_PYTHON_LIBRARY)
+ add_definitions(-DENTITYX_PYTHON_TEST_DATA=\"${CMAKE_CURRENT_SOURCE_DIR}/entityx/python\")
+ create_test(python_test entityx/python/PythonSystem_test.cc entityx_python ${Boost_PYTHON_LIBRARY} ${PYTHON_LIBRARIES})
+ endif (Boost_PYTHON_LIBRARY)
if (ENTITYX_RUN_BENCHMARKS)
message("-- Running benchmarks")
add_definitions(-DGTEST_USE_OWN_TR1_TUPLE=1 -DBOOST_NO_CXX11_NUMERIC_LIMITS=1)
@@ -101,15 +150,20 @@ if (ENTITYX_BUILD_TESTING)
endif ()
endif (ENTITYX_BUILD_TESTING)
-file(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/entityx/*.h")
+
+configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/entityx/config.h.in
+ ${CMAKE_CURRENT_SOURCE_DIR}/entityx/config.h
+)
install(
- FILES ${headers}
- DESTINATION "include/entityx"
+ DIRECTORY "entityx"
+ DESTINATION "include"
+ FILES_MATCHING PATTERN "*.h"
)
install(
- TARGETS entityx entityx_shared
+ TARGETS ${install_libs}
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)