[osg-users] integrating an external project to OSG via CMake

Philip Lowman philip at yhbt.com
Fri Jul 18 20:52:05 PDT 2008


On Fri, Jul 18, 2008 at 5:35 PM, Mike Weiblen <mike.weiblen at gmail.com>
wrote:

> Intending to finally get osgToy and osgVRPN building again with modern
> OSG via CMake.
>
> I've looked at several other independent nodekits/apps for guidance
> (osggis, mpv, osgppu, vpb, etc) and they all have separate
> CMakeModules directories and use slightly different versions of
> FindOSG.cmake, apparently derived from a single ancestor version in
> OSG itself (which is the oldest)
>
> Is there a single definitive package of CMake goodies (including
> FindOSG.cmake) for uniformly but compatibly building independent (or
> interdependent) nodekits against OSG?  I'm hoping there are some
> resources to jumpstart that integration, else I may need to punt and
> just create hardcoded VS projects for shortterm results.


Mike,

I've submitted a patch to improve the OSG modules released as part of CMake
2.6.x.  It's sitting[1] in the CMake bugtracker, presently unassigned.  You
could download[2] the latest RC for the upcoming CMake 2.6.1 (or just wait
for it to be released, which should be any day now) and use the modules from
the patch and they should work fairly well for you in terms of detecting the
OSG nodekits and linking against them.  The modules won't work with CMake
2.6.0 due to the use of a new feature of find_library called HINTS.

[1] http://public.kitware.com/Bug/view.php?id=7331
[2] http://www.cmake.org/files/v2.6/

The patch facilitates external use of the OSG from MSVC/Win32 which is
something the official OSG CMake modules don't support directly because they
don't have detection of DEBUG libraries of the OSG.

The modules work a little differently from the all-inclusive
FindOpenSceneGraph.cmake that's been floating around in that you must call
FIND_PACKAGE() for both the OSG and any nodekits you're planning on using.
Depending on how many nodekits your project needs this might be a few extra
calls to FIND_PACKAGE() but for projects that don't need every library
released with the OSG being able to include them separately keeps the CMake
cache less cluttered.

find_package(osg) yields...
OSG_INCLUDE_DIR
OSG_LIBRARY
OSG_LIBRARY_DEBUG

find_package(osgDB) yields...
OSGDB_INCLUDE_DIR
OSGDB_LIBRARY
OSGDB_LIBRARY_DEBUG

etc.

On platforms other than MSVC the _LIBRARY_DEBUG variable is simply set to
the contents of the _LIBRARY which allows for a relatively simple
target_link_libraries(foo optimized ${OSG_LIBRARY} debug
${OSG_LIBRARY_DEBUG}) that will work for all platforms.

I have updated the patch to support osgWidget as well.  If anyone has any
additional suggestions to improve the modules, I'm all ears.

-- 
Philip Lowman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080718/a80ef257/attachment-0003.htm>


More information about the osg-users mailing list