Export to GitHub

box2d - issue #83

CMake enhancements on Unix (includes patch)


Posted on Feb 10, 2010 by Swift Wombat

Thanks for providing CMake build files. Find attached a patch that fixes some problems I've run into on Linux:

  1. There was no easy way to import Box2D into other projects as a dependency. This is fixed by using the install(EXPORT) feature to install some configuration file. After having "make install"'d Box2D, one can create a new project, and use Box2D in it with a CMakeLists.txt like this:

find_package(Box2D REQUIRED) add_executable(myapp ${SOURCES}) target_link_libraries(myapp ${SOME_OTHER_LIBS} Box2D)

  1. The install paths were not specified properly. If one has, for instance, set his CMAKE_INSTALL_PREFIX to "/usr/local", stuff would have been installed to "/usr/local/usr/lib" instead of "/usr/lib".
Attachments

Comment #1

Posted on Feb 10, 2010 by Swift Wombat

Of course, I meant "/usr/local/lib" instead of "/usr/lib" in the last sentence. Should double-check my writing next time...

Comment #2

Posted on Feb 27, 2010 by Swift Wombat

Here is an updated version of above patch. The install() stuff might also be useful on other platforms (in fact on everyone except for MSVC), so I've set this as an option. The platform is still used, but only to determine the default value.

Also, I've changed some stuff in the buildsystem to conform with common conventions. For example, installing files by patterns is considered bad practice because CMake might not notice changes in the repo. Because the filelists are already available, I'm using these instead.

I'll use the rest of the day to make packages for Box2D.

Comment #3

Posted on Feb 27, 2010 by Swift Wombat

Here's the patch. I noticed too late that I messed up line ends, which makes the patch much bigger than it should.

Attachments

Comment #4

Posted on Feb 28, 2010 by Helpful Camel

Patched! Thanks.

Comment #5

Posted on Jul 14, 2010 by Happy Giraffe

Is this usable on Windows? How? I'd like to use Box2D with Qt. Many Thanks.

Status: Fixed

Labels:
Type-Defect Priority-Medium