cmake native build files creation

Share your projects and Chipmunk enhancements.

cmake native build files creation

Postby W.P. van Paassen » Tue Aug 21, 2007 4:07 am

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
W.P. van Paassen
 
Posts: 16
Joined: Tue Aug 21, 2007 3:53 am

Re: cmake native build files creation

Postby slembcke » Sat Aug 25, 2007 1:59 pm

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/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: cmake native build files creation

Postby W.P. van Paassen » Sun Aug 26, 2007 2:49 pm

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.
W.P. van Paassen
 
Posts: 16
Joined: Tue Aug 21, 2007 3:53 am

Re: cmake native build files creation

Postby milliams » Fri Sep 21, 2007 2:12 pm

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.
milliams
 
Posts: 11
Joined: Tue Sep 18, 2007 7:11 pm
Location: Portsmouth, UK

Re: cmake native build files creation

Postby W.P. van Paassen » Fri Sep 21, 2007 3:24 pm

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.
W.P. van Paassen
 
Posts: 16
Joined: Tue Aug 21, 2007 3:53 am

Re: cmake native build files creation

Postby milliams » Fri Sep 21, 2007 3:57 pm

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.
milliams
 
Posts: 11
Joined: Tue Sep 18, 2007 7:11 pm
Location: Portsmouth, UK

Re: cmake native build files creation

Postby viblo » Sun Sep 23, 2007 4:11 pm

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
viblo
 
Posts: 206
Joined: Tue Aug 21, 2007 3:12 pm


Return to Community Creations

Who is online

Users browsing this forum: No registered users and 0 guests

cron