cmake native build files creation

Share your projects and Chipmunk enhancements.
Post Reply
W.P. van Paassen
Posts: 16
Joined: Tue Aug 21, 2007 3:53 am
Contact:

cmake native build files creation

Post by W.P. van Paassen »

Hi,

Thanks for writing ChipMunk, I think it's awesome!

As a token of my appreciation I've added support for native build files creation with cmake (http://www.cmake.org/HTML/Features.html)

This is how it works on GNU/Linux.

*First install cmake if it's not already part of your distribution
*cd to the build directory and type cmake ..
*make

Now the library is in build/source and chipmunk_demos is in build.

The nice part of this is that the makefiles our created out of the
source tree so you can easily do a rm -rf * in directory build and
start over.

Keep up the great work!

Kind regards,
W.P. van Paassen
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: cmake native build files creation

Post by slembcke »

I've added the CMake files to the repository with some slight changes. Seems to work pretty good.

Some questions though:
  • It says that it supports creating MSVC projects. Would this be helpful? It seems there wouldn't be that much work to create a new project from scratch given how little Chipmunk actually has. Though if it could be automated, all the better.
  • How do you get it to install headers?
  • I added a static library target, but it recompiles all the C files to do so. How do you make them share between the targets. Not that it takes that long, just nitpicking.
  • Not sure if I botched my cmake configuration or if I broke your build files when moving them to the new project structure, it tries to install in /usr/local/usr/local/lib.
Otherwise awesome! Thanks again.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
W.P. van Paassen
Posts: 16
Joined: Tue Aug 21, 2007 3:53 am
Contact:

Re: cmake native build files creation

Post by W.P. van Paassen »

slembcke wrote:
  • It says that it supports creating MSVC projects. Would this be helpful? It seems there wouldn't be that much work to create a new project from scratch given how little Chipmunk actually has. Though if it could be automated, all the better.
Yes, this is helpful, I've tried this on win32 and it automatically creates a MSVC project when using cmake on win32. I believe cmake is even able to generate xcode projects for osx. This would mean that you only need to distribute the CMakeList.txt files and use cmake to create the build files for a specific target.
slembcke wrote:
  • I added a static library target, but it recompiles all the C files to do so. How do you make them share between the targets. Not that it takes that long, just nitpicking.
You can't, only the shared library version needs the -fPIC flag for gcc to create position independent code.
You can check this by using make VERBOSE=1
slembcke wrote:
  • How do you get it to install headers?
  • Not sure if I botched my cmake configuration or if I broke your build files when moving them to the new project structure, it tries to install in /usr/local/usr/local/lib.
Replace the INSTALL_TARGETS line in the CMakeLists.txt file in directory src with

INSTALL(TARGETS chipmunk chipmunk_static
LIBRARY DESTINATION /usr/local/lib/chipmunk
ARCHIVE DESTINATION /usr/local/lib/chipmunk
)

INSTALL(FILES
chipmunk.h cpArray.h cpBody.h cpHashSet.h cpPolyShape.h cpSpace.h cpVect.h
cpArbiter.h cpBB.h cpCollision.h cpJoint.h cpShape.h cpSpaceHash.h prime.h
DESTINATION /usr/local/include/chipmunk
)

cheers,
W.P.
milliams
Posts: 11
Joined: Tue Sep 18, 2007 7:11 pm
Location: Portsmouth, UK
Contact:

Re: cmake native build files creation

Post by milliams »

W.P. van Paassen wrote:Yes, this is helpful, I've tried this on win32 and it automatically creates a MSVC project when using cmake on win32. I believe cmake is even able to generate xcode projects for osx. This would mean that you only need to distribute the CMakeList.txt files and use cmake to create the build files for a specific target.
This works very well actually. In our team there's me working on Linux, using CMake to create the gnu make files and our other developer working with Visual Studio and uses CMake to create the VS project files whenever there's a change to the CMakeLists.txt.

I've also written a small patch for the CMakeLists.txt file in the src directory. Firstly it installs the header files (in a similar way to that which W.P. van Paassen described). It also installs the library with the correct command, allowing everything to be installed to a custom location (by passing -DCMAKE_INSTALL_PREFIX=<path> to 'cmake'). Finally, it creates a versioned library in the way that many Unix libraries do it. It should apply just fine against svn revision 149.

p.s. Sorry that the patch is packaged in a tar.gz, but the forum wouldn't let me add an attachment with a .diff, .patch or .txt extension.
W.P. van Paassen
Posts: 16
Joined: Tue Aug 21, 2007 3:53 am
Contact:

Re: cmake native build files creation

Post by W.P. van Paassen »

Hi milliams,

thanks for improving on the cmakelist.txt file. I was wondering though why you kept the installation of the static library out of your patch

INSTALL(TARGETS chipmunk chipmunk_static
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)

Personally I don't want to dynamically link to a physics engine, because after carefully tweaking the physics (and maybe some of it quirks too) the installation of a new shared lib can ruin the game because of fixed (but anticipated for in game) bugs/quirks.

cheers,
W.P.
milliams
Posts: 11
Joined: Tue Sep 18, 2007 7:11 pm
Location: Portsmouth, UK
Contact:

Re: cmake native build files creation

Post by milliams »

I only left it out because in the version in svn, it wasn't being installed. I agree that it probably should be installed for those who wish to statically link.
I've attached an updated patch which installs the static library as libchipmunk.a.
viblo
Posts: 206
Joined: Tue Aug 21, 2007 3:12 pm
Contact:

Re: cmake native build files creation

Post by viblo »

I tried to compile chipmunk on windows with cmake on the code found in svn (rev 149), but I got like a million of errors in visual studio.. (well, a couple of hundred before I ctrl-break:ed). I havent tried to fix it, just hoped it would work out of the box :) I have VS2005 on WindowsXP.

The commands:

Code: Select all

> mkdir build
> cd build
> cmake ..
* open Chipmunk.sln in VS2005 and select compile
http://www.pymunk.org - A python library built on top of Chipmunk to let you easily get cool 2d physics in your python game/app
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests