aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJarrett Chisholm <j.chisholm@chisholmsoft.com>2014-02-11 20:17:46 -0500
committerAlec Thomas <alec@swapoff.org>2014-02-13 14:15:11 +1100
commite866fa4e7a781eb7e4de37a03ddfa191d5edd522 (patch)
tree45918deaa294af7c9bfabac2de8be78baee00457
parent851b198c999a0b11996b02a5e2192e517e161276 (diff)
Fixed compile issues on Windows with Visual Studio 2013.
- Made compiler flags dependent on the compiler being used. - Added check for clang to use the same compiler options as gnu g++
-rw-r--r--CHANGES.md6
-rw-r--r--CMakeLists.txt44
-rw-r--r--README.md6
-rw-r--r--entityx/3rdparty/simplesignal.h4
-rw-r--r--entityx/Event.h2
5 files changed, 47 insertions, 15 deletions
diff --git a/CHANGES.md b/CHANGES.md
index e4484af..9258362 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,5 +1,11 @@
# Change Log
+## 2014-02-13 - Support for Visual C++
+
+[Jarrett Chisholm](https://github.com/jarrettchisholm) has added conditional compilation support for VC++ and fixed some issues that prevented compilation, so EntityX now fully supports Visual C++!
+
+You will need at least [Visual Studio 2013](http://www.microsoft.com/en-ca/download/details.aspx?id=40787) with [Update 1](http://www.microsoft.com/en-us/download/details.aspx?id=41650) and [Update 2 CTP](http://www.microsoft.com/en-us/download/details.aspx?id=41699) installed. The usual CMake installation instructions should "just work" and correctly provide VC++ support.
+
## 2013-10-29 [no-boost branch] - Removed boost dependency for everything except python integration.
This branch requires C++11 support and has removed all the non-boost::python dependecies, reducing the overhead of running entityx.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fc89cd3..f996eb9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -18,18 +18,31 @@ include(${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
include(CheckCXXSourceCompiles)
# Default compiler args
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Werror -Wall -Wextra -Wno-unused-parameter -Wno-error=unused-variable -Wno-error=sign-compare -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")
+if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Werror -Wall -Wextra -Wno-unused-parameter -Wno-error=unused-variable -Wno-error=sign-compare -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")
+elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
+ # /Zi - Produces a program database (PDB) that contains type information and symbolic debugging information for use with the debugger.
+ # /FS - Allows multiple cl.exe processes to write to the same .pdb file
+ # /DEBUG - Enable debug during linking
+ # /Od - Disables optimization
+ set(CMAKE_CXX_FLAGS_DEBUG "/Zi /FS /DEBUG /Od")
+ # /Ox - Full optimization
+ set(CMAKE_CXX_FLAGS_RELEASE "/Ox -DNDEBUG")
+ set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/Ox /Zi /FS /DEBUG")
+endif()
# 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++")
+if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
+endif()
check_cxx_source_compiles(
"
#include <memory>
@@ -90,10 +103,21 @@ require(HAS_CXX11_LONG_LONG "C++11 lambdas")
message("-- Checking misc features")
require(HAVE_STDINT_H "stdint.h")
-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")
+if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+ 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")
+elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
+ # /Zi - Produces a program database (PDB) that contains type information and symbolic debugging information for use with the debugger.
+ # /FS - Allows multiple cl.exe processes to write to the same .pdb file
+ # /DEBUG - Enable debug during linking
+ # /Od - Disables optimization
+ set(CMAKE_CXX_FLAGS_DEBUG "/Zi /FS /DEBUG /Od")
+ # /Ox - Full optimization
+ set(CMAKE_CXX_FLAGS_RELEASE "/Ox -DNDEBUG")
+ set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/Ox /Zi /FS /DEBUG")
+endif()
# Things to install
set(install_libs entityx)
diff --git a/README.md b/README.md
index 503e56f..ee1fe5e 100644
--- a/README.md
+++ b/README.md
@@ -27,6 +27,7 @@ You can also contact me directly via [email](mailto:alec@swapoff.org) or [Twitte
## Recent Notable Changes
+- 2014-02-13 - Visual C++ support thanks to [Jarrett Chisholm](https://github.com/jarrettchisholm)!
- 2013-10-29 - Boost has been removed as a primary dependency for builds not using python.
- 2013-08-21 - Remove dependency on `boost::signal` and switch to embedded [Simple::Signal](http://timj.testbit.eu/2013/cpp11-signal-system-performance/).
- 2013-08-18 - Destroying an entity invalidates all other references
@@ -320,12 +321,13 @@ while (true) {
EntityX has the following build and runtime requirements:
-- A C++ compiler that supports a basic set of C++11 features (ie. Clang >= 3.1, GCC >= 4.7, and maybe (untested) VC++ with the [Nov 2012 CTP](http://www.microsoft.com/en-us/download/details.aspx?id=35515)).
+- A C++ compiler that supports a basic set of C++11 features (ie. Clang >= 3.1, GCC >= 4.7, and Visual C++.
+- For Visual C++ support you will need at least [Visual Studio 2013](http://www.microsoft.com/en-ca/download/details.aspx?id=40787) with [Update 1](http://www.microsoft.com/en-us/download/details.aspx?id=41650) and [Update 2 CTP](http://www.microsoft.com/en-us/download/details.aspx?id=41699) installed.
- [CMake](http://cmake.org/)
### C++11 compiler and library support
-C++11 support is quite...raw. To make life more interesting, C++ support really means two things: language features supported by the compiler, and library features.
+C++11 support is quite...raw. To make life more interesting, C++ support really means two things: language features supported by the compiler, and library features. EntityX tries to support the most common options, including the default C++ library for the compiler/platform, and libstdc++.
### Installing on OSX Mountain Lion
diff --git a/entityx/3rdparty/simplesignal.h b/entityx/3rdparty/simplesignal.h
index 0af2644..39bb2fb 100644
--- a/entityx/3rdparty/simplesignal.h
+++ b/entityx/3rdparty/simplesignal.h
@@ -2,10 +2,10 @@
#ifndef SIMPLE_SIGNAL_H__
#define SIMPLE_SIGNAL_H__
-#include <unistd.h>
#include <assert.h>
#include <stdint.h>
#include <vector>
+#include <functional>
namespace Simple {
@@ -81,7 +81,7 @@ private:
void
unlink ()
{
- function = 0;
+ function = nullptr;
if (next)
next->prev = prev;
if (prev)
diff --git a/entityx/Event.h b/entityx/Event.h
index dac1bb4..8c8a8dc 100644
--- a/entityx/Event.h
+++ b/entityx/Event.h
@@ -160,7 +160,7 @@ class EventManager : entityx::help::NonCopyable {
*/
template <typename E, typename ... Args>
void emit(Args && ... args) {
- E event(std::forward<Args>(args) ...);
+ E event = E(std::forward<Args>(args) ...);
auto sig = signal_for(E::family());
sig->emit(static_cast<BaseEvent*>(&event));
}