Box2D for GNU/Linux with cmake

Hi,

I was not aware of KIAaze's work about Makefile so I start an cmake support for Box2D as there's no support for my beloved Linux Box 🙂

So basicaly, retreive the file Box2D-v1.4.2-cmake.tar.gz at this address : https://gna.org/support/download.php?file_id=3202

Then you can do the classical things to do with cmake :

tar xfvz Box2D-v1.4.2-cmake.tar.gz
cd Box2D-v1.4.2-cmake/Box2D
cmake .
make

and then we will be able to launch ./Examples/framework.

Regards,

Yannig
Added file for cmake support :
CMakeLists.txt
Examples: CMakeLists.txt
Source: CMakeLists.txt

I have also fix a few issue due to uppercase/lowercase difference with Unix world (included header) and some warning about missing new line and some deprecated use of header files (new.h => new and memory.h => memory).

Modified file :
Box2D/Examples/TestBed/Framework/Main.cpp
Box2D/Examples/TestBed/Framework/Render.cpp
Box2D/Examples/TestBed/Framework/Test.cpp
Box2D/Examples/TestBed/Framework/Test.h
Box2D/Examples/TestBed/Tests/BroadPhaseTest.h
Box2D/Examples/TestBed/Tests/TestEntries.cpp
Box2D/Source/Collision/b2BroadPhase.h
Box2D/Source/Collision/b2PairManager.h
Box2D/Source/Collision/b2Shape.cpp
Box2D/Source/Common/b2Math.h
Box2D/Source/Dynamics/b2Body.cpp
Box2D/Source/Dynamics/b2ContactManager.cpp
Box2D/Source/Dynamics/b2World.cpp
Box2D/Source/Dynamics/Contacts/b2CircleContact.cpp
Box2D/Source/Dynamics/Contacts/b2ContactSolver.cpp
Box2D/Source/Dynamics/Contacts/b2PolyAndCircleContact.cpp
Box2D/Source/Dynamics/Contacts/b2PolyContact.cpp
Box2D/Source/Dynamics/Joints/b2GearJoint.cpp
Box2D/Source/Dynamics/Joints/b2Joint.cpp
Great! I will apply your patch for the next version.
Tortoise SVN wouldn't allow me to apply the patch. It is missing an "Index:" line.
If you're cleaning up
<memory.h> -> <memory>
<new.h> -> <new>
then you could probably do
<stdlib.h> -> <cstdlib>
<stdio.h> -> <cstdio>
<limits.h> -> <climits>
Also...
I'm still waiting for a CMake patch that works.

It seems that some people are having problems with my change to <cstdio> et al in 1.4.3. Why do you need this change?
It's not a needed change, but it is closer to standard C++...
Right. I know it is more standard, but does it sometimes require a using statement? The MS documentation is vague about this. I would like to avoid the use of namespaces.
Hi !

First a happy new year for every one !

I have updated my patch in order to allow Linux people to use the 1.4.3 version with Cmake files.

To use it :
- download patch.tar.gz and put it in Box2D directory after unzipping it
- untar it (tar xfvz patch.tar.gz) in Box2D_v1.4.3/Box2D directory
- then run put_patch.sh (you'll need a working version of patch utility)
- then run 'cmake .'
- run make
- then run ./Examples/framework or ./Examples/helloworld
- enjoy !

Erin : I have splitted every modification in multiple files in order to ease the integration. Here's a comment for each modification :
diff_b2BroadPhase.h.diff diff_b2Conservative.h.diff diff_b2ContactManager.cpp.diff diff_b2ContactSolver.cpp.diff diff_b2PairManager.cpp.diff diff_b2PairManager.h.diff diff_b2Settings.cpp.diff diff_Test.h.diff : add a line at the end of the file to avoid screaming from g++ about missing empty line at end of file.

diff_TestEntries.cpp.diff diff_Test.cpp.diff diff_Render.cpp.diff diff_BroadPhaseTest.h.diff : new ifdef to allow compilation with a linux box
diff_Main.cpp.diff : ifdef to allow compilation with linux and a cast of a (const char *) to (char *) necessary with gcc to compile.

And finaly 3 new files in order to allow compilation with cmake :
CMakeLists.txt : main cmake file
Examples/CMakeLists.txt : compilation of examples
Source/CMakeLists.txt : compilation of Box2D

Regards,

Yannig
It would be nice if the source in SVN could just include the required makefiles to build the source and build it into a library. Also adding newlines at the end of all the files would be be nice (gcc complains about each and every file every time it sees it).

One other thing, I tried to build the example and it was not easy. I'm using fedora 7. Many of the include files use "gl" in the include path but the directory structure uses "GL". Also the #define __APPLE__ is not consistent with all the changes needed for other Unix implementations. After modifying some of the include stuff and writing some Makefiles I got it all to work based on the current stuff in SVN.

Adding the fixed point port of box2d to the SVN code would also be nice.

Original thread: https://box2d.org/forum/viewtopic.php?t=105